[Question] how to get all tags for a certain image version
tcurdt opened this issue · comments
Question
I want to get a list of all tags for certain image.
This is what I tried:
regctl image inspect ghcr.io/tcurdt/foo:something
regctl tag ls ghcr.io/tcurdt/foo:something
And it seems like regctl tag ls ghcr.io/tcurdt/foo:something
almost does what I want - except that it gives the same output as regctl tag ls ghcr.io/tcurdt/foo
. So it's always ALL tags. Not for the specific image version.
Is this possible with the current version of regclient
?
I haven't found it yet.
Context: I have foo:something
also tagged as foo:build-1234
and would like to extract the build-1234
part.
Version
$ regctl version
VCSTag: (devel)
VCSRef: unknown
VCSCommit: unknown
VCSState: unknown
VCSDate: unknown
Platform: linux/arm64
GoVer: go1.21.5
GoCompiler: gc
$ ls -la /nix/store/ | grep regctl
dr-xr-xr-x 3 root root 4096 Jan 1 1970 hq3dm22ks45g1sf2aplzma05h3c7cm4n-regclient-0.5.6-regctl
Environment
This is on nixOS on arm
Anything else
The data for this doesn't come directly from any OCI APIs yet, so it would end up being a shell script to loop over every tag. This will be slow to poll the registry for each digest, so anything you can do to limit the possible tags to check the better.
$ digest="$(regctl image digest ghcr.io/regclient/regctl:latest)"
$ for tag in $(regctl tag ls ghcr.io/regclient/regctl --include 'v.*'); do
> if [ "$digest" = "$(regctl image digest ghcr.io/regclient/regctl:${tag})" ]; then
> echo "match $tag"
> fi
> done
match v0
match v0.5
match v0.5.6
That works - but OMG. I am curious what constraint has caused that API design of the OCI.
What I have done so far is to include the information also into the image meta data.
So it's just one call with regctl image inspect ghcr.io/foo/bar:latest
and picking the info.
I am not sure which approach I prefer yet. Both feel ugly.
Thank you so much for you help.
That works - but OMG. I am curious what constraint has caused that API design of the OCI.
The tag listing API only lists the tags, and not other metadata about those tags, like their digest:
https://github.com/opencontainers/distribution-spec/blob/v1.0.1/spec.md#content-discovery
There is a desire to make something that provides more data to the users, e.g. full descriptors rather than just the tag string. Some of that is seen in opencontainers/distribution-spec#222
I'm closing this for now since it's not a feature of regclient and won't be until changes happen upstream in OCI that would also need to be adopted by registries, but feel free to keep the conversation going here.