Skip to content

Commit

Permalink
contrib: simplify check-docker-images script
Browse files Browse the repository at this point in the history
The curl URL fails if the sha256 is no longer part of the tag. Running
with `docker buildx imagetools inspect` it is possible to verify if an
image digest exists regardless even if no longer belongs to a tag.

Signed-off-by: André Martins <andre@cilium.io>
  • Loading branch information
aanm committed May 28, 2021
1 parent f3c90b8 commit 8e1ef9c
Showing 1 changed file with 13 additions and 34 deletions.
47 changes: 13 additions & 34 deletions contrib/release/check-docker-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
cilium_tag="${1}"
org="cilium"

external_dependencies_docker=(
"envoyproxy/envoy:${HUBBLE_PROXY_VERSION}" \
)

external_dependencies_quay=(
"coreos/etcd:${ETCD_VERSION}" \
external_dependencies=(
"docker.io/envoyproxy/envoy:${HUBBLE_PROXY_VERSION}" \
"quay.io/coreos/etcd:${ETCD_VERSION}" \
)

internal_dependencies=(
Expand All @@ -30,56 +27,38 @@ cilium_images=(\
"operator-generic" \
)

docker_tag_exists(){
local repo="${1}"
local tag="${2}"
curl --silent -f -lSL "https://index.docker.io/v1/repositories/${repo}/tags/${tag}" &> /dev/null
image_tag_exists(){
local image="${1}"
docker buildx imagetools inspect "${image}" &> /dev/null
}

quay_tag_exists(){
local repo="${1}"
local tag="${2}"
curl --silent -f -lSL "https://quay.io/api/v1/repository/${repo}/tag/${tag}/images" &> /dev/null
}

for image in "${external_dependencies_docker[@]}" ; do
image_tag=${image#*:}
image_name=${image%":$image_tag"}
if ! docker_tag_exists "${image_name}" "${image_tag}" ; then
echo "docker.io/${image} does not exist!"
not_found=true
fi
done

for image in "${external_dependencies_quay[@]}" ; do
image_tag=${image#*:}
image_name=${image%":$image_tag"}
if ! quay_tag_exists "${image_name}" "${image_tag}" ; then
echo "quay.io/${image} does not exist!"
for image in "${external_dependencies[@]}" ; do
if ! image_tag_exists "${image}" ; then
echo "${image} does not exist!"
not_found=true
fi
done

for image in "${internal_dependencies[@]}" ; do
image_tag=${image#*:}
image_name=${org}/${image%":$image_tag"}
if ! docker_tag_exists "${image_name}" "${image_tag}" ; then
if ! image_tag_exists "docker.io/${image_name}:${image_tag}" ; then
echo "docker.io/${image_name}:${image_tag} does not exist!"
not_found=true
fi
if ! quay_tag_exists "${image_name}" "${image_tag}" ; then
if ! image_tag_exists "quay.io/${image_name}:${image_tag}" ; then
echo "quay.io/${image_name}:${image_tag} does not exist!"
not_found=true
fi
done

for image in "${cilium_images[@]}"; do
image_name="${org}/${image}"
if ! docker_tag_exists "${image_name}" "${cilium_tag}" ; then
if ! image_tag_exists "docker.io/${image_name}:${cilium_tag}" ; then
echo "docker.io/${image_name}:${cilium_tag} does not exist!"
not_found=true
fi
if ! quay_tag_exists "${image_name}" "${cilium_tag}" ; then
if ! image_tag_exists "quay.io/${image_name}:${cilium_tag}" ; then
echo "quay.io/${image_name}:${cilium_tag} does not exist!"
not_found=true
fi
Expand Down

0 comments on commit 8e1ef9c

Please sign in to comment.