Skip to content

Commit

Permalink
resolve comments
Browse files Browse the repository at this point in the history
Signed-off-by: Billy Zha <[email protected]>
  • Loading branch information
qweeah committed Aug 21, 2023
1 parent 87de8df commit 6fcd346
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cmd/oras/internal/option/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type Remote struct {
distributionSpec distributionSpec
headerFlags []string
headers http.Header
hasWarned sync.Map
warned sync.Map
}

// EnableDistributionSpecFlag set distribution specification flag as applicable.
Expand Down Expand Up @@ -250,7 +250,7 @@ func (opts *Remote) Credential() auth.Credential {
}

// NewRegistry assembles a oras remote registry.
func (opts *Remote) NewRegistry(hostname string, warn func(...interface{}), common Common) (reg *remote.Registry, err error) {
func (opts *Remote) NewRegistry(hostname string, warn func(...any), common Common) (reg *remote.Registry, err error) {
reg, err = remote.NewRegistry(hostname)
if err != nil {
return nil, err
Expand All @@ -259,7 +259,7 @@ func (opts *Remote) NewRegistry(hostname string, warn func(...interface{}), comm
reg.PlainHTTP = opts.isPlainHttp(hostname)

reg.HandleWarning = func(warning remote.Warning) {
if _, ok := opts.hasWarned.LoadOrStore(warning.WarningValue, true); ok {
if _, loaded := opts.warned.LoadOrStore(warning.WarningValue, true); !loaded {
warn(warning.Text)
}
}
Expand All @@ -270,7 +270,7 @@ func (opts *Remote) NewRegistry(hostname string, warn func(...interface{}), comm
}

// NewRepository assembles a oras remote repository.
func (opts *Remote) NewRepository(reference string, warn func(...interface{}), common Common) (repo *remote.Repository, err error) {
func (opts *Remote) NewRepository(reference string, warn func(...any), common Common) (repo *remote.Repository, err error) {
repo, err = remote.NewRepository(reference)
if err != nil {
return nil, err
Expand All @@ -282,7 +282,7 @@ func (opts *Remote) NewRepository(reference string, warn func(...interface{}), c
return nil, err
}
repo.HandleWarning = func(warning remote.Warning) {
if _, loaded := opts.hasWarned.LoadOrStore(warning.WarningValue, true); loaded {
if _, loaded := opts.warned.LoadOrStore(warning.WarningValue, true); !loaded {
warn(hostname, warning.Text)
}
}
Expand Down

0 comments on commit 6fcd346

Please sign in to comment.