-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_acr_cleanup.sh
27 lines (24 loc) · 1000 Bytes
/
run_acr_cleanup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash
if [[ -z "${SP_USER}" ]]; then
SP_USER=$(cat ${AZURE_CREDENTIALS} | jq -r '.id')
fi
if [[ -z "${SP_SECRET}" ]]; then
SP_SECRET=$(cat ${AZURE_CREDENTIALS} | jq -r '.password')
fi
# Exit script if az login is unsuccessful.
# radix-acr-cleanup does not work when login is unsuccesful.
# In some situation, e.g. when radix-acr-cleanup is scheduled to run on a newly created node,
# the network is not ready and az login cannot connect to login.microsoftonline.com.
az login --service-principal -u ${SP_USER} -p ${SP_SECRET} --tenant ${TENANT} || exit
./radix-acr-cleanup \
--period=${PERIOD} \
--registry=${REGISTRY} \
--cluster-type=${CLUSTER_TYPE} \
--active-cluster-name=${ACTIVE_CLUSTER_NAME} \
--delete-untagged=${DELETE_UNTAGGED} \
--retain-latest-untagged=${RETAIN_LATEST_UNTAGGED} \
--perform-delete=${PERFORM_DELETE} \
--cleanup-days="${CLEANUP_DAYS}" \
--cleanup-start="${CLEANUP_START}" \
--cleanup-end="${CLEANUP_END}" \
--whitelisted="${WHITELISTED}"