1
1
# Copyright © 2025, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
2
2
# SPDX-License-Identifier: Apache-2.0
3
3
4
+ # shellcheck disable=SC2148
5
+ # This script is not intended to be run directly
6
+
4
7
# This file is not marked as executable as it is intended to be sourced
5
8
# Current directory must be the root directory of the repo
6
9
7
-
8
10
function checkYqVersion {
9
11
# confirm yq installed and correct version
10
12
local goodver yq_version
@@ -35,8 +37,8 @@ function create_ingress_certs {
35
37
if [ -f " $certFile " ] && [ -f " $keyFile " ]; then
36
38
kubectl delete secret " $secretName " --namespace " $namespace " --ignore-not-found
37
39
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
+ kubectl -n " $namespace " label secret " $secretName " managed-by=" v4m-es-script"
41
+ elif [ -n " $certFile$keyFile " ]; then
40
42
log_warn " Missing Ingress certificate file; specified Ingress cert [$certFile ] and/or key [$keyFile ] file is missing."
41
43
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
44
fi
@@ -70,8 +72,12 @@ if [ -z "$AUTOGENERATE_SOURCED" ]; then
70
72
exit 1
71
73
fi
72
74
73
- # validate required inputs
74
- BASE_DOMAIN=" ${BASE_DOMAIN} "
75
+ # validate required inputs:
76
+ # BASE_DOMAIN
77
+ # ROUTING
78
+ # INGRESS_CERT
79
+ # INGRESS_KEY
80
+
75
81
if [ -z " $BASE_DOMAIN " ]; then
76
82
log_error " Required parameter [BASE_DOMAIN] not provided"
77
83
exit 1
@@ -87,8 +93,6 @@ if [ -z "$AUTOGENERATE_SOURCED" ]; then
87
93
exit 1
88
94
fi
89
95
90
- INGRESS_CERT=" ${INGRESS_CERT} "
91
- INGRESS_KEY=" ${INGRESS_KEY} "
92
96
if [ " $INGRESS_CERT /$INGRESS_KEY " != " /" ]; then
93
97
if [ ! -f " $INGRESS_CERT " ] || [ ! -f " $INGRESS_KEY " ]; then
94
98
# Only WARN b/c missing cert doesn't prevent deployment and it can be created afterwards
@@ -112,21 +116,15 @@ if [ -z "$AUTOGENERATE_SOURCED" ]; then
112
116
113
117
if [ " $AUTOGENERATE_SMTP " == " true" ]; then
114
118
115
- # required
116
- # shellcheck disable=SC2269
117
- SMTP_HOST=" ${SMTP_HOST} "
118
- # shellcheck disable=SC2269
119
- SMTP_PORT=" ${SMTP_PORT} "
120
- # shellcheck disable=SC2269
121
- SMTP_FROM_ADDRESS=" ${SMTP_FROM_ADDRESS} "
122
- # shellcheck disable=SC2269
123
- SMTP_FROM_NAME=" ${SMTP_FROM_NAME} "
124
-
125
- # optional
126
- # shellcheck disable=SC2269
127
- SMTP_USER=" ${SMTP_USER} "
128
- # shellcheck disable=SC2269
129
- SMTP_PASSWORD=" ${SMTP_PASSWORD} "
119
+ # required settings
120
+ # SMTP_HOST - no default
121
+ # SMTP_PORT - no default
122
+ # SMTP_FROM_ADDRESS - no default
123
+ # SMTP_FROM_NAME - no default
124
+
125
+ # optional settings
126
+ # SMTP_USER - no default
127
+ # SMTP_PASSWORD - no default
130
128
SMTP_USER_SECRET=" ${SMTP_USER_SECRET:- grafana-smtp-user} "
131
129
SMTP_SKIP_VERIFY=" ${SMTP_SKIP_VERIFY:- false} "
132
130
SMTP_TLS_CERT_FILE=" ${SMTP_TLS_CERT_FILE:-/ cert/ tls.crt} "
@@ -159,7 +157,7 @@ if [ -z "$AUTOGENERATE_SOURCED" ]; then
159
157
log_debug " Secret [$SMTP_USER_SECRET ] exists; will use it for SMTP user credentials"
160
158
elif [ -z " $SMTP_USER " ] && [ -z " $SMTP_PASSWORD " ]; then
161
159
log_debug " Neither SMTP_USER nor SMTP_PASSWORD are set; skipping creation of secret [$SMTP_USER_SECRET ]"
162
- elif [ -z " $SMTP_USER " ] || [ -z " $SMTP_PASSWORD " ]; then
160
+ elif [ -z " $SMTP_USER " ] || [ -z " $SMTP_PASSWORD " ]; then
163
161
log_error " Complete SMTP Credentials NOT provided; MUST provide BOTH [SMTP_USER] and [SMTP_PASSWORD]"
164
162
log_info " SMTP_USER is set to [$SMTP_USER ] and SMTP_PASSWORD is set to [$SMTP_PASSWORD ]"
165
163
exit 1
@@ -173,13 +171,12 @@ if [ -z "$AUTOGENERATE_SOURCED" ]; then
173
171
174
172
export AUTOGENERATE_SOURCED=" true"
175
173
176
- elif [ " $AUTOGENERATE_SOURCED " == " NotNeeded" ]; then
177
- log_debug " autogenerate-include.sh not needed"
178
- else
179
- log_debug " autogenerate-include.sh was already sourced [$AUTOGENERATE_SOURCED ]"
174
+ elif [ " $AUTOGENERATE_SOURCED " == " NotNeeded" ]; then
175
+ log_debug " autogenerate-include.sh not needed"
176
+ else
177
+ log_debug " autogenerate-include.sh was already sourced [$AUTOGENERATE_SOURCED ]"
180
178
fi
181
179
182
-
183
180
function checkStorageClass {
184
181
# input parms: $1 *Name of env var* identifying storageClass
185
182
# input parms: $2 storageClass
@@ -193,7 +190,8 @@ function checkStorageClass {
193
190
log_error " Required parameter not provided. Either [$storageClassEnvVar ] or [STORAGECLASS] MUST be provided."
194
191
exit 1
195
192
else
196
- if $( kubectl get storageClass " $storageClass " -o name & > /dev/null) ; then
193
+ # shellcheck disable=SC2091
194
+ if $( kubectl get storageClass " $storageClass " -o name & > /dev/null) ; then
197
195
log_debug " The specified StorageClass [$storageClass ] exists"
198
196
else
199
197
log_error " The specified StorageClass [$storageClass ] does NOT exist"
0 commit comments