Skip to content

Commit

Permalink
search: catalog: return full match as first item
Browse files Browse the repository at this point in the history
When searching via v2/catalog make sure that a full match is returned as
the first item.  The change is motivated by a conversation in a BZ [1]
on the rather undefined nature/semantics of searching images.

While this change does not fix the BZ, it may be a small improvement
when using the v2/catalog endpoint.

[1] bugzilla.redhat.com/show_bug.cgi?id=1976283

Signed-off-by: Valentin Rothberg <[email protected]>
  • Loading branch information
vrothberg committed Jul 13, 2021
1 parent 5a7aad2 commit c031c43
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion docker/docker_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,14 @@ func SearchRegistry(ctx context.Context, sys *types.SystemContext, registry, ima
res := SearchResult{
Name: repo,
}
searchRes = append(searchRes, res)
// bugzilla.redhat.com/show_bug.cgi?id=1976283
// If we have a full match, make sure it's listed as the first result.
// (Note there might be a full match we never see if we reach the result limit first.)
if repo == image {
searchRes = append([]SearchResult{res}, searchRes...)
} else {
searchRes = append(searchRes, res)
}
}
}

Expand Down

0 comments on commit c031c43

Please sign in to comment.