diff --git a/pkg/auth/auth.go b/pkg/auth/auth.go index a9ad60f43..d2e75c1f7 100644 --- a/pkg/auth/auth.go +++ b/pkg/auth/auth.go @@ -134,9 +134,13 @@ func Login(ctx context.Context, systemContext *types.SystemContext, opts *LoginO if err = docker.CheckAuth(ctx, systemContext, username, password, server); err == nil { // Write the new credentials to the authfile - if err := config.SetAuthentication(systemContext, server, username, password); err != nil { + desc, err := config.SetCredentials(systemContext, server, username, password) + if err != nil { return err } + if opts.Verbose { + fmt.Fprintln(opts.Stdout, "Used: ", desc) + } } if err == nil { fmt.Fprintln(opts.Stdout, "Login Succeeded!") diff --git a/pkg/auth/cli.go b/pkg/auth/cli.go index 1d8eed4ac..5a7c1137c 100644 --- a/pkg/auth/cli.go +++ b/pkg/auth/cli.go @@ -20,6 +20,7 @@ type LoginOptions struct { Username string StdinPassword bool GetLoginSet bool + Verbose bool // set to true for verbose output // Options caller can set Stdin io.Reader // set to os.Stdin Stdout io.Writer // set to os.Stdout @@ -47,6 +48,7 @@ func GetLoginFlags(flags *LoginOptions) *pflag.FlagSet { fs.StringVarP(&flags.Username, "username", "u", "", "Username for registry") fs.BoolVar(&flags.StdinPassword, "password-stdin", false, "Take the password from stdin") fs.BoolVar(&flags.GetLoginSet, "get-login", false, "Return the current login user for the registry") + fs.BoolVarP(&flags.Verbose, "verbose", "v", false, "Write more detailed information to stdout") return &fs }