Skip to content

Commit

Permalink
refinement
Browse files Browse the repository at this point in the history
Signed-off-by: Xiaoxuan Wang <[email protected]>
  • Loading branch information
wangxiaoxuan273 committed Mar 20, 2024
1 parent 38f0112 commit c508781
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions cmd/oras/internal/option/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ func (opts *Remote) ApplyFlagsWithPrefix(fs *pflag.FlagSet, prefix, description
if opts.applyDistributionSpec {
opts.DistributionSpec.ApplyFlagsWithPrefix(fs, prefix, description)
}
fs.StringVarP(&opts.Username, opts.flagPrefix+"username", shortUser, "", opts.notePrefix+"registry username")
fs.StringVarP(&opts.Password, opts.flagPrefix+"password", shortPassword, "", opts.notePrefix+"registry password")
fs.StringVarP(&opts.identityToken, opts.flagPrefix+"identity-token", "", "", opts.notePrefix+"registry identity token")
fs.StringVarP(&opts.Username, opts.flagPrefix+usernameFlag, shortUser, "", opts.notePrefix+"registry username")
fs.StringVarP(&opts.Password, opts.flagPrefix+passwordFlag, shortPassword, "", opts.notePrefix+"registry password")
fs.StringVarP(&opts.identityToken, opts.flagPrefix+identityTokenFlag, "", "", opts.notePrefix+"registry identity token")
fs.BoolVarP(&opts.Insecure, opts.flagPrefix+"insecure", "", false, "allow connections to "+opts.notePrefix+"SSL registry without certs")
plainHTTPFlagName := opts.flagPrefix + "plain-http"
plainHTTP := fs.Bool(plainHTTPFlagName, false, "allow insecure connections to "+opts.notePrefix+"registry without SSL check")
Expand All @@ -132,9 +132,9 @@ func (opts *Remote) ApplyFlagsWithPrefix(fs *pflag.FlagSet, prefix, description
// conflicts with read file from input.
func (opts *Remote) CheckStdinConflict() error {
if opts.PasswordFromStdin {
return fmt.Errorf("`-` read file from input and `%s` read password from input cannot be both used", passwordFromStdinFlag)
return fmt.Errorf("`-` read file from input and `--%s` read password from input cannot be both used", passwordFromStdinFlag)
} else if opts.IdentityTokenFromStdin {
return fmt.Errorf("`-` read file from input and `%s` read identity token from input cannot be both used", identityTokenFromStdinFlag)
return fmt.Errorf("`-` read file from input and `--%s` read identity token from input cannot be both used", identityTokenFromStdinFlag)
}

Check warning on line 138 in cmd/oras/internal/option/remote.go

View check run for this annotation

Codecov / codecov/patch

cmd/oras/internal/option/remote.go#L137-L138

Added lines #L137 - L138 were not covered by tests
return nil
}
Expand All @@ -156,7 +156,7 @@ func (opts *Remote) Parse() error {
[]string{opts.flagPrefix + usernameFlag, opts.flagPrefix + passwordFlag, passwordFromStdinFlag})

if identityTokenFlag != "" && basicAuthFlag != "" {
return fmt.Errorf("%s cannot be used with %s", basicAuthFlag, identityTokenFlag)
return fmt.Errorf("--%s cannot be used with --%s", basicAuthFlag, identityTokenFlag)
}

if err := opts.parseCustomHeaders(); err != nil {
Expand Down

0 comments on commit c508781

Please sign in to comment.