fix: don't send empty arguments to gcloud in the cleanup script

fix: don't send empty arguments to gcloud in the cleanup script
This commit is contained in:
Chris Hawk 2023-09-05 12:44:17 -07:00 committed by GitHub
commit 611e6d96db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -40,8 +40,20 @@ cleanup_resource() {
extra_list_arg="$3"
extra_delete_arg="$4"
for resource_id in $(gcloud "${resource_group}" "${resource}" list --project="${PROJECT_ID}" --format="csv[no-heading](name)" "${extra_list_arg}"); do
gcloud "${resource_group}" "${resource}" delete "${resource_id}" --project="${PROJECT_ID}" -q "${extra_delete_arg}"
if [ -z "$extra_list_arg" ]
then
resources=( $(gcloud "${resource_group}" "${resource}" list --project="${PROJECT_ID}" --format="csv[no-heading](name)") )
else
resources=( $(gcloud "${resource_group}" "${resource}" list --project="${PROJECT_ID}" --format="csv[no-heading](name)" "${extra_list_arg}") )
fi
for resource_id in $resources; do
if [ -z "$extra_delete_arg" ]
then
gcloud "${resource_group}" "${resource}" delete "${resource_id}" --project="${PROJECT_ID}" -q
else
gcloud "${resource_group}" "${resource}" delete "${resource_id}" --project="${PROJECT_ID}" -q "${extra_delete_arg}"
fi
done
}