I'm currently using this to check if an image is available on gcr.io.
tags_json=$(curl "https://gcr.io/v2/${repo}/${image}/tags/list" 2>/dev/null)
tags_found="$(echo "${tags_json}" | jq ".tags | indices([\"${version}\"]) | any")"
This is unfortunate because the version of jq
that supports indices
is rather new compared to some LTS distros out there...
I can get away with this for docker.io, which works with older versions of jq
:
tags_json=$(curl "https://registry.hub.docker.com/v2/repositories/${repo}/${image}/tags/${version}/" 2>/dev/null)
tags_found="$(echo "${tags_json}" | jq ".v2?")"
Is there a better way to do this? I've seen mentions that GCR supports some extensions on top of the typical docker registry protocol. Anything that I can use here.