Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HWORKS-679] Delete project docker images from registry with tags #1019

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions templates/default/dockerImage.sh.erb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@ elif [ "$1" == "gc" ] ; then
docker exec registry bin/registry garbage-collect /etc/docker/registry/config.yml -m
docker container restart registry

elif [ "$1" == "delete-with-tags" ] ; then
REPO_NAME=$2
TAGS_STR=$3
read -ra TAGS <<< $(echo "$TAGS_STR" | tr ',' ' ')
for TAG in "${TAGS[@]}"; do
# get the digest
DIGEST=$(curl -g -k -sSL -I \
-H "Accept: application/vnd.docker.distribution.manifest.v2+json" \
"https://$REGISTRY_URL/v2/$REPO_NAME/manifests/$TAG" | awk '$1 == "docker-content-digest:" { print $2 }' | tr -d $'\r')
# delete the manifest
curl -g -k -v -sSL -X DELETE "https://${REGISTRY_URL}/v2/$REPO_NAME/manifests/${DIGEST}"
done
<% else -%>

elif [ "$1" == "delete-acr" ] ; then
Expand Down