Created
April 14, 2020 19:38
-
-
Save steinbrueckri/a10e4e7f3c33d369d1c4daf39c47a5d4 to your computer and use it in GitHub Desktop.
check_image_tag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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