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

Adds "docker-list-tags" command to list tags #716

Merged
merged 7 commits into from
Feb 25, 2020

Conversation

zhill
Copy link
Contributor

Adds new command docker-list-tags to list the tags in a docker V2 registry's repository.

Discussion in #276. I expect some changes will be needed in the naming so opening this early to facilitate discussion.

If there is any additional testing or docs required I will gladly update.

Copy link
Contributor

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This is pretty good.

cmd/skopeo/tags.go Outdated Show resolved Hide resolved
cmd/skopeo/tags.go Outdated Show resolved Hide resolved
cmd/skopeo/tags.go Outdated Show resolved Hide resolved
cmd/skopeo/tags.go Outdated Show resolved Hide resolved
cmd/skopeo/tags.go Outdated Show resolved Hide resolved
cmd/skopeo/tags_test.go Outdated Show resolved Hide resolved
docs/skopeo-docker-list-tags.1.md Outdated Show resolved Hide resolved
docs/skopeo.1.md Outdated Show resolved Hide resolved
docs/skopeo.1.md Outdated Show resolved Hide resolved
docs/skopeo-docker-list-tags.1.md Outdated Show resolved Hide resolved
Copy link
Contributor Author

Thanks! This is pretty good.

Thanks for the super fast response. Will review and make changes as recommended.

cmd/skopeo/tags.go Outdated Show resolved Hide resolved
cmd/skopeo/tags.go Outdated Show resolved Hide resolved
cmd/skopeo/tags_test.go Outdated Show resolved Hide resolved
cmd/skopeo/tags_test.go Outdated Show resolved Hide resolved
@rhatdan
Copy link
Member

rhatdan commented Sep 11, 2019

Need bash completions.

Copy link
Contributor Author

@rhatdan yes, as discussed in the issue, I don't really care about the name. The contention seems to be with others' opinions on naming scope. I'm happy to use 'list-tags', 'list-registry-tags', 'list-repository-tags', or whatever as long as its descriptive of what the command does.

How about 'list-repository-tags'? @mtrmac is that ok? I'd prefer not to make the change more than once, so if we can get agreement here first then I'll change it.

Thanks again. I very much appreciate the prompt reviews and suggestions.

@mtrmac
Copy link
Contributor

mtrmac commented Sep 11, 2019

PLEASE just call this list-tags, do not add docker-. If this only works currently with docker API, then just document it. Lets not make the skopeo CLI any more complicated then it already is.

Well, the thing is: Are you willing to bet that no new protocols and server kinds which could use a “list tags” operation will be added during the lifetime of Skopeo? Considering the long discussions about file-at-a-time sync, I’m really not.

And if there are going to be new protocols and server kinds, then the CLI will need to accommodate them. If we don’t add the protocol anywhere in the CLI now, we’ll end up requiring an extra option, or a non-trivial command name, in the future, for the new protocols/server kinds. If skopeo list-tags were created now for docker/distribution, any future protocol would have to use skopeo list-tags --fedora or skopeo list-fedora-tags in the future, no matter how prevalent the future protocol became = no matter how confusing it were to have the shorter command not apply to the prevalent protocol.

Being explicit about the protocol now allows us to symmetrically handle future protocols without expressing a preference (who knows, the next one may well turn out to be a vendor-named one as well).

Also, note that this command is pretty likely to be primarily used in scripts / automation. So, in a sense, the user-friendliness does not matter nearly as much as stable behavior. (So, I’m absolutely unwilling to do, or design this to eventually require, heuristic guessing about the protocol in Skopeo — we can’t know that it will be possible to safely guess that with future unknown protocols anyway.)

(And, as far as user-friendliness goes, with completions, list-* are all exactly as easy to type.)

If Podman wants to provide easier-to-type code with more heuristics, it can of course do that; looking at how the semantics of the currently-existing heuristics in there turned out to be unclear and inconsistent, I wouldn’t recommend it but I can’t and won’t try to stop it.)


How about 'list-repository-tags'

I’m not happy about that name but I guess I could settle on that if @rhatdan can; it’s still very generic, but at least I can console myself with the thought that calling image servers “registries” does not make any semantic sense, so at least there’s some chance that the new protocol won’t use this jargon and we won’t collide.

@rhatdan
Copy link
Member

rhatdan commented Sep 12, 2019

I am not tighing the list-tags to only container-registries. If other containers stores supported tags, then list-tags should show there as well.

I could see skopeo list-tags listing tags for an images stored in container-storage and docker-daemon. Perhaps.

The question you raise is do I see some time in the future where list-tags would talk about something totally different on a a different type of image store, and my answer would be no.

@mtrmac
Copy link
Contributor

mtrmac commented Sep 12, 2019

I am not tighing the list-tags to only container-registries. If other containers stores supported tags, then list-tags should show there as well.

I could see skopeo list-tags listing tags for an images stored in container-storage and docker-daemon. Perhaps.

Then the CLI must be explicit about which “container store” the user is asking about.

@rhatdan
Copy link
Member

rhatdan commented Sep 12, 2019

Yes I agree, the container store needs to be specified.

Copy link
Contributor Author

Yes I agree, the container store needs to be specified.

As in: list-tags docker://host.io:port/repo and later list-tags container-storage://path?

I'm fixing up integration tests now, and will get the updates pushed here shortly

@mtrmac
Copy link
Contributor

mtrmac commented Sep 13, 2019

Yes I agree, the container store needs to be specified.

As in: list-tags docker://host.io:port/repo and later list-tags container-storage://path?

docker://host.io:port/repo is defined to be the same as docker://host.io:port/repo:latest; and use of that syntax implies that other image references (like dir:path) can probably be accepted as well.

So, if the semantics of the parameter here is different, I think it should use a different syntax, maybe list-docker tags or list-tags --docker; of the two, the former is easier to use with shell completions.

@rhatdan
Copy link
Member

rhatdan commented Sep 13, 2019

Why is the additional option needed?
Isn't this enough for the tool to interpret what the user wants?

skopeo list-tags  docker://host.io:port/repo
skopeo list-tags container-storage

@rhatdan
Copy link
Member

rhatdan commented Oct 31, 2019

@zhill @mtrmac @vrothberg What is the state of this PR?

Copy link
Contributor Author

I have pushed updates and am ready for more feedback re:naming. I had let it sit for a while b/c my cycles to operate on feedback were limited. I'd like to get a clear direction on what to name the command and how params should work if not the way it is currently implemented. I can then rebase and get the PR ready to merge

@rhatdan
Copy link
Member

rhatdan commented Oct 31, 2019

@giuseppe @mtrmac Do we need to add this as a topic for the F2F?

docs/skopeo-list-repository-tags.1.md Outdated Show resolved Hide resolved
completions/bash/skopeo Outdated Show resolved Hide resolved
cmd/skopeo/tags_test.go Outdated Show resolved Hide resolved
docs/skopeo.1.md Outdated Show resolved Hide resolved
@mtrmac
Copy link
Contributor

mtrmac commented Oct 31, 2019

@rhatdan From my POV this is now mostly up to you to state goals and/or ask ask for a design, and if both, to make them consistent with each other. E.g. #716 (comment) asks a question that I think answered in the immediately preceding comment already.

Or maybe just say that you are fine with list-repository-tags $docker_reference as it is now.

Copy link
Contributor Author

Thanks, I'll get the updates done ASAP, but cycles are scarce until the end of the week. I appreciate your time reviewing and helping move this forward.

force-pushed the tag_list branch 3 times, most recently from af52650 to 07ee608 Compare December 13, 2019 17:33
Copy link
Contributor

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I guess the discussion period was long enough. Last chance to object to skopeo list-repository-tags $docker-reference.

(@vrothberg WDYT?)

These two are still outstanding:
#716 (comment)
#716 (comment)
that, and the mis-placed Error marshalling json output error are the only things I care somewhat strongly enough; the rest are very low-priority and non-blocking.

cmd/skopeo/tags.go Outdated Show resolved Hide resolved
cmd/skopeo/tags.go Outdated Show resolved Hide resolved
cmd/skopeo/tags.go Outdated Show resolved Hide resolved
cmd/skopeo/tags.go Outdated Show resolved Hide resolved
cmd/skopeo/tags_test.go Outdated Show resolved Hide resolved
integration/list_repository_tags_test.go Outdated Show resolved Hide resolved
Copy link
Contributor Author

Thanks for the review (again). I'll get updates in today. I've been very cycle constrained lately but have time to focus on this and get it over the finish line. Thanks!

@vrothberg
Copy link
Member

(@vrothberg WDYT?)

Thanks for the ping! I will have a look at this PR tomorrow morning with a fresh pair of eyes.

@vrothberg
Copy link
Member

@zhill, can you also rebase the PR so we can merge it more easily?

Copy link
Contributor Author

Yes, working on that now. I'll rebase and squash it down to a single commit now that we're close (didn't want to lose history previously). Thanks again folks! I know its been a long PR due to my intermittent availability, the patience is appreciated.

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple of nits mainly related to naming

cmd/skopeo/tags.go Outdated Show resolved Hide resolved
}

return cli.Command{
Name: "list-repository-tags",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a preference to name the command list-tags and require the input to follow transport:.... convention. Maybe we want to support something similar for other transports in the future. Embedding "repository" into the command name and making it docker-transport only would close that door in some way.

The code wouldn't need to change much as we can error out for other transports for now. But I am late to the game and may miss context.

@mtrmac WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My worry is that it’s not certain that things can be generalized for all transports.

It’s already a bit conceptually dubious with docker://, where docker://foo means “the docker://foo:latest image”, not “the docker://foo repository”.

In general, the whole idea of “repository” and “tag” does generalize at all well — compare #716 (comment) (besides syntax problems) suggesting that the whole local storage is a single “repository” and the hostname/[ns/…/]repo:tag value is a “tag”: it’s not at all an unreasonable position to take, but it makes the concept of “tag” meaningless and rules out the possibility of any transport-agnostic consumer of the output of this command.

(Compare #682 (comment) and #524 (comment) dealing with registry names, all of this ends up with several docker:// syntaxes with different meanings and rules.)

My default heuristic in such cases is to intentionally make the command extremely specific and limited; if we ever generalize it, we can easily add a general command, and maintain the specific one as a trivial shim. Going the other way from a prematurely-general interface to a specific one, or changing the prematurely-general interface to be general in a different way, requires better ability to forecast the future.


But, overall, sure:

  • list-tags docker://… and list-docker-tags … are equivalent in the information that is being provided
  • The “docker://repo means :latest” quibble is pedantic but does not make a difference in practice (apart from our ability to cleanly reject tagged/digested input, but this PR does not reject it anyway)
  • list-repository-tags … is already an specifics-losing compromise that I’m not at all strongly attached to

As long as the input is clearly namespaced and therefore unambiguous (i.e. not skopeo list heuristically-guess-what-I-mean), I think any of the three options works, and we’ve taken 4 months to decide and it’s not going to get any easier with 4 more months.

@vrothberg So, to settle this once for all, skopeo list-tags docker://…?

cmd/skopeo/tags.go Outdated Show resolved Hide resolved
cmd/skopeo/tags.go Outdated Show resolved Hide resolved
docs/skopeo-list-repository-tags.1.md Outdated Show resolved Hide resolved
docs/skopeo-list-repository-tags.1.md Outdated Show resolved Hide resolved
docs/skopeo.1.md Outdated Show resolved Hide resolved
Copy link
Contributor Author

I've made the changes and rebased along with squashing to a single commit for easier review and merge.

cmd/skopeo/tags.go Outdated Show resolved Hide resolved
cmd/skopeo/tags.go Outdated Show resolved Hide resolved
cmd/skopeo/tags.go Outdated Show resolved Hide resolved
}

return cli.Command{
Name: "list-repository-tags",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My worry is that it’s not certain that things can be generalized for all transports.

It’s already a bit conceptually dubious with docker://, where docker://foo means “the docker://foo:latest image”, not “the docker://foo repository”.

In general, the whole idea of “repository” and “tag” does generalize at all well — compare #716 (comment) (besides syntax problems) suggesting that the whole local storage is a single “repository” and the hostname/[ns/…/]repo:tag value is a “tag”: it’s not at all an unreasonable position to take, but it makes the concept of “tag” meaningless and rules out the possibility of any transport-agnostic consumer of the output of this command.

(Compare #682 (comment) and #524 (comment) dealing with registry names, all of this ends up with several docker:// syntaxes with different meanings and rules.)

My default heuristic in such cases is to intentionally make the command extremely specific and limited; if we ever generalize it, we can easily add a general command, and maintain the specific one as a trivial shim. Going the other way from a prematurely-general interface to a specific one, or changing the prematurely-general interface to be general in a different way, requires better ability to forecast the future.


But, overall, sure:

  • list-tags docker://… and list-docker-tags … are equivalent in the information that is being provided
  • The “docker://repo means :latest” quibble is pedantic but does not make a difference in practice (apart from our ability to cleanly reject tagged/digested input, but this PR does not reject it anyway)
  • list-repository-tags … is already an specifics-losing compromise that I’m not at all strongly attached to

As long as the input is clearly namespaced and therefore unambiguous (i.e. not skopeo list heuristically-guess-what-I-mean), I think any of the three options works, and we’ve taken 4 months to decide and it’s not going to get any easier with 4 more months.

@vrothberg So, to settle this once for all, skopeo list-tags docker://…?

Copy link
Contributor Author

Once the naming decision is made I'll update with a new commit for that change. Thanks @mtrmac and @vrothberg !

@vrothberg
Copy link
Member

@vrothberg So, to settle this once for all, skopeo list-tags docker://…?

Ay! I am in favor of that. Thanks!

@rhatdan
Copy link
Member

rhatdan commented Jan 15, 2020

I am also.

Copy link
Contributor

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! A few comments after a quick skim, I’ll do a complete review later.

cmd/skopeo/list_tags.go Outdated Show resolved Hide resolved
cmd/skopeo/list_tags.go Outdated Show resolved Hide resolved
cmd/skopeo/list_tags.go Outdated Show resolved Hide resolved
cmd/skopeo/list_tags_test.go Outdated Show resolved Hide resolved
cmd/skopeo/list_tags_test.go Show resolved Hide resolved
Copy link
Contributor

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A full review now.

integration/list_tags_test.go Outdated Show resolved Hide resolved
docs/skopeo-list-tags.1.md Outdated Show resolved Hide resolved
cmd/skopeo/list_tags.go Outdated Show resolved Hide resolved
cmd/skopeo/list_tags.go Outdated Show resolved Hide resolved
cmd/skopeo/list_tags.go Outdated Show resolved Hide resolved
Copy link
Contributor Author

apologies for going dark, some other stuff has come up but I'll get to this ASAP. I don't see any issues with making the suggested changes and I'll get those in as soon as I can but may be few more days.

containers#276

Example: skopeo list-tags docker://docker.io/library/centos
Returns response:
{
  Repository": "docker.io/library/centos",
  "Tags": [
    "6",
    "7",
    ...
  ]
}

Signed-off-by: Zach Hill <[email protected]>
Signed-off-by: Zach Hill <[email protected]>
…t already tested by the upstream container/images repo or local unit tests

Signed-off-by: Zach Hill <[email protected]>
Copy link
Contributor Author

I'll update the branch to latest, but I think I resolved all the comments. Note that I did remove the integration test since there wasn't one for the inspect command and such a test was dependent on an external registry and didn't really provide a lot of value that was't covered by the unit tests. I can add it back in if you feel it provides real test value moving forward.

Copy link
Contributor

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Sorry it took so long.

Note that I did remove the integration test since there wasn't one for the inspect command and such a test was dependent on an external registry and didn't really provide a lot of value that was't covered by the unit tests. I can add it back in if you feel it provides real test value moving forward.

If you don’t think a test would be useful enough to keep this code working that it’s worth the trouble, sure, up to you.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants