-
Notifications
You must be signed in to change notification settings - Fork 15
/
stop
executable file
·51 lines (39 loc) · 1.17 KB
/
stop
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
#!/bin/bash
set -euo pipefail
. utils.sh
if [[ $PLATFORM == openshift ]]; then
export OPENSHIFT_USERNAME="${OPENSHIFT_USERNAME:-$OSHIFT_CLUSTER_ADMIN_USERNAME}"
oc_login
fi
set_namespace default
result=0
if has_namespace $CONJUR_NAMESPACE_NAME; then
$cli --request-timeout=5m delete namespace $CONJUR_NAMESPACE_NAME
printf "Waiting for $CONJUR_NAMESPACE_NAME namespace deletion to complete"
# Wait up to 10 minutes for namespace deletion to complete
wait_time=600
while has_namespace "$CONJUR_NAMESPACE_NAME"; do
printf "."
wait_time=$(( wait_time - 5 ))
if [ "$wait_time" -lt 0 ]; then
echo ""
echo "Timeout deleting namespace ${CONJUR_NAMESPACE_NAME}"
result=1
break
fi
sleep 5
done
echo ""
fi
echo "Deleting cluster role"
$cli delete --ignore-not-found clusterrole conjur-authenticator-$CONJUR_NAMESPACE_NAME
if [[ $PLATFORM == openshift ]]; then
echo "Deleting custom AUDIT_WRITE SecurityContextConstraints"
$cli delete --ignore-not-found scc "$CONJUR_NAMESPACE_NAME-audit-write"
fi
if [ "$result" -ne 0 ]; then
echo "Failed to purge conjur environment"
else
echo "Conjur environment purged."
fi
exit $result