forked from mojaloop/helm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclean.sh
60 lines (54 loc) · 1.1 KB
/
clean.sh
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
57
58
59
60
#!/bin/bash
usage() {
echo "Script to clean Helm deployments";
echo "Usage: `basename $0` options -r <release-name> (-e) (-d)";
echo "-r <release-name>: set helm release name -required"
echo "-e: execute helm command"
echo "-d: enable debug flags for helm"
echo "-h: display usage"
echo ""
}
# set an initial values
EXEC=false
DEBUG=false
# extract options and their arguments into variables.
while getopts ":r:edh" arg; do
case $arg in
r)
RELEASE=$OPTARG >&2
;;
e)
EXEC=true >&2
;;
d)
DEBUG=true >&2
;;
h)
usage;
exit 0;
;;
\?)
usage;
echo "Invalid option: -$OPTARG" >&2;
exit 1
break
;;
esac
done
if [ -z "$RELEASE" ];
then
usage;
echo "Missing option: -r" >&2;
exit 1
fi;
if $DEBUG;
then
OPT_ARGS=" --debug --dry-run "
fi;
CMD="helm del --purge $OPT_ARGS $RELEASE"
echo "Helm cmd: $CMD"
if $EXEC;
then
echo "executing command";
$CMD
fi;