Skip to content

Commit b91b082

Browse files
authored
Housekeeping: lint remaining scripts in bin (shellck5) (#799)
* Remove obsolete references to Elasticsearch and Kibana * [FIX] Corrects args sequence in tls_cert_managed_by_v4m
1 parent 975f69f commit b91b082

14 files changed

+1282
-1313
lines changed

bin/airgap-include.sh

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
# Copyright © 2023-2024, 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-
810
if [ "$AIRGAP_SOURCED" == "" ]; then
911
## Check for AIRGAP_REGISTRY, if null/empty, error out. Otherwise set and create HELM_URL_BASE.
10-
if [ -z $AIRGAP_REGISTRY ]; then
12+
if [ -z "$AIRGAP_REGISTRY" ]; then
1113
log_error "AIRGAP_REGISTRY has not been set"
1214
log_error "Please provide the URL for the private image registry and try again"
1315
exit 1
@@ -16,31 +18,27 @@ if [ "$AIRGAP_SOURCED" == "" ]; then
1618
AIRGAP_IMAGE_PULL_SECRET_NAME=${AIRGAP_IMAGE_PULL_SECRET_NAME:-"v4m-image-pull-secret"}
1719

1820
# Check for the image pull secret for the air gap environment
19-
if [ -z "$(kubectl get secret -n $V4M_NS $AIRGAP_IMAGE_PULL_SECRET_NAME -o name --ignore-not-found)" ]; then
20-
log_error "The image pull secret, [$AIRGAP_IMAGE_PULL_SECRET_NAME], was not detected"
21-
log_error "Please add the image pull secret to the [$V4M_NS] namespace and run the deployment script again"
22-
exit 1
21+
if [ -z "$(kubectl get secret -n "$V4M_NS" "$AIRGAP_IMAGE_PULL_SECRET_NAME" -o name --ignore-not-found)" ]; then
22+
log_error "The image pull secret, [$AIRGAP_IMAGE_PULL_SECRET_NAME], was not detected"
23+
log_error "Please add the image pull secret to the [$V4M_NS] namespace and run the deployment script again"
24+
exit 1
2325
fi
2426

2527
AIRGAP_HELM_REPO=${AIRGAP_HELM_REPO:-"$AIRGAP_REGISTRY"}
2628
AIRGAP_HELM_FORMAT=${AIRGAP_HELM_FORMAT:-"oci"}
2729

2830
if [ "$AIRGAP_HELM_FORMAT" == "tgz" ]; then
29-
if [ ! -d "$AIRGAP_HELM_REPO" ]; then
30-
log_error "When AIRGAP_HELM_FORMAT is 'tgz', AIRGAP_HELM_REPO is expected to be a directory."
31-
log_error "The specified AIRGAP_HELM_REPO directory [$AIRGAP_HELM_REPO] does NOT exist."
32-
exit 1
33-
else
34-
log_debug "Confirmed AIRGAP_HELM_REPO [$AIRGAP_HELM_REPO] exists"
35-
fi
31+
if [ ! -d "$AIRGAP_HELM_REPO" ]; then
32+
log_error "When AIRGAP_HELM_FORMAT is 'tgz', AIRGAP_HELM_REPO is expected to be a directory."
33+
log_error "The specified AIRGAP_HELM_REPO directory [$AIRGAP_HELM_REPO] does NOT exist."
34+
exit 1
35+
else
36+
log_debug "Confirmed AIRGAP_HELM_REPO [$AIRGAP_HELM_REPO] exists"
37+
fi
3638
fi
3739
fi
3840

3941
log_info "Deploying into an 'air-gapped' cluster from private registry [$AIRGAP_REGISTRY]"
4042

41-
airgapDir="$TMP_DIR/airgap"
42-
mkdir -p $airgapDir
43-
4443
export AIRGAP_SOURCED=true
4544
fi
46-

bin/autogenerate-include.sh

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
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-
810
function 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]"
180178
fi
181179

182-
183180
function 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"

bin/colors-include.sh

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Copyright © 2020, 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
# Added background colors and functions
58

69
# Colors
@@ -34,67 +37,67 @@ lightbluebg="\033[46m"
3437

3538
# Foregrounds
3639
function black {
37-
echo -e "${black}${1}${end}" >&3
40+
echo -e "${black}${1}${end}" >&3
3841
}
3942

4043
function blackb {
41-
echo -e "${blackb}${1}${end}" >&3
44+
echo -e "${blackb}${1}${end}" >&3
4245
}
4346

4447
function white {
45-
echo -e "${white}${1}${end}" >&3
48+
echo -e "${white}${1}${end}" >&3
4649
}
4750

4851
function whiteb {
49-
echo -e "${whiteb}${1}${end}" >&3
52+
echo -e "${whiteb}${1}${end}" >&3
5053
}
5154

5255
function red {
53-
echo -e "${red}${1}${end}" >&3
56+
echo -e "${red}${1}${end}" >&3
5457
}
5558

5659
function redb {
57-
echo -e "${redb}${1}${end}" >&3
60+
echo -e "${redb}${1}${end}" >&3
5861
}
5962

6063
function green {
61-
echo -e "${green}${1}${end}" >&3
64+
echo -e "${green}${1}${end}" >&3
6265
}
6366

6467
function greenb {
65-
echo -e "${greenb}${1}${end}" >&3
68+
echo -e "${greenb}${1}${end}" >&3
6669
}
6770

6871
function yellow {
69-
echo -e "${yellow}${1}${end}" >&3
72+
echo -e "${yellow}${1}${end}" >&3
7073
}
7174

7275
function yellowb {
73-
echo -e "${yellowb}${1}${end}" >&3
76+
echo -e "${yellowb}${1}${end}" >&3
7477
}
7578

7679
function blue {
77-
echo -e "${blue}${1}${end}" >&3
80+
echo -e "${blue}${1}${end}" >&3
7881
}
7982

8083
function blueb {
81-
echo -e "${blueb}${1}${end}" >&3
84+
echo -e "${blueb}${1}${end}" >&3
8285
}
8386

8487
function purple {
85-
echo -e "${purple}${1}${end}" >&3
88+
echo -e "${purple}${1}${end}" >&3
8689
}
8790

8891
function purpleb {
89-
echo -e "${purpleb}${1}${end}" >&3
92+
echo -e "${purpleb}${1}${end}" >&3
9093
}
9194

9295
function lightblue {
93-
echo -e "${lightblue}${1}${end}" >&3
96+
echo -e "${lightblue}${1}${end}" >&3
9497
}
9598

9699
function lightblueb {
97-
echo -e "${lightblueb}${1}${end}" >&3
100+
echo -e "${lightblueb}${1}${end}" >&3
98101
}
99102

100103
# Export all the things

0 commit comments

Comments
 (0)