Skip to content

Commit 714f5bf

Browse files
authored
Merge pull request #6744 from thaJeztah/registryclient_cleanups
internal/registryclient: minor cleanups
2 parents 49b7be0 + 816f455 commit 714f5bf

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

internal/registryclient/fetcher.go

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ func continueOnError(err error) bool {
216216
}
217217

218218
func (c *client) iterateEndpoints(ctx context.Context, namedRef reference.Named, each func(context.Context, distribution.Repository, reference.Named) (bool, error)) error {
219-
endpoints, err := allEndpoints(namedRef, c.insecureRegistry)
219+
endpoints, err := allEndpoints(ctx, namedRef, c.insecureRegistry)
220220
if err != nil {
221221
return err
222222
}
@@ -271,11 +271,11 @@ func (c *client) iterateEndpoints(ctx context.Context, namedRef reference.Named,
271271
return nil
272272
}
273273
}
274-
return newNotFoundError(namedRef.String())
274+
return notFoundError{errors.New("no such manifest: " + namedRef.String())}
275275
}
276276

277277
// allEndpoints returns a list of endpoints ordered by priority (v2, http).
278-
func allEndpoints(namedRef reference.Named, insecure bool) ([]registry.APIEndpoint, error) {
278+
func allEndpoints(ctx context.Context, namedRef reference.Named, insecure bool) ([]registry.APIEndpoint, error) {
279279
var serviceOpts registry.ServiceOptions
280280
if insecure {
281281
logrus.Debugf("allowing insecure registry for: %s", reference.Domain(namedRef))
@@ -285,22 +285,11 @@ func allEndpoints(namedRef reference.Named, insecure bool) ([]registry.APIEndpoi
285285
if err != nil {
286286
return nil, err
287287
}
288-
endpoints, err := registryService.Endpoints(context.TODO(), reference.Domain(namedRef))
288+
endpoints, err := registryService.Endpoints(ctx, reference.Domain(namedRef))
289289
logrus.Debugf("endpoints for %s: %v", namedRef, endpoints)
290290
return endpoints, err
291291
}
292292

293-
func newNotFoundError(ref string) *notFoundError {
294-
return &notFoundError{err: errors.New("no such manifest: " + ref)}
295-
}
296-
297-
type notFoundError struct {
298-
err error
299-
}
300-
301-
func (n *notFoundError) Error() string {
302-
return n.err.Error()
303-
}
293+
type notFoundError struct{ error }
304294

305-
// NotFound satisfies interface github.com/docker/docker/errdefs.ErrNotFound
306295
func (notFoundError) NotFound() {}

0 commit comments

Comments
 (0)