From f4842ece3eb04b1da4c48918492821817e8eb034 Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Thu, 2 Mar 2023 16:00:38 +0800 Subject: [PATCH] fix!: support multiple config files in `oras cp` (#847) Signed-off-by: Billy Zha --- cmd/oras/internal/option/remote.go | 5 +---- test/e2e/suite/auth/auth.go | 5 ++++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/oras/internal/option/remote.go b/cmd/oras/internal/option/remote.go index 4dde434d8..fab310068 100644 --- a/cmd/oras/internal/option/remote.go +++ b/cmd/oras/internal/option/remote.go @@ -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. diff --git a/test/e2e/suite/auth/auth.go b/test/e2e/suite/auth/auth.go index 55ee99fb8..695d10c86 100644 --- a/test/e2e/suite/auth/auth.go +++ b/test/e2e/suite/auth/auth.go @@ -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")