Skip to content

Commit 831704e

Browse files
committed
search: do not sort results by stars on client side
Once upon a time, there was a website named ["The Docker index"][2]; a complimentary service for users of Docker, provided by dotCloud. The Docker Index was the place to find and explore pre-made container images, and allowed you to [share your images and download them][1]. The Docker Index evolved rapidly, and gained new features, such as [Trusted Images][3], and "stars" to rank your favorite images. The website also provided an API, which allowed you to search images, even from the comfort of your `docker` CLI. Things moved fast in container-land, and while there was an API to use, it was still a work in progress. While the Docker Index allowed users to "star" images, the search API did not rank results accordingly. As any engineer knows, there's no problem that can't be solved with some elbow- grease and a piece of Duct tape, so while the Docker Index team worked on making the search API better, the `docker` engine [fixed the problem on the client side][4] Years went by, and the Docker Index API became the "registry V1" specification, including search. The registry got a major "v2" rewrite and became the [OCI Distribution Spec][5], and Docker Index became Docker Hub, which included V2 and V3 search APIs. The V1 search API continued to be supported, as it was the only documented API for registries, but improvements were made, including ranking of search results. Duct tape is durable, and even though improvements were made, the Docker client continued to sort the results as well. Unfortunately, this meant that search results on the command-line were ranked different from their equivalent on the registry (such as Docker Hub). This patch removes the client-side sorting of results, using the order in which the search API returned them to (finally) celebrate the work of the engineers working on the search API, also when used from the command-line. [1]: https://web.archive.org/web/20130708004229/http://docker.io/ [2]: https://web.archive.org/web/20130623223614/https://index.docker.io/ [3]: https://web.archive.org/web/20140208001647/https://index.docker.io/ [4]: moby/moby@1669b80 [5]: https://github.com/opencontainers/distribution-spec Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 55cb22d commit 831704e

File tree

1 file changed

+0
-4
lines changed

1 file changed

+0
-4
lines changed

cli/command/registry/search.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package registry
22

33
import (
44
"context"
5-
"sort"
65

76
"github.com/docker/cli/cli"
87
"github.com/docker/cli/cli/command"
@@ -75,9 +74,6 @@ func runSearch(dockerCli command.Cli, options searchOptions) error {
7574
return err
7675
}
7776

78-
sort.Slice(results, func(i, j int) bool {
79-
return results[j].StarCount < results[i].StarCount
80-
})
8177
searchCtx := formatter.Context{
8278
Output: dockerCli.Out(),
8379
Format: NewSearchFormat(options.format),

0 commit comments

Comments
 (0)