Skip to content

Commit

Permalink
Merge pull request #4 from m800-limited/master
Browse files Browse the repository at this point in the history
fix: failure when multiple repo is found for same manifest
  • Loading branch information
mortensteenrasmussen authored Aug 6, 2017
2 parents 83d746a + c7c2336 commit 32411a3
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions docker-registry-cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,26 @@ if [ ${TOTAL_COUNT} -gt 0 ]; then
fi

for manifest in ${MANIFESTS_WITHOUT_TAGS}; do
repo=$(find . | grep "_manifests/revisions/sha256/${manifest}/link" | awk -F "_manifest" '{print $(NF-1)}' | sed 's#^./\(.*\)/#\1#')

if [ ${DRY_RUN} ]; then
echo "Would have run curl -fsS ${CURL_INSECURE_ARG} -X DELETE ${REGISTRY_URL}/v2/${repo}/manifests/sha256:${manifest} > /dev/null"
else
curl -fsS ${CURL_INSECURE_ARG} -X DELETE ${REGISTRY_URL}/v2/${repo}/manifests/sha256:${manifest} > /dev/null
exit_code=$?

if [ ${exit_code} -eq 0 ]; then
((CURRENT_COUNT++))
repos=$(find . | grep "_manifests/revisions/sha256/${manifest}/link" | awk -F "_manifest" '{print $(NF-1)}' | sed 's#^./\(.*\)/#\1#')

for repo in repos; do
if [ ${DRY_RUN} ]; then
echo "Would have run curl -fsS ${CURL_INSECURE_ARG} -X DELETE ${REGISTRY_URL}/v2/${repo}/manifests/sha256:${manifest} > /dev/null"
else
((FAILED_COUNT++))
curl -fsS ${CURL_INSECURE_ARG} -X DELETE ${REGISTRY_URL}/v2/${repo}/manifests/sha256:${manifest} > /dev/null
exit_code=$?

if [ ${exit_code} -eq 0 ]; then
((CURRENT_COUNT++))
else
((FAILED_COUNT++))
fi
fi
fi
done
done

DF_AFTER=$(df -Ph . | awk 'END{print}')

if [ ${DRY_RUN} ]; then
echo "DRY_RUN over"
else
Expand Down

0 comments on commit 32411a3

Please sign in to comment.