Skip to content

Instantly share code, notes, and snippets.

@cdecl
Last active August 23, 2021 23:16
Show Gist options
  • Save cdecl/5363d5095ce90f91413436d37bb2b616 to your computer and use it in GitHub Desktop.
Save cdecl/5363d5095ce90f91413436d37bb2b616 to your computer and use it in GitHub Desktop.
#!/bin/bash
URI="$1"
NAME="$2"
TAG="$3"
if [[ -z "$URI" ]]; then
echo "Usage: $0 <URI> <NAME> [<TAG>]"
exit -1
fi
if [[ -z "$NAME" ]]; then
echo "Usage: $0 $URI <NAME> [<TAG>]"
echo
curl -sS $URI/v2/_catalog | jq -r '.repositories[]'
echo
exit -1
fi
if [[ -z "$TAG" ]]; then
echo "Usage: $0 $URI $NAME [<TAG>]"
echo
curl -sS $URI/v2/$NAME/tags/list | jq -r '.tags[]'
echo
exit -1
fi
MANIFESTS=$(curl -sS -I -H "Accept: application/vnd.docker.distribution.manifest.v2+json" \
$URI/v2/$NAME/manifests/$TAG | grep -i Docker-Content-Digest | awk '{print $2}')
if [[ -z "$MANIFESTS" ]]; then
echo "No manifest found for $NAME:$TAG"
exit -1
fi
echo $MANIFESTS
echo
echo curl -sS -XDELETE $URI/v2/$NAME/manifests/$MANIFESTS
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment