forked from rancher/fleet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
k3d-act-clean
executable file
·56 lines (45 loc) · 1.18 KB
/
k3d-act-clean
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env bash
set -e
function k3d-cluster-delete {
if [ -z "$1" ]; then
return
fi
k3d cluster delete "$1"
}
function docker-clean-by-name {
if [ -z "$1" ]; then
return
fi
ids=$(docker ps -a --filter name="$1" --format "{{.ID}}")
if [ -z "$ids" ]; then
return
fi
for id in $ids; do
docker stop "$id"
docker rm "$id"
done
}
if [[ -n "$FLEET_E2E_CLUSTER" || -n "$FLEET_E2E_CLUSTER_DOWNSTREAM" ]]; then
k3d-cluster-delete "$FLEET_E2E_CLUSTER"
k3d-cluster-delete "$FLEET_E2E_CLUSTER_DOWNSTREAM"
docker-clean-by-name "$FLEET_E2E_CLUSTER"
docker-clean-by-name "$FLEET_E2E_CLUSTER_DOWNSTREAM"
else
configs=(
dev/env.single-cluster-defaults
dev/env.multi-cluster-defaults
)
for config in "${configs[@]}"; do
# shellcheck source=/dev/null
source "$config"
config_vars=(
"$FLEET_E2E_CLUSTER"
"$FLEET_E2E_CLUSTER_DOWNSTREAM"
)
for config_var in "${config_vars[@]}"; do
k3d-cluster-delete "$config_var"
docker-clean-by-name "$config_var"
done
done
fi
docker-clean-by-name "act"