Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] default sort order of "tag ls" enhancements #151

Open
thaJeztah opened this issue Jan 6, 2021 · 3 comments
Open

[RFC] default sort order of "tag ls" enhancements #151

thaJeztah opened this issue Jan 6, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@thaJeztah
Copy link
Member

Description

NOTE: I haven't given this a lot of thought (yet), but thought I should write down some thoughts

This started mostly because I was playing with hub-tool tag ls, and got curious; "so, what's the default sort order??".

I didn't see what the output of hub-tool tag ls was sorted on, then I thought it was on "last pulled", but that didn't seem to be the order either?

$ hub-tool tag ls nginx

TAG                           DIGEST                                                                     STATUS    LAST UPDATE      LAST PUSHED    LAST PULLED       SIZE
nginx:latest                  sha256:f19d295b57fdde6f71573f487b35875ca95bd23401b142eb55eeb9d887f9f5b1    active    3 weeks ago      3 weeks        About a minute    421.2MB
nginx:stable-alpine-perl      sha256:0c85226446a083d92fbf432faee51d12933eafdcf13eb0b7d06fc465368ae908    active    2 weeks ago      2 weeks        8 seconds         124.8MB
nginx:stable-alpine           sha256:da3716611fb965f3fda1f3281882baeb2760ca8bb7317f1d22ed45e75570827b    active    2 weeks ago      2 weeks        10 minutes        64.99MB

Include sort order in summary

First thing I noticed, is that we don't show what the output is sorted on. The output does contain a notice about number of tags; perhaps we should include information about sorting there as well;

100/325 listed, use --all flag to show all

Mention default sort order in "usage" output

The --help output also doesn't include the default;

$ hub-tool tag ls --help

List all the images in a repository

Usage:
  hub-tool tag ls [OPTION] REPOSITORY

Aliases:
  ls, list

Flags:
      --all             Fetch all available tags
      --format string   Print values using a custom format ("json")
  -h, --help            help for ls
      --platforms       List all available platforms per tag
      --sort string     Sort tags by (updated|name)[=(asc|desc)] (e.g.: --sort updated or --sort name=desc)

Global Flags:
      --verbose   Print logs

"Last pulled" is not an option for --sort

Interestingly, last pulled is not an option for --sort, which means that I cannot manually / explicitly specify the output to be sorted by "last pulled". Being able to sort by "last pulled" can assist users when (if?) retention limits will be introduced.

We should probably add that as an option if possible

Sort by "last updated" as a default?

Perhaps last updated or last pushed would make more sense as a default, which would make the output somewhat predictable, and puts the "latest" image at the top of the list. This would address use-cases such as; docker/for-linux#455 (comment)

Output of docker hub --version:

hub-tool --version

Docker Hub Tool v0.2.0, build 0edf43a
@thaJeztah thaJeztah added the enhancement New feature or request label Jan 6, 2021
@silvin-lubecki
Copy link
Collaborator

We should probably add that as an option if possible

We matched the options available on Hub:
Screen Shot 2021-01-06 at 14 44 38
So you only have updated and lexicographical orders available.
See the saas-mega code here: https://github.com/docker/saas-mega/blob/cc7f5d91d574d44943899c1cac3e593d9b1c18c8/services/repos-new/api/rest/repos/v2/repository.go#L192-L191
And the default is the hub one: if we don't specify any ordering it fallbacks to images_tag.last_updated DESC: https://github.com/docker/saas-mega/blob/680604f3b127f46e4081e2c340a68b199a56f5a2/services/repos-new/db/repos/v2/tag.go#L153
So it should be the last pushed first by default.

@silvin-lubecki
Copy link
Collaborator

Mention default sort order in "usage" output

Yes we need to add that to the help description 👍

@thaJeztah
Copy link
Member Author

if we don't specify any ordering it fallbacks to images_tag.last_updated DESC:

I suspect there's a bug somewhere (perhaps on Docker Hub's side?); look at this output (I removed some columns);

$ hub-tool tag ls nginx

TAG                           LAST UPDATE      LAST PUSHED    LAST PULLED       SIZE
nginx:latest                  3 weeks ago      3 weeks        About a minute    421.2MB
nginx:stable-alpine-perl      2 weeks ago      2 weeks        6 minutes         124.8MB
nginx:stable-alpine           2 weeks ago      2 weeks        4 minutes         64.99MB
nginx:mainline-alpine-perl    2 weeks ago      2 weeks        9 minutes         126.3MB
nginx:mainline-alpine         2 weeks ago      2 weeks        6 minutes         66.49MB
nginx:alpine-perl             2 weeks ago      2 weeks        9 minutes         126.3MB
nginx:alpine                  2 weeks ago      2 weeks        6 minutes         66.49MB
nginx:1.19.6-alpine-perl      2 weeks ago      2 weeks        9 minutes         126.3MB
nginx:1.19.6-alpine           2 weeks ago      2 weeks        6 minutes         66.49MB
nginx:1.19-alpine-perl        2 weeks ago      2 weeks        9 minutes         126.3MB
nginx:1.19-alpine             2 weeks ago      2 weeks        6 minutes         66.49MB
nginx:1.18.0-alpine-perl      2 weeks ago      2 weeks        6 minutes         124.8MB
nginx:1.18.0-alpine           2 weeks ago      2 weeks        4 minutes         64.99MB
nginx:1.18-alpine-perl        2 weeks ago      2 weeks        6 minutes         124.8MB
nginx:1.18-alpine             2 weeks ago      2 weeks        4 minutes         64.99MB
nginx:1-alpine-perl           2 weeks ago      2 weeks        9 minutes         126.3MB
nginx:1-alpine                2 weeks ago      2 weeks        6 minutes         66.49MB
nginx:perl                    3 weeks ago      3 weeks        About a minute    506.4MB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants