Skip to content

Instantly share code, notes, and snippets.

@steinbrueckri
Created April 14, 2020 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steinbrueckri/a10e4e7f3c33d369d1c4daf39c47a5d4 to your computer and use it in GitHub Desktop.
Save steinbrueckri/a10e4e7f3c33d369d1c4daf39c47a5d4 to your computer and use it in GitHub Desktop.
check_image_tag
#!/bin/bash
# NOTE: other solution can maybe ...
# gcloud container images list-tags eu.gcr.io/project_id/image_name
image=$1
if [[ ! $image =~ ^[eu\.]*gcr\.io\/.+\/.+:.+$ ]]; then
echo "[ERROR] bad parameter, expect something like 'eu.gcr.io/project/image:version'"
exit 255
fi
# docker manifest inspect is only supported on a Docker cli with experimental cli features enabled
export DOCKER_CLI_EXPERIMENTAL="enabled"
docker manifest inspect $image > /dev/null 2>&1
RESULT=$?
if [ $RESULT -eq 0 ]; then
echo "[ERROR] Image tag already exist ... 😞"
exit 255
else
echo "[INFO] Image tag doesn't exist go ahead ... 😚"
exit 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment