Skip to content

Commit c03f7dc

Browse files
lavocattMsarawan
authored andcommitted
[NO-ISSUE] override certManager namespace
Add the ability to override the cert manager namespace if the user doesn't want to rely on the auto detect in the subscriptions. Can be very useful when relying on helm charts instead of OLM to install cert manager.
1 parent 0270d94 commit c03f7dc

File tree

2 files changed

+59
-15
lines changed

2 files changed

+59
-15
lines changed

deploy.sh

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ function printUsage() {
1111
echo " ./${SCRIPT_NAME} -i|--image <image url>"
1212
echo "Options: "
1313
echo " -i|--image Specify the plugin image to deploy. (default is ${DEFAULT_IMAGE})"
14+
echo " -c|--certManagerNamespace give the namespace cert manager is installed in, will search for it in the Subscriptions otherwise"
1415
echo " -h|--help Print this message."
1516
}
1617

@@ -25,6 +26,11 @@ while [[ $# -gt 0 ]]; do
2526
shift
2627
shift
2728
;;
29+
-c|--certManagerNamespace)
30+
certManagerNamespace="$2"
31+
shift
32+
shift
33+
;;
2834
-*|--*)
2935
echo "Unknown option $1"
3036
printUsage
@@ -35,17 +41,21 @@ while [[ $# -gt 0 ]]; do
3541
esac
3642
done
3743

38-
# find the cert-manager operator namespace, if this can't be retrived there's no
39-
# possibility to proceed
40-
certManagerNamespace=$(oc get Subscriptions --all-namespaces -ojson | jq -r '.items[] | select(.spec.name == "cert-manager") | .metadata.namespace')
44+
# if the user has overridden the certManagerNamespace don't try to search for it
4145
if test -z "$certManagerNamespace"
42-
then
43-
certManagerNamespace=$(oc get Subscriptions --all-namespaces -ojson | jq -r '.items[] | select(.spec.name == "openshift-cert-manager-operator") | .metadata.namespace')
46+
then
47+
# find the cert-manager operator namespace, if this can't be retrived there's no
48+
# possibility to proceed
49+
certManagerNamespace=$(oc get Subscriptions --all-namespaces -ojson | jq -r '.items[] | select(.spec.name == "cert-manager") | .metadata.namespace')
4450
if test -z "$certManagerNamespace"
4551
then
46-
echo "cert-manager's namespace can't be determined, check that it is installed"
47-
oc get Subscriptions --all-namespaces
48-
exit 1
52+
certManagerNamespace=$(oc get Subscriptions --all-namespaces -ojson | jq -r '.items[] | select(.spec.name == "openshift-cert-manager-operator") | .metadata.namespace')
53+
if test -z "$certManagerNamespace"
54+
then
55+
echo "Error: cert-manager's namespace can't be determined"
56+
oc get Subscriptions --all-namespaces
57+
exit 1
58+
fi
4959
fi
5060
fi
5161
echo "cert-manager's namespace: $certManagerNamespace"

undeploy.sh

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,49 @@
11
#!/usr/bin/env sh
22

3-
# find the cert-manager operator namespace, if this can't be retrived there's no
4-
# possibility to proceed
5-
certManagerNamespace=$(oc get Subscriptions --all-namespaces -ojson | jq -r '.items[] | select(.spec.name == "cert-manager") | .metadata.namespace')
3+
function printUsage() {
4+
echo "${SCRIPT_NAME}: Deleting the jolokia api server from openshift"
5+
echo "Usage:"
6+
echo " ./${SCRIPT_NAME} -i|--image <image url>"
7+
echo "Options: "
8+
echo " -c|--certManagerNamespace give the namespace cert manager is installed in, will search for it in the Subscriptions otherwise"
9+
echo " -h|--help Print this message."
10+
}
11+
12+
while [[ $# -gt 0 ]]; do
13+
case $1 in
14+
-h|--help)
15+
printUsage
16+
exit 0
17+
;;
18+
-c|--certManagerNamespace)
19+
certManagerNamespace="$2"
20+
shift
21+
shift
22+
;;
23+
-*|--*)
24+
echo "Unknown option $1"
25+
printUsage
26+
exit 1
27+
;;
28+
*)
29+
;;
30+
esac
31+
done
32+
33+
# if the user has overridden the certManagerNamespace don't try to search for it
634
if test -z "$certManagerNamespace"
7-
then
8-
certManagerNamespace=$(oc get Subscriptions --all-namespaces -ojson | jq -r '.items[] | select(.spec.name == "openshift-cert-manager-operator") | .metadata.namespace')
35+
then
36+
# find the cert-manager operator namespace, if this can't be retrived there's no
37+
# possibility to proceed
38+
certManagerNamespace=$(oc get Subscriptions --all-namespaces -ojson | jq -r '.items[] | select(.spec.name == "cert-manager") | .metadata.namespace')
939
if test -z "$certManagerNamespace"
1040
then
11-
echo "cert-manager's namespace can't be determined, defaulting to default namespace"
12-
certManagerNamespace="openshift-operators"
41+
certManagerNamespace=$(oc get Subscriptions --all-namespaces -ojson | jq -r '.items[] | select(.spec.name == "openshift-cert-manager-operator") | .metadata.namespace')
42+
if test -z "$certManagerNamespace"
43+
then
44+
echo "Error: cert-manager's namespace can't be determined"
45+
exit 1
46+
fi
1347
fi
1448
fi
1549
echo "cert-manager's namespace: $certManagerNamespace"

0 commit comments

Comments
 (0)