update clean registry

Signed-off-by: Jess Frazelle <acidburn@github.com>
This commit is contained in:
Jess Frazelle 2018-12-28 19:10:00 -05:00
parent c70cf86b55
commit 8cd8c59cde
No known key found for this signature in database
GPG Key ID: 18F3685C0022BFF3

View File

@ -32,6 +32,7 @@ for repo in "${repos[@]}"; do
# get the latest index for the tag # get the latest index for the tag
current=$(gsutil cat "${BUCKET_PREFIX}/repositories/${repo}/_manifests/tags/${tag}/current/link" || true) current=$(gsutil cat "${BUCKET_PREFIX}/repositories/${repo}/_manifests/tags/${tag}/current/link" || true)
if [[ "$current" == "true" ]]; then if [[ "$current" == "true" ]]; then
# continue the loop since we cannot cat
continue continue
fi fi
# split on : since the link comes back as: # split on : since the link comes back as:
@ -39,6 +40,23 @@ for repo in "${repos[@]}"; do
ha=${current%:*} ha=${current%:*}
id=${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}" echo "repo: $repo | tag: $tag | current: ${ha}:${id}"
# get the shas # get the shas
@ -49,7 +67,8 @@ for repo in "${repos[@]}"; do
# shellcheck disable=SC2199 # shellcheck disable=SC2199
if [[ "${shas[@]}" != "" ]] && [[ ! -z "${shas[@]}" ]]; then 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 fi
done done
done done