Skip to content

Commit 378a3d7

Browse files
committed
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>
1 parent 3d8b495 commit 378a3d7

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

cli/command/registry.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@ import (
1818
"github.com/pkg/errors"
1919
)
2020

21-
const patSuggest = "You can log in with your password or a Personal Access " +
22-
"Token (PAT). Using a limited-scope PAT grants better security and is required " +
23-
"for organizations using SSO. Learn more at https://docs.docker.com/go/access-tokens/"
21+
const (
22+
registerSuggest = "Log in with your Docker ID or email address to push and pull images from Docker Hub. " +
23+
"If you don't have a Docker ID, head over to https://hub.docker.com/ to create one."
24+
patSuggest = "You can log in with your password or a Personal Access " +
25+
"Token (PAT). Using a limited-scope PAT grants better security and is required " +
26+
"for organizations using SSO. Learn more at https://docs.docker.com/go/access-tokens/"
27+
)
2428

2529
// RegistryAuthenticationPrivilegedFunc returns a RequestPrivilegeFunc from the specified registry index info
2630
// for the given command.
@@ -126,8 +130,10 @@ func PromptUserForCredentials(ctx context.Context, cli Cli, argUser, argPassword
126130
argUser = strings.TrimSpace(argUser)
127131
if argUser == "" {
128132
if serverAddress == registry.IndexServer {
129-
// if this is a default registry (docker hub), then display the following message.
130-
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.")
133+
// When signing in to the default (Docker Hub) registry, we display
134+
// hints for creating an account, and (if hints are enabled), using
135+
// a token instead of a password.
136+
_, _ = fmt.Fprintln(cli.Out(), registerSuggest)
131137
if hints.Enabled() {
132138
fmt.Fprintln(cli.Out(), patSuggest)
133139
fmt.Fprintln(cli.Out())

0 commit comments

Comments
 (0)