diff --git a/cmd/oras/internal/option/remote.go b/cmd/oras/internal/option/remote.go index c56282cc2..bf014c74b 100644 --- a/cmd/oras/internal/option/remote.go +++ b/cmd/oras/internal/option/remote.go @@ -42,6 +42,7 @@ import ( // Remote options struct. type Remote struct { + DistributionSpec CACertFilePath string Insecure bool Configs []string @@ -51,7 +52,6 @@ type Remote struct { resolveFlag []string applyDistributionSpec bool - distributionSpec distributionSpec headerFlags []string headers http.Header warned map[string]*sync.Map @@ -93,7 +93,7 @@ func (opts *Remote) ApplyFlagsWithPrefix(fs *pflag.FlagSet, prefix, description flagPrefix, notePrefix = applyPrefix(prefix, description) if opts.applyDistributionSpec { - opts.distributionSpec.ApplyFlagsWithPrefix(fs, prefix, description) + opts.DistributionSpec.ApplyFlagsWithPrefix(fs, prefix, description) } fs.StringVarP(&opts.Username, flagPrefix+"username", shortUser, "", notePrefix+"registry username") fs.StringVarP(&opts.Password, flagPrefix+"password", shortPassword, "", notePrefix+"registry password or identity token") @@ -117,7 +117,7 @@ func (opts *Remote) Parse() error { if err := opts.readPassword(); err != nil { return err } - return opts.distributionSpec.Parse() + return opts.DistributionSpec.Parse() } // readPassword tries to read password with optional cmd prompt. @@ -299,8 +299,8 @@ func (opts *Remote) NewRepository(reference string, common Common, logger logrus return nil, err } repo.SkipReferrersGC = true - if opts.distributionSpec.referrersAPI != nil { - if err := repo.SetReferrersCapability(*opts.distributionSpec.referrersAPI); err != nil { + if opts.ReferrersAPI != nil { + if err := repo.SetReferrersCapability(*opts.ReferrersAPI); err != nil { return nil, err } } diff --git a/cmd/oras/internal/option/spec.go b/cmd/oras/internal/option/spec.go index 837959761..965eb929b 100644 --- a/cmd/oras/internal/option/spec.go +++ b/cmd/oras/internal/option/spec.go @@ -51,27 +51,27 @@ func (opts *ImageSpec) ApplyFlags(fs *pflag.FlagSet) { fs.StringVar(&opts.flag, "image-spec", ImageSpecV1_1, fmt.Sprintf("[Experimental] specify manifest type for building artifact. options: %s, %s", ImageSpecV1_1, ImageSpecV1_0)) } -// distributionSpec option struct. -type distributionSpec struct { - // referrersAPI indicates the preference of the implementation of the Referrers API. +// DistributionSpec option struct. +type DistributionSpec struct { + // ReferrersAPI indicates the preference of the implementation of the Referrers API. // Set to true for referrers API, false for referrers tag scheme, and nil for auto fallback. - referrersAPI *bool + ReferrersAPI *bool // specFlag should be provided in form of`--