mirror of https://github.com/docker/cli.git
cli/command: PromptUserForCredentials: use consts for all hints
This message resulted in code-lines that were too long; move it to a
const together with the other hint. While at it, also suppress unhandled
error, and touch-up the code-comment.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 378a3d7d36
)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
da3a1c3027
commit
ddeb7eb4ed
|
@ -19,9 +19,13 @@ import (
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
const patSuggest = "You can log in with your password or a Personal Access " +
|
const (
|
||||||
|
registerSuggest = "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."
|
||||||
|
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 " +
|
"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/"
|
"for organizations using SSO. Learn more at https://docs.docker.com/go/access-tokens/"
|
||||||
|
)
|
||||||
|
|
||||||
// RegistryAuthenticationPrivilegedFunc returns a RequestPrivilegeFunc from the specified registry index info
|
// RegistryAuthenticationPrivilegedFunc returns a RequestPrivilegeFunc from the specified registry index info
|
||||||
// for the given command.
|
// for the given command.
|
||||||
|
@ -128,8 +132,10 @@ func PromptUserForCredentials(ctx context.Context, cli Cli, argUser, argPassword
|
||||||
argUser = strings.TrimSpace(argUser)
|
argUser = strings.TrimSpace(argUser)
|
||||||
if argUser == "" {
|
if argUser == "" {
|
||||||
if serverAddress == registry.IndexServer {
|
if serverAddress == registry.IndexServer {
|
||||||
// if this is a default registry (docker hub), then display the following message.
|
// When signing in to the default (Docker Hub) registry, we display
|
||||||
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.")
|
// hints for creating an account, and (if hints are enabled), using
|
||||||
|
// a token instead of a password.
|
||||||
|
_, _ = fmt.Fprintln(cli.Out(), registerSuggest)
|
||||||
if hints.Enabled() {
|
if hints.Enabled() {
|
||||||
fmt.Fprintln(cli.Out(), patSuggest)
|
fmt.Fprintln(cli.Out(), patSuggest)
|
||||||
fmt.Fprintln(cli.Out())
|
fmt.Fprintln(cli.Out())
|
||||||
|
|
Loading…
Reference in New Issue