From 581cf36bd4206b4cccf3cd1ad93162bbbffaad37 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 --- 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 92ea17f90c..b2696d7b1d 100644 --- a/cli/command/registry.go +++ b/cli/command/registry.go @@ -150,10 +150,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 {