11#  Copyright © 2025, SAS Institute Inc., Cary, NC, USA.  All Rights Reserved.
22#  SPDX-License-Identifier: Apache-2.0
33
4+ #  shellcheck disable=SC2148
5+ #  This script is not intended to be run directly
6+ 
47#  This file is not marked as executable as it is intended to be sourced
58#  Current directory must be the root directory of the repo
69
7- 
810function  checkYqVersion  {
911    #  confirm yq installed and correct version
1012    local  goodver yq_version
@@ -35,8 +37,8 @@ function create_ingress_certs {
3537    if  [ -f  " $certFile "   ] &&  [ -f  " $keyFile "   ];  then 
3638        kubectl delete secret " $secretName "   --namespace " $namespace "   --ignore-not-found
3739        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 
4042        log_warn " Missing Ingress certificate file; specified Ingress cert [$certFile ] and/or key [$keyFile ] file is missing." 
4143        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" 
4244    fi 
@@ -70,8 +72,12 @@ if [ -z "$AUTOGENERATE_SOURCED" ]; then
7072            exit  1
7173        fi 
7274
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+ 
7581        if  [ -z  " $BASE_DOMAIN "   ];  then 
7682            log_error " Required parameter [BASE_DOMAIN] not provided" 
7783            exit  1
@@ -87,8 +93,6 @@ if [ -z "$AUTOGENERATE_SOURCED" ]; then
8793            exit  1
8894        fi 
8995
90-         INGRESS_CERT=" ${INGRESS_CERT} " 
91-         INGRESS_KEY=" ${INGRESS_KEY} " 
9296        if  [ " $INGRESS_CERT /$INGRESS_KEY "   !=  " /"   ];  then 
9397            if  [ !  -f  " $INGRESS_CERT "   ] ||  [ !  -f  " $INGRESS_KEY "   ];  then 
9498                #  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
112116
113117    if  [ " $AUTOGENERATE_SMTP "   ==  " true"   ];  then 
114118
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
130128        SMTP_USER_SECRET=" ${SMTP_USER_SECRET:- grafana-smtp-user} " 
131129        SMTP_SKIP_VERIFY=" ${SMTP_SKIP_VERIFY:- false} " 
132130        SMTP_TLS_CERT_FILE=" ${SMTP_TLS_CERT_FILE:-/ cert/ tls.crt} " 
@@ -159,7 +157,7 @@ if [ -z "$AUTOGENERATE_SOURCED" ]; then
159157            log_debug " Secret [$SMTP_USER_SECRET ] exists; will use it for SMTP user credentials" 
160158        elif  [ -z  " $SMTP_USER "   ] &&  [ -z  " $SMTP_PASSWORD "   ];  then 
161159            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 
163161            log_error " Complete SMTP Credentials NOT provided; MUST provide BOTH [SMTP_USER] and [SMTP_PASSWORD]" 
164162            log_info " SMTP_USER is set to [$SMTP_USER ] and SMTP_PASSWORD is set to [$SMTP_PASSWORD ]" 
165163            exit  1
@@ -173,13 +171,12 @@ if [ -z "$AUTOGENERATE_SOURCED" ]; then
173171
174172    export  AUTOGENERATE_SOURCED=" true" 
175173
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 ]" 
180178fi 
181179
182- 
183180function  checkStorageClass  {
184181    #  input parms: $1  *Name of env var* identifying storageClass
185182    #  input parms: $2  storageClass
@@ -193,7 +190,8 @@ function checkStorageClass {
193190        log_error " Required parameter not provided.  Either [$storageClassEnvVar ] or [STORAGECLASS] MUST be provided." 
194191        exit  1
195192    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 
197195            log_debug " The specified StorageClass [$storageClass ] exists" 
198196        else 
199197            log_error " The specified StorageClass [$storageClass ] does NOT exist" 
0 commit comments