diff options
author | Sebastiaan van Stijn <github@gone.nl> | 2022-02-26 14:32:13 +0100 |
---|---|---|
committer | Sebastiaan van Stijn <github@gone.nl> | 2022-03-17 17:12:21 +0100 |
commit | 9cb0aa4c9164268f72da13bd74b827390ff511ff (patch) | |
tree | 75fe564b80f0aaa4cc4c799a55a0183db67d5b50 /registry/service.go | |
parent | d3c3e2c867804b3dd51e8bd59a7427e84502b92a (diff) | |
download | docker-9cb0aa4c9164268f72da13bd74b827390ff511ff.tar.gz |
registry: minor improvements and cleanup
- registry: newIndexInfo(): minor refactor
- registry: loadAllowNondistributableArtifacts() minor refactor
initialise the slices with a length.
- registry: defaultService.Search(): minor refactor
Perform all manipulation earlier, so that it's not needed to scroll up
to learn what's done.
- various other minor cleanups
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Diffstat (limited to 'registry/service.go')
-rw-r--r-- | registry/service.go | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/registry/service.go b/registry/service.go index 8b95f71bd7..d66736cb4f 100644 --- a/registry/service.go +++ b/registry/service.go @@ -174,8 +174,11 @@ func (s *defaultService) Search(ctx context.Context, term string, limit int, aut if err != nil { return nil, err } + if index.Official { + // If pull "library/foo", it's stored locally under "foo" + remoteName = strings.TrimPrefix(remoteName, "library/") + } - // *TODO: Search multiple indexes. endpoint, err := newV1Endpoint(index, userAgent, headers) if err != nil { return nil, err @@ -195,7 +198,7 @@ func (s *defaultService) Search(ctx context.Context, term string, limit int, aut v2Client, err := v2AuthHTTPClient(endpoint.URL, endpoint.client.Transport, modifiers, creds, scopes) if err != nil { if fErr, ok := err.(fallbackError); ok { - logrus.Errorf("Cannot use identity token for search, v2 auth not supported: %v", fErr.err) + logrus.WithError(fErr.err).Error("cannot use identity token for search, v2 auth not supported") } else { return nil, err } @@ -217,13 +220,7 @@ func (s *defaultService) Search(ctx context.Context, term string, limit int, aut } } - r := newSession(client, endpoint) - - if index.Official { - // If pull "library/foo", it's stored locally under "foo" - remoteName = strings.TrimPrefix(remoteName, "library/") - } - return r.searchRepositories(remoteName, limit) + return newSession(client, endpoint).searchRepositories(remoteName, limit) } // ResolveRepository splits a repository name into its components |