Skip to content

Commit 5093fab

Browse files
committed
Linting (round 2)
1 parent 3e88c87 commit 5093fab

File tree

7 files changed

+25
-27
lines changed

7 files changed

+25
-27
lines changed

bin/airgap-include.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
if [ "$AIRGAP_SOURCED" == "" ]; then
1010
## Check for AIRGAP_REGISTRY, if null/empty, error out. Otherwise set and create HELM_URL_BASE.
11-
if [ -z $AIRGAP_REGISTRY ]; then
11+
if [ -z "$AIRGAP_REGISTRY" ]; then
1212
log_error "AIRGAP_REGISTRY has not been set"
1313
log_error "Please provide the URL for the private image registry and try again"
1414
exit 1
@@ -17,7 +17,7 @@ if [ "$AIRGAP_SOURCED" == "" ]; then
1717
AIRGAP_IMAGE_PULL_SECRET_NAME=${AIRGAP_IMAGE_PULL_SECRET_NAME:-"v4m-image-pull-secret"}
1818

1919
# Check for the image pull secret for the air gap environment
20-
if [ -z "$(kubectl get secret -n $V4M_NS $AIRGAP_IMAGE_PULL_SECRET_NAME -o name --ignore-not-found)" ]; then
20+
if [ -z "$(kubectl get secret -n "$V4M_NS" "$AIRGAP_IMAGE_PULL_SECRET_NAME" -o name --ignore-not-found)" ]; then
2121
log_error "The image pull secret, [$AIRGAP_IMAGE_PULL_SECRET_NAME], was not detected"
2222
log_error "Please add the image pull secret to the [$V4M_NS] namespace and run the deployment script again"
2323
exit 1
@@ -40,7 +40,7 @@ if [ "$AIRGAP_SOURCED" == "" ]; then
4040
log_info "Deploying into an 'air-gapped' cluster from private registry [$AIRGAP_REGISTRY]"
4141

4242
airgapDir="$TMP_DIR/airgap"
43-
mkdir -p $airgapDir
43+
mkdir -p "$airgapDir"
4444

4545
export AIRGAP_SOURCED=true
4646
fi

bin/autogenerate-include.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ function create_ingress_certs {
3636
if [ -f "$certFile" ] && [ -f "$keyFile" ]; then
3737
kubectl delete secret "$secretName" --namespace "$namespace" --ignore-not-found
3838
kubectl create secret tls "$secretName" --namespace "$namespace" --key="$keyFile" --cert="$certFile"
39-
kubectl -n $namespace label secret $secretName managed-by="v4m-es-script"
40-
elif [ ! -z "$certFile$keyFile" ]; then
39+
kubectl -n "$namespace" label secret "$secretName" managed-by="v4m-es-script"
40+
elif [ -n "$certFile$keyFile" ]; then
4141
log_warn "Missing Ingress certificate file; specified Ingress cert [$certFile] and/or key [$keyFile] file is missing."
4242
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"
4343
fi
@@ -71,8 +71,12 @@ if [ -z "$AUTOGENERATE_SOURCED" ]; then
7171
exit 1
7272
fi
7373

74-
#validate required inputs
75-
BASE_DOMAIN="${BASE_DOMAIN}"
74+
#validate required inputs:
75+
# BASE_DOMAIN
76+
# ROUTING
77+
# INGRESS_CERT
78+
# INGRESS_KEY
79+
7680
if [ -z "$BASE_DOMAIN" ]; then
7781
log_error "Required parameter [BASE_DOMAIN] not provided"
7882
exit 1
@@ -88,8 +92,6 @@ if [ -z "$AUTOGENERATE_SOURCED" ]; then
8892
exit 1
8993
fi
9094

91-
INGRESS_CERT="${INGRESS_CERT}"
92-
INGRESS_KEY="${INGRESS_KEY}"
9395
if [ "$INGRESS_CERT/$INGRESS_KEY" != "/" ]; then
9496
if [ ! -f "$INGRESS_CERT" ] || [ ! -f "$INGRESS_KEY" ]; then
9597
# Only WARN b/c missing cert doesn't prevent deployment and it can be created afterwards

bin/common.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function trap_add() {
1818
printf '%s\n' "${cmd_to_add}"
1919
# helper fn to get existing trap command from output
2020
# of trap -p
21-
# shellcheck disable=SC2329
21+
# shellcheck disable=SC2329,SC2317
2222
extract_trap_cmd() { printf '%s\n' "$3"; }
2323
# print existing trap command with newline
2424
eval "extract_trap_cmd $(trap -p "${signal}")"

bin/log-include.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,7 @@ function add_notice {
3737

3838
function display_notices {
3939
if [ -f "$TMP_DIR/notices.txt" ]; then
40-
local IFS=''
41-
cat "$TMP_DIR"/notices.txt | while read -r line || [[ -n "$line" ]];
42-
do
43-
log_notice "$line"
44-
done
40+
while IFS= read -r line || [[ -n "$line" ]]; do log_notice "$line"; done <"$TMP_DIR"/notices.txt
4541
fi
4642
}
4743

bin/service-url-include.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ function get_k8s_info {
2929
object=$2
3030
jsonpath=$3
3131

32-
info=$(kubectl -n "$namespace" get "$object" -o=jsonpath=$jsonpath 2>/dev/null)
32+
info=$(kubectl -n "$namespace" get "$object" -o=jsonpath="$jsonpath" 2>/dev/null)
3333
rc=$?
3434

35-
if [ ! -z "$info" ]; then
35+
if [ -n "$info" ]; then
3636
echo "$info"
3737
else
3838
v4m_rc=1
@@ -162,7 +162,7 @@ function get_nodeport_url {
162162
protocol=http
163163
fi
164164

165-
if [ ! -z "$port" ]; then
165+
if [ -n "$port" ]; then
166166
porttxt=":$port"
167167
fi
168168

bin/show_app_url.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Copyright © 2021, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
44
# SPDX-License-Identifier: Apache-2.0
55

6-
cd "$(dirname $BASH_SOURCE)/.." || exit
6+
cd "$(dirname "$BASH_SOURCE")/.." || exit
77
source bin/common.sh
88
source bin/service-url-include.sh
99

@@ -86,7 +86,7 @@ do
8686

8787
# Print URLs
8888
# add_notice "*** $service ***"
89-
if [ ! -z "$service_url" ]; then
89+
if [ -n "$service_url" ]; then
9090
add_notice " You can access $service via the following URL:"
9191
add_notice " $service_url"
9292
add_notice ""

bin/version-include.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,18 @@ function populateValuesYAML() {
3636

3737
# Top-level user.env contents
3838
if [ -f "$USER_DIR/user.env" ]; then
39-
echo ' "user.env": |' >> "$v4mValuesYAML"
40-
cat "$USER_DIR/user.env" | sed 's/^/ /' >> "$v4mValuesYAML"
39+
echo ' "user.env": |' >> "$v4mValuesYAML"
40+
sed 's/^/ /' "$USER_DIR/user.env" >> "$v4mValuesYAML"
4141
fi
4242
# Monitoring user.env contents
4343
if [ -f "$USER_DIR/monitoring/user.env" ]; then
44-
echo ' "monitoring_user.env": |' >> "$v4mValuesYAML"
45-
cat "$USER_DIR/monitoring/user.env" | sed 's/^/ /' >> "$v4mValuesYAML"
44+
echo ' "monitoring_user.env": |' >> "$v4mValuesYAML"
45+
sed 's/^/ /' "$USER_DIR/monitoring/user.env" >> "$v4mValuesYAML"
4646
fi
4747
# Logging user.env contents
4848
if [ -f "$USER_DIR/logging/user.env" ]; then
49-
echo ' "logging_user.env": |' >> "$v4mValuesYAML"
50-
cat "$USER_DIR/logging/user.env" | sed 's/^/ /' >> "$v4mValuesYAML"
49+
echo ' "logging_user.env": |' >> "$v4mValuesYAML"
50+
sed 's/^/ /' "$USER_DIR/logging/user.env" >> "$v4mValuesYAML"
5151
fi
5252
fi
5353

@@ -92,7 +92,7 @@ function removeV4MInfo() {
9292
return 1
9393
fi
9494

95-
if [ ! -z "$(helm list -n "$NS" --filter "^$releaseName\$" -q)" ]; then
95+
if [ -n "$(helm list -n "$NS" --filter "^$releaseName\$" -q)" ]; then
9696
log_info "Removing SAS Viya Monitoring for Kubernetes version information"
9797
helm uninstall -n "$NS" "$releaseName"
9898
fi

0 commit comments

Comments
 (0)