-
Notifications
You must be signed in to change notification settings - Fork 179
Expand file tree
/
Copy pathuninstall.sh
More file actions
executable file
·50 lines (38 loc) · 1.37 KB
/
uninstall.sh
File metadata and controls
executable file
·50 lines (38 loc) · 1.37 KB
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
#!/usr/bin/env bash
# SPDX-FileCopyrightText: the secureCodeBox authors
#
# SPDX-License-Identifier: Apache-2.0
# Official uninstall script for the secureCodeBox
#
# Removes all available resources (scanners, demo-targets, hooks, operator) and namespaces
#
# For more information see https://www.securecodebox.io/
set -eu
shopt -s extglob
# @see: http://wiki.bash-hackers.org/syntax/shellvars
[ -z "${SCRIPT_DIRECTORY:-}" ] &&
SCRIPT_DIRECTORY="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
BASE_DIR=$(dirname "${SCRIPT_DIRECTORY}")
SCB_SYSTEM_NAMESPACE='securecodebox-system'
SCB_DEMO_NAMESPACE='demo-targets'
SCB_NAMESPACE='default'
function uninstallResources() {
local resource_directory="$1"
local namespace="$2"
local resources=()
for path in "$resource_directory"/*; do
[ -d "${path}" ] || continue # skip if not a directory
local directory
directory="$(basename "${path}")"
resources+=("${directory}")
done
for resource in "${resources[@]}"; do
helm uninstall "$resource" -n "$namespace" || true
done
}
helm -n "$SCB_SYSTEM_NAMESPACE" uninstall securecodebox-operator || true
uninstallResources "$BASE_DIR/demo-targets" "$SCB_DEMO_NAMESPACE"
uninstallResources "$BASE_DIR/scanners" "$SCB_NAMESPACE"
uninstallResources "$BASE_DIR/hooks" "$SCB_NAMESPACE"
kubectl delete namespaces "$SCB_SYSTEM_NAMESPACE" || true
echo "Uninstall completed"