From 17d3d9a92a9ad6b55c3dd1b64e0212aa9d46aff0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Petazzoni?= Date: Wed, 12 Apr 2023 08:25:47 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=20Add=20clean=20up=20scri?= =?UTF-8?q?pt=20to=20remove=20stray=20LBs=20and=20PVs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- prepare-labs/cleanup.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 prepare-labs/cleanup.sh diff --git a/prepare-labs/cleanup.sh b/prepare-labs/cleanup.sh new file mode 100755 index 00000000..c61eba74 --- /dev/null +++ b/prepare-labs/cleanup.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +case "$1-$2" in +linode-lb) + linode-cli nodebalancers list --json | + jq '.[] | select(.label | startswith("ccm-")) | .id' | + xargs -n1 -P10 linode-cli nodebalancers delete + ;; +linode-pvc) + linode-cli volumes list --json | + jq '.[] | select(.label | startswith("pvc")) | .id' | + xargs -n1 -P10 linode-cli volumes delete + ;; +digitalocean-lb) + doctl compute load-balancer list --output json | + jq .[].id | + xargs -n1 -P10 doctl compute load-balancer delete --force + ;; +digitalocean-pvc) + doctl compute volume list --output json | + jq '.[] | select(.name | startswith("pvc-")) | .id' | + xargs -n1 -P10 doctl compute volume delete --force + ;; +*) + echo "Unknown combination of provider ('$1') and resource ('$2')." + ;; +esac +