Last active
April 2, 2024 18:49
-
-
Save prb112/838d8c2ae908b496f5d5480411a7d692 to your computer and use it in GitHub Desktop.
patches the imagstreams in the namespace so they are scheduled per imagestream-sets-schedule
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Updated Script to Fix scheduled = false or null | |
for NAMESPACE_IMAGESTREAM in $(oc get imagestreams -A -ojson | jq -r '.items[] | select(.spec.tags[]? | select(.from.kind != "ImageStreamTag" and (.importPolicy.scheduled == null or .importPolicy.scheduled == false))) | "\(.metadata.namespace),\(.metadata.name)"') | |
do | |
NAMESPACE=$(echo ${NAMESPACE_IMAGESTREAM} | awk -F',' '{print $1}') | |
IMAGESTREAM=$(echo ${NAMESPACE_IMAGESTREAM} | awk -F',' '{print $2}') | |
echo "Processing ${NAMESPACE} imagestream/${IMAGESTREAM}" | |
IDX=0 | |
for TAG in $(oc get imagestream -n ${NAMESPACE} ${IMAGESTREAM} -ojson | jq -r '.spec.tags[].name') | |
do | |
STATUS="$(oc patch -n ${NAMESPACE} imagestream/${IMAGESTREAM} -p '[{"op": "replace", "path": "/spec/tags/'${IDX}'/importPolicy/scheduled", "value":true}]' --type=json 2>&1 | grep 'is invalid')" | |
if [ ! -z "${STATUS}" ] | |
then | |
echo "FAILING: ${NAMESPACE},${IMAGESTREAM},${TAG}" | |
fi | |
(( IDX += 1 )) | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment