Skip to content

Commit eda78e9

Browse files
committed
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>
1 parent 581cf36 commit eda78e9

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

cli/command/registry.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,8 @@ func PromptUserForCredentials(ctx context.Context, cli Cli, argUser, argPassword
123123
cli.SetIn(streams.NewIn(os.Stdin))
124124
}
125125

126-
defaultUsername = strings.TrimSpace(defaultUsername)
127-
128-
if argUser = strings.TrimSpace(argUser); argUser == "" {
126+
argUser = strings.TrimSpace(argUser)
127+
if argUser == "" {
129128
if serverAddress == registry.IndexServer {
130129
// if this is a default registry (docker hub), then display the following message.
131130
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.")
@@ -136,6 +135,7 @@ func PromptUserForCredentials(ctx context.Context, cli Cli, argUser, argPassword
136135
}
137136

138137
var prompt string
138+
defaultUsername = strings.TrimSpace(defaultUsername)
139139
if defaultUsername == "" {
140140
prompt = "Username: "
141141
} else {

0 commit comments

Comments
 (0)