forked from rht-labs/ubiquitous-journey
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpatch-gitops-operator.sh
executable file
·31 lines (28 loc) · 1.06 KB
/
patch-gitops-operator.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
#!/bin/bash
# ./patch-gitops-operator.sh $argocd_ns
if [ -z ${1} ]; then
echo "🤥 No namespace specified - please set one 🤥 "
echo "./patch-gitops-operator.sh \$argocd_ns"
echo "For example:"
echo "./patch-gitops-operator.sh labs-ci-cd"
exit -1
fi
export ARGOCD_NAMESPACE=${1}
run()
{
NS=$(oc get subscription/openshift-gitops-operator -n openshift-operators \
-o jsonpath='{.spec.config.env[?(@.name=="ARGOCD_CLUSTER_CONFIG_NAMESPACES")].value}')
if [ -z $NS ]; then
NS="${ARGOCD_NAMESPACE}"
elif [[ "$NS" =~ .*"${ARGOCD_NAMESPACE}".* ]]; then
echo "${ARGOCD_NAMESPACE} already added."
return
else
NS="${ARGOCD_NAMESPACE},${NS}"
fi
oc -n openshift-operators patch subscription/openshift-gitops-operator --type=json \
-p '[{"op":"replace","path":"/spec/config/env/1","value":{"name": "ARGOCD_CLUSTER_CONFIG_NAMESPACES", "value":"'${NS}'"}}]'
echo "EnvVar set to: $(oc get subscription/openshift-gitops-operator -n openshift-operators \
-o jsonpath='{.spec.config.env[?(@.name=="ARGOCD_CLUSTER_CONFIG_NAMESPACES")].value}')"
}
run