66
77
88function checkYqVersion {
9- # confirm yq installed and correct version
10- local goodver yq_version
11- goodver=" yq \(.+mikefarah.+\) version (v)?(4\.(3[2-9]|[4-9][0-9])\..+)"
12- yq_version=$( yq --version)
13- if [ " $? " == " 1" ]; then
14- log_error " Required component [yq] not available."
15- return 1
16- elif [[ ! $yq_version =~ $goodver ]]; then
17- log_error " Incorrect version [$yq_version ] found; version 4.32.2+ required."
18- return 1
19- else
20- log_debug " A valid version [$yq_version ] of yq detected"
21- return 0
22- fi
9+ # confirm yq installed and correct version
10+ local goodver yq_version
11+ goodver=" yq \(.+mikefarah.+\) version (v)?(4\.(3[2-9]|[4-9][0-9])\..+)"
12+ yq_version=$( yq --version)
13+ if [ " $? " == " 1" ]; then
14+ log_error " Required component [yq] not available."
15+ return 1
16+ elif [[ ! $yq_version =~ $goodver ]]; then
17+ log_error " Incorrect version [$yq_version ] found; version 4.32.2+ required."
18+ return 1
19+ else
20+ log_debug " A valid version [$yq_version ] of yq detected"
21+ return 0
22+ fi
2323}
2424
2525export -f checkYqVersion
2626
2727function create_ingress_certs {
28- local certFile keyFile namespace secretName
29-
30- namespace=" $1 "
31- secretName=" $2 "
32- certFile=" ${3:- $INGRESS_CERT } "
33- keyFile=" ${4:- $INGRESS_KEY } "
34-
35- if [ -f " $certFile " ] && [ -f " $keyFile " ]; then
36- kubectl delete secret " $secretName " --namespace " $namespace " --ignore-not-found
37- kubectl create secret tls " $secretName " --namespace " $namespace " --key=" $keyFile " --cert=" $certFile "
38- kubectl -n $namespace label secret $secretName managed-by=" v4m-es-script"
39- elif [ ! -z " $certFile$keyFile " ]; then
40- log_warn " Missing Ingress certificate file; specified Ingress cert [$certFile ] and/or key [$keyFile ] file is missing."
41- log_warn " Create the missing Kubernetes secrets after deployment; use command: kubectl -create secret tls $secretName --namespace $namespace --key=cert_key_file --cert=cert_file"
42- fi
28+ local certFile keyFile namespace secretName
29+
30+ namespace=" $1 "
31+ secretName=" $2 "
32+ certFile=" ${3:- $INGRESS_CERT } "
33+ keyFile=" ${4:- $INGRESS_KEY } "
34+
35+ if [ -f " $certFile " ] && [ -f " $keyFile " ]; then
36+ kubectl delete secret " $secretName " --namespace " $namespace " --ignore-not-found
37+ kubectl create secret tls " $secretName " --namespace " $namespace " --key=" $keyFile " --cert=" $certFile "
38+ kubectl -n $namespace label secret $secretName managed-by=" v4m-es-script"
39+ elif [ ! -z " $certFile$keyFile " ]; then
40+ log_warn " Missing Ingress certificate file; specified Ingress cert [$certFile ] and/or key [$keyFile ] file is missing."
41+ log_warn " Create the missing Kubernetes secrets after deployment; use command: kubectl -create secret tls $secretName --namespace $namespace --key=cert_key_file --cert=cert_file"
42+ fi
4343}
4444
4545export -f create_ingress_certs
@@ -48,76 +48,76 @@ AUTOGENERATE_INGRESS="${AUTOGENERATE_INGRESS:-false}"
4848AUTOGENERATE_STORAGECLASS=" ${AUTOGENERATE_STORAGECLASS:- false} "
4949
5050if [ " $AUTOGENERATE_INGRESS " != " true" ] && [ " $AUTOGENERATE_STORAGECLASS " != " true" ]; then
51- log_debug " No autogeneration of YAML enabled"
52- export AUTOGENERATE_SOURCED=" NotNeeded"
51+ log_debug " No autogeneration of YAML enabled"
52+ export AUTOGENERATE_SOURCED=" NotNeeded"
5353fi
5454
5555if [ -z " $AUTOGENERATE_SOURCED " ]; then
5656
57- if ! checkYqVersion; then
58- exit 1
59- fi
60-
61- if [ " $AUTOGENERATE_INGRESS " == " true" ]; then
62-
63- # Confirm NOT on OpenShift
64- if [ " $OPENSHIFT_CLUSTER " == " true" ]; then
65- log_error " Setting AUTOGENERATE_INGRESS to 'true' is not valid on OpenShift clusters."
66- log_error " Web applications will be made accessible via OpenShift routes instead (if enabled)."
67-
68- export AUTOGENERATE_INGRESS=" false"
69- exit 1
70- fi
71-
72-
73- # validate required inputs
74- BASE_DOMAIN=" ${BASE_DOMAIN} "
75- if [ -z " $BASE_DOMAIN " ]; then
76- log_error " Required parameter [BASE_DOMAIN] not provided"
77- exit 1
78- fi
79-
80- ROUTING=" ${ROUTING:- host} "
81-
82- if [ " $ROUTING " == " path" ]; then
83- export MON_TLS_PATH_INGRESS=" true"
84- log_debug " Path ingress requested, setting MON_TLS_PATH_INGRESS to 'true'"
85- elif [ " $ROUTING " != " host" ] && [ " $ROUTING " != " path" ]; then
86- log_error " Invalid ROUTING value, valid values are 'host' or 'path'"
87- exit 1
88- fi
89-
90- INGRESS_CERT=" ${INGRESS_CERT} "
91- INGRESS_KEY=" ${INGRESS_KEY} "
92- if [ " $INGRESS_CERT /$INGRESS_KEY " != " /" ]; then
93- if [ ! -f " $INGRESS_CERT " ] || [ ! -f " $INGRESS_KEY " ]; then
94- # Only WARN b/c missing cert doesn't prevent deployment and it can be created afterwards
95- log_warn " Missing Ingress certificate file; specified Ingress cert [$INGRESS_CERT ] and/or key [$INGRESS_KEY ] file is missing."
96- log_warn " You can create the missing Kubernetes secrets after deployment. See Enable TLS for Ingress topic in Help Center documentation."
97- # unset variable values to prevent further attempted use
98- unset INGRESS_CERT
99- unset INGRESS_KEY
100- else
101- log_debug " Ingress cert [$INGRESS_CERT ] and key [$INGRESS_KEY ] files exist."
102- fi
103- fi
104-
105- log_info " Autogeneration of Ingress definitions has been enabled"
106-
107- fi
108-
109- if [ " $AUTOGENERATE_STORAGECLASS " == " true" ]; then
110-
111- log_info " Autogeneration of StorageClass specfication has been enabled"
112-
113- fi
114-
115- export AUTOGENERATE_SOURCED=" true"
116-
117- elif [ " $AUTOGENERATE_SOURCED " == " NotNeeded" ]; then
118- log_debug " autogenerate-include.sh not needed"
119- else
120- log_debug " autogenerate-include.sh was already sourced [$AUTOGENERATE_SOURCED ]"
57+ if ! checkYqVersion; then
58+ exit 1
59+ fi
60+
61+ if [ " $AUTOGENERATE_INGRESS " == " true" ]; then
62+
63+ # Confirm NOT on OpenShift
64+ if [ " $OPENSHIFT_CLUSTER " == " true" ]; then
65+ log_error " Setting AUTOGENERATE_INGRESS to 'true' is not valid on OpenShift clusters."
66+ log_error " Web applications will be made accessible via OpenShift routes instead (if enabled)."
67+
68+ export AUTOGENERATE_INGRESS=" false"
69+ exit 1
70+ fi
71+
72+
73+ # validate required inputs
74+ BASE_DOMAIN=" ${BASE_DOMAIN} "
75+ if [ -z " $BASE_DOMAIN " ]; then
76+ log_error " Required parameter [BASE_DOMAIN] not provided"
77+ exit 1
78+ fi
79+
80+ ROUTING=" ${ROUTING:- host} "
81+
82+ if [ " $ROUTING " == " path" ]; then
83+ export MON_TLS_PATH_INGRESS=" true"
84+ log_debug " Path ingress requested, setting MON_TLS_PATH_INGRESS to 'true'"
85+ elif [ " $ROUTING " != " host" ] && [ " $ROUTING " != " path" ]; then
86+ log_error " Invalid ROUTING value, valid values are 'host' or 'path'"
87+ exit 1
88+ fi
89+
90+ INGRESS_CERT=" ${INGRESS_CERT} "
91+ INGRESS_KEY=" ${INGRESS_KEY} "
92+ if [ " $INGRESS_CERT /$INGRESS_KEY " != " /" ]; then
93+ if [ ! -f " $INGRESS_CERT " ] || [ ! -f " $INGRESS_KEY " ]; then
94+ # Only WARN b/c missing cert doesn't prevent deployment and it can be created afterwards
95+ log_warn " Missing Ingress certificate file; specified Ingress cert [$INGRESS_CERT ] and/or key [$INGRESS_KEY ] file is missing."
96+ log_warn " You can create the missing Kubernetes secrets after deployment. See Enable TLS for Ingress topic in Help Center documentation."
97+ # unset variable values to prevent further attempted use
98+ unset INGRESS_CERT
99+ unset INGRESS_KEY
100+ else
101+ log_debug " Ingress cert [$INGRESS_CERT ] and key [$INGRESS_KEY ] files exist."
102+ fi
103+ fi
104+
105+ log_info " Autogeneration of Ingress definitions has been enabled"
106+
107+ fi
108+
109+ if [ " $AUTOGENERATE_STORAGECLASS " == " true" ]; then
110+
111+ log_info " Autogeneration of StorageClass specfication has been enabled"
112+
113+ fi
114+
115+ export AUTOGENERATE_SOURCED=" true"
116+
117+ elif [ " $AUTOGENERATE_SOURCED " == " NotNeeded" ]; then
118+ log_debug " autogenerate-include.sh not needed"
119+ else
120+ log_debug " autogenerate-include.sh was already sourced [$AUTOGENERATE_SOURCED ]"
121121fi
122122
123123
@@ -131,19 +131,17 @@ function checkStorageClass {
131131 storageClass=" ${2:- $STORAGECLASS } "
132132
133133 if [ -z " $storageClass " ]; then
134- log_error " Required parameter not provided. Either [$storageClassEnvVar ] or [STORAGECLASS] MUST be provided."
135- exit 1
134+ log_error " Required parameter not provided. Either [$storageClassEnvVar ] or [STORAGECLASS] MUST be provided."
135+ exit 1
136136 else
137- if $( kubectl get storageClass " $storageClass " -o name & > /dev/null) ; then
138- log_debug " The specified StorageClass [$storageClass ] exists"
139- else
140- log_error " The specified StorageClass [$storageClass ] does NOT exist"
141- exit 1
142- fi
137+ if $( kubectl get storageClass " $storageClass " -o name & > /dev/null) ; then
138+ log_debug " The specified StorageClass [$storageClass ] exists"
139+ else
140+ log_error " The specified StorageClass [$storageClass ] does NOT exist"
141+ exit 1
142+ fi
143143 fi
144144
145145}
146146
147-
148-
149147export -f checkStorageClass
0 commit comments