Skip to content
Snippets Groups Projects
Commit 2e90b1de authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

cleanup for node images

parent 887664cc
No related branches found
No related tags found
2 merge requests!1973Development,!1968Resolve "Update Laravel to 9.x"
...@@ -41,6 +41,7 @@ nginx: ...@@ -41,6 +41,7 @@ nginx:
variables: variables:
FPM_REPOSITORY_ID: 418 FPM_REPOSITORY_ID: 418
NGINX_REPOSITORY_ID: 416 NGINX_REPOSITORY_ID: 416
NODE_REPOSITORY_ID: 416
KEEP_N: 9 # Trim to the latest 9 revisions as the 10th will be deleted in the next stage KEEP_N: 9 # Trim to the latest 9 revisions as the 10th will be deleted in the next stage
before_script: before_script:
- chmod go-r $KUBECONFIG - chmod go-r $KUBECONFIG
......
...@@ -68,6 +68,39 @@ done ...@@ -68,6 +68,39 @@ done
echo "Got ${#existing_tags_nginx[@]} tags." echo "Got ${#existing_tags_nginx[@]} tags."
echo "" echo ""
# Get All existing tags for the node repo
echo "Fetching existing node tags..."
declare -A existing_tags_node
get_tags_url=$CI_API_V4_URL/projects/$CI_PROJECT_ID/registry/repositories/$NODE_REPOSITORY_ID/tags
page=1
counter=1
while [[ "$page" != "" && $counter -le 50 ]]
do
tags=$(curl --fail --silent -D headers.txt "${get_tags_url}?page=$page" | jq -r ".[][\"name\"]")
for tag in $tags
do
if [[ $tag = ${DOCKER_IMAGE_TAG_PREFIX}-* && "$tag" != $DOCKER_IMAGE_TAG_PREFIX && $tag != $DOCKER_NGINX_IMAGE_TAG ]]
then
existing_tags_node[$tag]=1
fi
done
while read header
do
header=$(echo $header | sed -r 's/\s+//g')
key=$(echo $header | cut -d':' -f1 )
value=$(echo $header | cut -d':' -f2 )
case "$key" in
x-next-page)
page="$value"
sleep 1
;;
esac
done < headers.txt
counter=$((counter + 1))
done
echo "Got ${#existing_tags_node[@]} tags."
echo ""
# Get List of existing revisions # Get List of existing revisions
echo "Fetching Tags from helm revision history to not be deleted..." echo "Fetching Tags from helm revision history to not be deleted..."
declare -A revision_tags_fpm declare -A revision_tags_fpm
...@@ -109,4 +142,13 @@ do ...@@ -109,4 +142,13 @@ do
curl --fail --silent -X DELETE -H "JOB-TOKEN: $CI_JOB_TOKEN" "$CI_API_V4_URL/projects/$CI_PROJECT_ID/registry/repositories/$NGINX_REPOSITORY_ID/tags/$nginx_tag" curl --fail --silent -X DELETE -H "JOB-TOKEN: $CI_JOB_TOKEN" "$CI_API_V4_URL/projects/$CI_PROJECT_ID/registry/repositories/$NGINX_REPOSITORY_ID/tags/$nginx_tag"
echo "" echo ""
fi fi
done done
\ No newline at end of file
# Delete Node Tags
echo "Deleting unused NGINX Tags..."
for node_tag in ${!existing_tags_node[@]}
do
echo $node_tag
curl --fail --silent -X DELETE -H "JOB-TOKEN: $CI_JOB_TOKEN" "$CI_API_V4_URL/projects/$CI_PROJECT_ID/registry/repositories/$NODE_REPOSITORY_ID/tags/$node_tag"
echo ""
done
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment