mirror of https://github.com/docker/cli.git
cli/command: PromptUserForCredentials: move trimming where it's used
- move trimming defaultUsername inside the if-branch, as it's the only
location where the result of the trimmed username is use.
- do the reverse for trimming argUser, because the result of trimming
argUser is used outside of the if-branch (not just for the condition).
putting it inside the condition makes it easy to assume the result is
only used locally.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit eda78e9cdc
)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
97c25b7574
commit
78dbcca264
|
@ -125,9 +125,8 @@ func PromptUserForCredentials(ctx context.Context, cli Cli, argUser, argPassword
|
||||||
cli.SetIn(streams.NewIn(os.Stdin))
|
cli.SetIn(streams.NewIn(os.Stdin))
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultUsername = strings.TrimSpace(defaultUsername)
|
argUser = strings.TrimSpace(argUser)
|
||||||
|
if argUser == "" {
|
||||||
if argUser = strings.TrimSpace(argUser); argUser == "" {
|
|
||||||
if serverAddress == registry.IndexServer {
|
if serverAddress == registry.IndexServer {
|
||||||
// if this is a default registry (docker hub), then display the following message.
|
// if this is a default registry (docker hub), then display the following message.
|
||||||
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.")
|
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.")
|
||||||
|
@ -138,6 +137,7 @@ func PromptUserForCredentials(ctx context.Context, cli Cli, argUser, argPassword
|
||||||
}
|
}
|
||||||
|
|
||||||
var prompt string
|
var prompt string
|
||||||
|
defaultUsername = strings.TrimSpace(defaultUsername)
|
||||||
if defaultUsername == "" {
|
if defaultUsername == "" {
|
||||||
prompt = "Username: "
|
prompt = "Username: "
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue