Skip to content

Commit

Permalink
Add loops to ensure Subscription UID and InstallPlan are not empty
Browse files Browse the repository at this point in the history
  • Loading branch information
KhizerJaan authored and karl-johan-grahn committed Jul 11, 2024
1 parent 7f7a574 commit 2e76dab
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,16 @@ spec:
- -c
- |
export HOME=/tmp/approver
echo
echo "Get Subscription (${SUBSCRIPTION}) UID"
subscriptionUID=$(oc get subscriptions.operators.coreos.com --field-selector metadata.name=${SUBSCRIPTION} -o=jsonpath="{.items[0].metadata.uid}")
subscriptionUID=""
while [ -z "${subscriptionUID}" ]; do
echo "Get Subscription (${SUBSCRIPTION}) UID"
subscriptionUID=$(oc get subscriptions.operators.coreos.com --field-selector metadata.name=${SUBSCRIPTION} -o=jsonpath="{.items[0].metadata.uid}")
if [ -z "${subscriptionUID}" ]; then
echo "Subscription UID not found, retrying in 5 seconds..."
sleep 5
fi
done
echo "Subscription (${SUBSCRIPTION}) UID: ${subscriptionUID}"
if [ ! -z "subscriptionUID" ]; then
# this complicated go-template finds an InstallPlan where both the .spec.clusterServiceVersionNames contains the expected CSV
Expand Down Expand Up @@ -57,7 +63,15 @@ spec:
echo
echo "Get InstallPlan for CSV (${SUBSCRIPTION_CSV}) with Subscription (${SUBSCRIPTION_CSV}) (${subscriptionUID}) owner"
installPlan=$(oc get installplan -o=go-template="${installPlanGoTemplate}")
installPlan=""
while [ -z "${installPlan}" ]; do
echo "Get InstallPlan for CSV (${SUBSCRIPTION_CSV}) with Subscription (${SUBSCRIPTION_CSV}) (${subscriptionUID}) owner"
installPlan=$(oc get installplan -o=go-template="${installPlanGoTemplate}")
if [ -z "${installPlan}" ]; then
echo "InstallPlan not found, retrying in 5 seconds..."
sleep 5
fi
done
echo "InstallPlan for CSV (${SUBSCRIPTION_CSV}) with Subscription (${SUBSCRIPTION_CSV}) (${subscriptionUID}) owner: ${installPlan}"
if [ ! -z "${installPlan}" ]; then
echo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,15 @@ spec:
- |
export HOME=/tmp/approver
echo
echo "Get Subscription (${SUBSCRIPTION}) UID"
subscriptionUID=$(oc get subscriptions.operators.coreos.com --field-selector metadata.name=${SUBSCRIPTION} -o=jsonpath="{.items[0].metadata.uid}")
subscriptionUID=""
while [ -z "${subscriptionUID}" ]; do
echo "Get Subscription (${SUBSCRIPTION}) UID"
subscriptionUID=$(oc get subscriptions.operators.coreos.com --field-selector metadata.name=${SUBSCRIPTION} -o=jsonpath="{.items[0].metadata.uid}")
if [ -z "${subscriptionUID}" ]; then
echo "Subscription UID not found, retrying in 5 seconds..."
sleep 5
fi
done
echo "Subscription (${SUBSCRIPTION}) UID: ${subscriptionUID}"
if [ ! -z "subscriptionUID" ]; then
# this complicated go-template finds an InstallPlan where both the .spec.clusterServiceVersionNames contains the expected CSV
Expand All @@ -54,8 +61,15 @@ spec:
EOF
)`}}
echo
echo "Get InstallPlan for CSV (${SUBSCRIPTION_CSV}) with Subscription (${SUBSCRIPTION_CSV}) (${subscriptionUID}) owner"
installPlan=$(oc get installplan -o=go-template="${installPlanGoTemplate}")
installPlan=""
while [ -z "${installPlan}" ]; do
echo "Get InstallPlan for CSV (${SUBSCRIPTION_CSV}) with Subscription (${SUBSCRIPTION_CSV}) (${subscriptionUID}) owner"
installPlan=$(oc get installplan -o=go-template="${installPlanGoTemplate}")
if [ -z "${installPlan}" ]; then
echo "InstallPlan not found, retrying in 5 seconds..."
sleep 5
fi
done
echo "InstallPlan for CSV (${SUBSCRIPTION_CSV}) with Subscription (${SUBSCRIPTION_CSV}) (${subscriptionUID}) owner: ${installPlan}"
if [ ! -z "${installPlan}" ]; then
echo
Expand Down

0 comments on commit 2e76dab

Please sign in to comment.