From 97c25b75748ee396ac6153c9447eaa47ad33cbc9 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sat, 19 Oct 2024 12:01:25 +0200 Subject: [PATCH] cli/command: PromptUserForCredentials: move "post" check for empty name move the "post" check for username being empty inside the branch that's handling the username, as it's the only branch where username is mutated after checking if it's empty. Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 581cf36bd4206b4cccf3cd1ad93162bbbffaad37) Signed-off-by: Sebastiaan van Stijn --- cli/command/registry.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cli/command/registry.go b/cli/command/registry.go index 51fff10c5f..11fad3fe1f 100644 --- a/cli/command/registry.go +++ b/cli/command/registry.go @@ -152,10 +152,11 @@ func PromptUserForCredentials(ctx context.Context, cli Cli, argUser, argPassword if argUser == "" { argUser = defaultUsername } + if argUser == "" { + return registrytypes.AuthConfig{}, errors.Errorf("Error: Non-null Username Required") + } } - if argUser == "" { - return registrytypes.AuthConfig{}, errors.Errorf("Error: Non-null Username Required") - } + if argPassword == "" { restoreInput, err := DisableInputEcho(cli.In()) if err != nil {