1
0
mirror of https://github.com/docker/cli.git synced 2026-01-26 15:41:42 +03:00

Merge pull request #6744 from thaJeztah/registryclient_cleanups

internal/registryclient: minor cleanups
This commit is contained in:
Paweł Gronowski
2026-01-16 11:33:23 +00:00
committed by GitHub

View File

@@ -216,7 +216,7 @@ func continueOnError(err error) bool {
}
func (c *client) iterateEndpoints(ctx context.Context, namedRef reference.Named, each func(context.Context, distribution.Repository, reference.Named) (bool, error)) error {
endpoints, err := allEndpoints(namedRef, c.insecureRegistry)
endpoints, err := allEndpoints(ctx, namedRef, c.insecureRegistry)
if err != nil {
return err
}
@@ -271,11 +271,11 @@ func (c *client) iterateEndpoints(ctx context.Context, namedRef reference.Named,
return nil
}
}
return newNotFoundError(namedRef.String())
return notFoundError{errors.New("no such manifest: " + namedRef.String())}
}
// allEndpoints returns a list of endpoints ordered by priority (v2, http).
func allEndpoints(namedRef reference.Named, insecure bool) ([]registry.APIEndpoint, error) {
func allEndpoints(ctx context.Context, namedRef reference.Named, insecure bool) ([]registry.APIEndpoint, error) {
var serviceOpts registry.ServiceOptions
if insecure {
logrus.Debugf("allowing insecure registry for: %s", reference.Domain(namedRef))
@@ -285,22 +285,11 @@ func allEndpoints(namedRef reference.Named, insecure bool) ([]registry.APIEndpoi
if err != nil {
return nil, err
}
endpoints, err := registryService.Endpoints(context.TODO(), reference.Domain(namedRef))
endpoints, err := registryService.Endpoints(ctx, reference.Domain(namedRef))
logrus.Debugf("endpoints for %s: %v", namedRef, endpoints)
return endpoints, err
}
func newNotFoundError(ref string) *notFoundError {
return &notFoundError{err: errors.New("no such manifest: " + ref)}
}
type notFoundError struct{ error }
type notFoundError struct {
err error
}
func (n *notFoundError) Error() string {
return n.err.Error()
}
// NotFound satisfies interface github.com/docker/docker/errdefs.ErrNotFound
func (notFoundError) NotFound() {}