-
-
Save rdpanek/757ffae33246d322634725529fdf79d7 to your computer and use it in GitHub Desktop.
Get the list of images and tags for a Docker Hub user account.
This file contains hidden or 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 | |
# kubectl get deployments monitor -o json | jq '.spec.template.spec.containers[0].image' | |
# kubectl set image deployment/monitor monitor=rdpanek/monitor:develop-22ca149b | |
# set username and password | |
UNAME="" | |
UPASS="" | |
# ------- | |
set -e | |
echo | |
# aquire token | |
TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "'${UNAME}'", "password": "'${UPASS}'"}' https://hub.docker.com/v2/users/login/ | jq -r .token) | |
# get tags for repo | |
IMAGE_TAGS=$(curl -s -H "Authorization: JWT ${TOKEN}" https://hub.docker.com/v2/repositories/rdpanek/monitor/tags/?page_size=100 | jq -r '.results|.[0]|.name') | |
IMAGE='"rdpanek/monitor:'${IMAGE_TAGS}'"' | |
echo $IMAGE | |
KUBE_DEPLOYMENTS=$(kubectl get deployments monitor -o json | jq '.spec.template.spec.containers[0].image') | |
echo $KUBE_DEPLOYMENTS | |
if [ ${IMAGE} == $KUBE_DEPLOYMENTS ] ; then | |
echo "existuje ${IMAGE}" | |
else | |
echo "neexistuje ${IMAGE}" | |
echo $(kubectl set image deployment/monitor monitor=rdpanek/monitor:${IMAGE_TAGS}) | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment