Skip to content

Commit

Permalink
Merge pull request #1334 from vrothberg/auth
Browse files Browse the repository at this point in the history
pkg/auth: add `NoWriteBack` option
  • Loading branch information
openshift-merge-robot authored Feb 20, 2023
2 parents 7d797f2 + 3992a68 commit 792735e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
18 changes: 9 additions & 9 deletions pkg/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,16 @@ func Login(ctx context.Context, systemContext *types.SystemContext, opts *LoginO
}

if err = docker.CheckAuth(ctx, systemContext, username, password, registry); err == nil {
// Write the new credentials to the authfile
desc, err := config.SetCredentials(systemContext, key, username, password)
if err != nil {
return err
}
if opts.Verbose {
fmt.Fprintln(opts.Stdout, "Used: ", desc)
if !opts.NoWriteBack {
// Write the new credentials to the authfile
desc, err := config.SetCredentials(systemContext, key, 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!")
return nil
}
Expand Down
1 change: 1 addition & 0 deletions pkg/auth/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type LoginOptions struct {
Stdin io.Reader // set to os.Stdin
Stdout io.Writer // set to os.Stdout
AcceptUnspecifiedRegistry bool // set to true if allows login with unspecified registry
NoWriteBack bool // set to true to not write the credentials to the authfile/cred helpers
}

// LogoutOptions represents the results for flags in logout
Expand Down

0 comments on commit 792735e

Please sign in to comment.