diff --git a/cmd/oras/internal/option/remote.go b/cmd/oras/internal/option/remote.go index 927780f9d..cb4e30f6c 100644 --- a/cmd/oras/internal/option/remote.go +++ b/cmd/oras/internal/option/remote.go @@ -67,6 +67,7 @@ func (opts *Remote) EnableDistributionSpecFlag() { func (opts *Remote) ApplyFlags(fs *pflag.FlagSet) { opts.ApplyFlagsWithPrefix(fs, "", "") fs.BoolVarP(&opts.PasswordFromStdin, "password-stdin", "", false, "read password or identity token from stdin") + opts.warned = &sync.Map{} } func applyPrefix(prefix, description string) (flagPrefix, notePrefix string) { @@ -107,7 +108,6 @@ func (opts *Remote) ApplyFlagsWithPrefix(fs *pflag.FlagSet, prefix, description // Parse tries to read password with optional cmd prompt. func (opts *Remote) Parse() error { - opts.warned = &sync.Map{} if err := opts.parseCustomHeaders(); err != nil { return err } diff --git a/cmd/oras/internal/option/target.go b/cmd/oras/internal/option/target.go index df5e676ae..bebdb547d 100644 --- a/cmd/oras/internal/option/target.go +++ b/cmd/oras/internal/option/target.go @@ -21,6 +21,7 @@ import ( "fmt" "os" "strings" + "sync" "github.com/sirupsen/logrus" "github.com/spf13/pflag" @@ -200,6 +201,8 @@ func (opts *BinaryTarget) ApplyFlags(fs *pflag.FlagSet) { opts.From.ApplyFlagsWithPrefix(fs, "from", "source") opts.To.ApplyFlagsWithPrefix(fs, "to", "destination") fs.StringArrayVarP(&opts.resolveFlag, "resolve", "", nil, "base DNS rules formatted in `host:port:address[:address_port]` for --from-resolve and --to-resolve") + opts.From.warned = &sync.Map{} + opts.To.warned = opts.From.warned } // Parse parses user-provided flags and arguments into option struct.