Skip to content

Commit

Permalink
fix!: support multiple config files in oras cp (oras-project#847)
Browse files Browse the repository at this point in the history
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
  • Loading branch information
qweeah authored Mar 2, 2023
1 parent 12097db commit f4842ec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 1 addition & 4 deletions cmd/oras/internal/option/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,7 @@ func (opts *Remote) ApplyFlagsWithPrefix(fs *pflag.FlagSet, prefix, description
fs.BoolVarP(&opts.PlainHTTP, flagPrefix+"plain-http", "", false, "allow insecure connections to "+notePrefix+"registry without SSL check")
fs.StringVarP(&opts.CACertFilePath, flagPrefix+"ca-file", "", "", "server certificate authority file for the remote "+notePrefix+"registry")
fs.StringArrayVarP(&opts.resolveFlag, flagPrefix+"resolve", "", nil, "customized DNS for "+notePrefix+"registry, formatted in `host:port:address[:address_port]`")

if fs.Lookup("registry-config") == nil {
fs.StringArrayVarP(&opts.Configs, "registry-config", "", nil, "`path` of the authentication file")
}
fs.StringArrayVarP(&opts.Configs, flagPrefix+"registry-config", "", nil, "`path` of the authentication file for "+notePrefix+"registry")
}

// Parse tries to read password with optional cmd prompt.
Expand Down
5 changes: 4 additions & 1 deletion test/e2e/suite/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ var _ = Describe("Common registry user", Ordered, func() {

It("should run commands without logging in", func() {
RunWithoutLogin("attach", Host+"/repo:tag", "-a", "test=true", "--artifact-type", "doc/example")
RunWithoutLogin("copy", Host+"/repo:from", Host+"/repo:to")
ORAS("copy", Host+"/repo:from", Host+"/repo:to", "--from-registry-config", AuthConfigPath, "--to-registry-config", AuthConfigPath).
ExpectFailure().
MatchErrKeyWords("Error:", "credential required").
WithDescription("fail without logging in").Exec()
RunWithoutLogin("discover", Host+"/repo:tag")
RunWithoutLogin("push", "-a", "key=value", Host+"/repo:tag")
RunWithoutLogin("pull", Host+"/repo:tag")
Expand Down

0 comments on commit f4842ec

Please sign in to comment.