[COMMON] Add custom certs into AAF truststore
[oom.git] / kubernetes / helm / plugins / undeploy / undeploy.sh
1 #!/bin/bash
2
3 usage() {
4 cat << EOF
5 Delete an umbrella Helm Chart, and its subcharts, that was previously deployed using 'Helm deploy'. 
6
7 Example of deleting all Releases that have the prefix 'demo'.
8   $ helm undeploy demo
9
10   $ helm undeploy demo --purge
11
12 Usage:
13   helm undeploy [RELEASE] [flags]
14
15 Flags:
16       --purge     remove the releases from the store and make its name free for later use
17 EOF
18 }
19
20 undeploy() {
21   RELEASE=$1
22   FLAGS=$2
23
24   array=($(helm ls -q --all | grep $RELEASE))
25   n=${#array[*]}
26   for (( i = n-1; i >= 0; i-- ))
27   do
28     helm del "${array[i]}" $FLAGS
29   done
30 }
31
32 if [[ $# < 1 ]]; then
33   echo "Error: command 'undeploy' requires a release name"
34   exit 0
35 fi
36
37 case "${1:-"help"}" in
38   "help")
39     usage
40     ;;
41   "--help")
42     usage
43     ;;
44   "-h")
45     usage
46     ;;
47   *)
48     undeploy $1 ${@:2}
49     ;;
50 esac
51
52 exit 0