Merge commit '939177be6b30bd19dd3acfc1ae85690b83803234' as 'acm-hub-bootstrap'
This commit is contained in:
28
acm-hub-bootstrap/common/scripts/manage-secret-namespace.sh
Executable file
28
acm-hub-bootstrap/common/scripts/manage-secret-namespace.sh
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
|
||||
NAMESPACE=$1
|
||||
STATE=$2
|
||||
|
||||
MAIN_CLUSTERGROUP_FILE="./values-$(common/scripts/determine-main-clustergroup.sh).yaml"
|
||||
MAIN_CLUSTERGROUP_PROJECT="$(common/scripts/determine-main-clustergroup.sh)"
|
||||
|
||||
case "$STATE" in
|
||||
"present")
|
||||
|
||||
RES=$(yq ".clusterGroup.namespaces[] | select(. == \"$NAMESPACE\")" "$MAIN_CLUSTERGROUP_FILE" 2>/dev/null)
|
||||
if [ -z "$RES" ]; then
|
||||
echo "Namespace $NAMESPACE not found, adding"
|
||||
yq -i ".clusterGroup.namespaces += [ \"$NAMESPACE\" ]" "$MAIN_CLUSTERGROUP_FILE"
|
||||
fi
|
||||
;;
|
||||
"absent")
|
||||
echo "Removing namespace $NAMESPACE"
|
||||
yq -i "del(.clusterGroup.namespaces[] | select(. == \"$NAMESPACE\"))" "$MAIN_CLUSTERGROUP_FILE"
|
||||
;;
|
||||
*)
|
||||
echo "$STATE not supported"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user