mirror of
https://github.com/ansible-collections/google.cloud.git
synced 2025-07-23 05:10:29 -07:00
fixing compute_url_map, add cleanup script
Compute_url_map was broken by #509: It also merged in #393, which has an erroneous understanding that compute_url_map always returns a diff (integration tests show it does not). Adding a cleanup script to help with environment hygiene. Added cleanup to CI to help make tests less flakey.
This commit is contained in:
parent
0cece672cf
commit
4816e97719
3 changed files with 53 additions and 5 deletions
33
scripts/cleanup-project.sh
Executable file
33
scripts/cleanup-project.sh
Executable file
|
@ -0,0 +1,33 @@
|
|||
#!/usr/bin/env bash
|
||||
# cleanup-project cleans up an ansible testing project
|
||||
#
|
||||
# WARNING: do not run tests against a project while
|
||||
# this is running, or else your tests will fail.
|
||||
#
|
||||
# dependencies:
|
||||
# - google-cloud-sdk (gcloudgcloud )
|
||||
set -e
|
||||
PROJECT_ID="${1}"
|
||||
SERVICE_ACCOUNT_NAME="${2}"
|
||||
ZONE="us-central1-a"
|
||||
|
||||
main() {
|
||||
# note: the ordering here is deliberate, to start with
|
||||
# leaf resources and work upwards to parent resources.
|
||||
cleanup_resource "compute instances" "--zone=$ZONE"
|
||||
cleanup_resource "compute target-http-proxies" "--global"
|
||||
cleanup_resource "compute forwarding-rules" "--global"
|
||||
cleanup_resource "compute url-maps" "--global"
|
||||
cleanup_resource "compute backend-services" "--global"
|
||||
}
|
||||
|
||||
cleanup_resource() {
|
||||
resource_group="$1"
|
||||
extra_delete_args="$2"
|
||||
|
||||
for resource in $(gcloud $resource_group list --project="${PROJECT_ID}" --format="csv[no-heading](name)"); do
|
||||
gcloud $resource_group delete "${resource}" --project="${PROJECT_ID}" -q $extra_delete_args
|
||||
done
|
||||
}
|
||||
|
||||
main
|
Loading…
Add table
Add a link
Reference in a new issue