diff --git a/clean-registry/clean-registry b/clean-registry/clean-registry index aada59c..26b44fe 100755 --- a/clean-registry/clean-registry +++ b/clean-registry/clean-registry @@ -32,6 +32,7 @@ for repo in "${repos[@]}"; do # get the latest index for the tag current=$(gsutil cat "${BUCKET_PREFIX}/repositories/${repo}/_manifests/tags/${tag}/current/link" || true) if [[ "$current" == "true" ]]; then + # continue the loop since we cannot cat continue fi # split on : since the link comes back as: @@ -39,6 +40,23 @@ for repo in "${repos[@]}"; do ha=${current%:*} id=${current#*:} + # get the manifest + manifest=$(gsutil cat "${BUCKET_PREFIX}/blobs/sha256/${id:0:2}/${id}/data" || true) + if [[ "$manifest" == "true" ]]; then + # continue the loop since we cannot cat + continue + fi + manifest_media_type=$(echo ${manifest} | jq -r '.mediaType') + echo "media-type: $manifest_media_type" + + + if [ "${manifest_media_type}" == "application/vnd.docker.distribution.manifest.list.v2+json" ] ; then + # we have a manifest list and fetch the referenced manifests + additional_manifests=( $(echo ${manifest} | jq -r '.["manifests"] | .[].digest' | cut -d: -f2) ) + + echo "additional_manifests: ${additional_manifests[@]}" + fi + echo "repo: $repo | tag: $tag | current: ${ha}:${id}" # get the shas @@ -49,7 +67,8 @@ for repo in "${repos[@]}"; do # shellcheck disable=SC2199 if [[ "${shas[@]}" != "" ]] && [[ ! -z "${shas[@]}" ]]; then - parallel -j"${JOBS}" reg rm "${REPO_URL}/${repo}@${ha}:{1}" ::: "${shas[@]}" || true + echo "[to be removed]: ${shas[@]}" + #parallel -j"${JOBS}" reg rm "${REPO_URL}/${repo}@${ha}:{1}" ::: "${shas[@]}" || true fi done done