mirror of
https://github.com/ansible-collections/google.cloud.git
synced 2025-04-05 02:10:27 -07:00
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:
commit
611e6d96db
1 changed files with 14 additions and 2 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue