-
Notifications
You must be signed in to change notification settings - Fork 2.1k
login: Add message about using PATs #4478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ import ( | |
| "strings" | ||
|
|
||
| configtypes "github.com/docker/cli/cli/config/types" | ||
| "github.com/docker/cli/cli/hints" | ||
| "github.com/docker/cli/cli/streams" | ||
| "github.com/docker/distribution/reference" | ||
| "github.com/docker/docker/api/types" | ||
|
|
@@ -19,6 +20,10 @@ import ( | |
| "github.com/pkg/errors" | ||
| ) | ||
|
|
||
| const patSuggest = "You can log in with your password or a Personal Access " + | ||
| "Token (PAT). Using a limited-scope PAT grants better security and is required " + | ||
| "for organizations using SSO. Learn more at https://docs.docker.com/go/access-tokens/" | ||
|
|
||
| // RegistryAuthenticationPrivilegedFunc returns a RequestPrivilegeFunc from the specified registry index info | ||
| // for the given command. | ||
| func RegistryAuthenticationPrivilegedFunc(cli Cli, index *registrytypes.IndexInfo, cmdName string) types.RequestPrivilegeFunc { | ||
|
|
@@ -106,7 +111,11 @@ func ConfigureAuth(cli Cli, flUser, flPassword string, authconfig *registrytypes | |
| if flUser = strings.TrimSpace(flUser); flUser == "" { | ||
| if isDefaultRegistry { | ||
| // if this is a default registry (docker hub), then display the following message. | ||
| fmt.Fprintln(cli.Out(), "Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.") | ||
| fmt.Fprintln(cli.Out(), "Log in with your Docker ID or email address to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com/ to create one.") | ||
neersighted marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if hints.Enabled() { | ||
| fmt.Fprintln(cli.Out(), patSuggest) | ||
| fmt.Fprintln(cli.Out()) | ||
|
Comment on lines
+116
to
+117
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We probably can't / shouldn't change the existing (old) hint, but perhaps we should use |
||
| } | ||
| } | ||
| promptWithDefault(cli.Out(), "Username", authconfig.Username) | ||
| var err error | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package hints | ||
|
|
||
| import ( | ||
| "os" | ||
| "strconv" | ||
| ) | ||
|
|
||
| // Enabled returns whether cli hints are enabled or not | ||
| func Enabled() bool { | ||
| if v := os.Getenv("DOCKER_CLI_HINTS"); v != "" { | ||
| enabled, err := strconv.ParseBool(v) | ||
| if err != nil { | ||
| return true | ||
| } | ||
| return enabled | ||
| } | ||
| return true | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps use a string-literal for this (back-tick)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn’t use them because we don’t want newlines