Skip to content

Commit

Permalink
Delete at most one resource policy at a time
Browse files Browse the repository at this point in the history
  • Loading branch information
mr0re1 committed Aug 8, 2024
1 parent 9e68ecc commit 53db215
Showing 1 changed file with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,9 @@ done

echo "Deleting resource policies"
policies_filter="name:${cluster_name}-*"
while true; do
policies=$(gcloud compute resource-policies list --project "${project}" --format="value(selfLink)" --filter="${policies_filter}" --limit=10 | paste -sd " " -)
if [[ -z "${policies}" ]]; then
break
fi
# The lack of quotes is intentional and causes each new space-separated "word" to
# be treated as independent arguments. See PR#2523
# shellcheck disable=SC2086
gcloud compute resource-policies delete --quiet ${policies}
gcloud compute resource-policies list --project "${project}" --format="value(selfLink)" --filter="${policies_filter}" | while read -r line; do
echo "Deleting resource policy: $line"
gcloud compute resource-policies delete --quiet "${line}" || {
echo "Failed to delete resource policy: $line"
}
done

0 comments on commit 53db215

Please sign in to comment.