Skip to content

Commit d002497

Browse files
committed
Address shellcheck warnings in bootstrap scripts
Several warnings were unaddressed. Some of them were disabled as they can be safely ignored. Others were refactored as the warnings were legitimate.
1 parent 0554dee commit d002497

File tree

5 files changed

+52
-48
lines changed

5 files changed

+52
-48
lines changed

pkg/deploy/assets/gateway-production.json

Lines changed: 1 addition & 13 deletions
Large diffs are not rendered by default.

pkg/deploy/assets/rp-production.json

Lines changed: 1 addition & 13 deletions
Large diffs are not rendered by default.

pkg/deploy/generator/scripts/util-common.sh

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

44
# declare -r empty_str=""
55
#
6-
# empty_str - constant; used by functions for optional nameref string arguements
6+
# empty_str - constant
7+
# * used by functions for optional nameref string arguments
78
# shellcheck disable=SC2034
89
declare -r empty_str=""
910

@@ -21,12 +22,14 @@ declare -r role_rp="rp"
2122

2223
# declare -r role_devproxy="devproxy"
2324
#
24-
# role_devproxy - constant; Is used to determine which VMSS is being bootstrapped
25+
# role_devproxy - constant
26+
# * Is used to determine which VMSS is being bootstrapped
2527
declare -r role_devproxy="devproxy"
2628

2729
# declare -r us_gov_cloud="AzureUSGovernment"
2830
#
29-
# us_gov_cloud - constant; Is the name of AZURECLOUDNAME for US government cloud
31+
# us_gov_cloud - constant
32+
# * Is the name of AZURECLOUDNAME for US government cloud
3033
declare -r us_gov_cloud="AzureUSGovernment"
3134

3235
# declare -i XTRACE_SET=1
@@ -77,7 +80,8 @@ xtrace_toggle() {
7780
# Wrapper for echo that includes the function name
7881
# args:
7982
# 1) msg - string
80-
# 2) stack_level - int; optional
83+
# 2) stack_level - int
84+
# * optional
8185
# * defaults to the function at the bottom of the call stack
8286
log() {
8387
local -r msg="${1:-"log message is empty"}"
@@ -100,8 +104,8 @@ abort() {
100104
# args:
101105
# 1) filename - string
102106
# 2) file_contents - string
103-
# 3) clobber - boolean; optional
104-
# * defaults to false
107+
# 3) clobber - boolean
108+
# * Optional; defaults to false
105109
write_file() {
106110
local -n filename="$1"
107111
local -n file_contents="$2"
@@ -163,11 +167,11 @@ verify_role() {
163167
# get_keyvault_suffix()
164168
#
165169
# args:
166-
# 1) rl - nameref, string;
170+
# 1) rl - nameref, string
167171
# * role to get short role for
168-
# 2) kv_suffix - nameref, string;
172+
# 2) kv_suffix - nameref, string
169173
# * short role will be assigned to this nameref
170-
# 3) sec_prefix - nameref, string;
174+
# 3) sec_prefix - nameref, string
171175
# * keyvault certificate prefix will be assigned to this nameref
172176
get_keyvault_suffix() {
173177
local -n rl="$1"
@@ -187,7 +191,7 @@ get_keyvault_suffix() {
187191
sec_prefix="$role_rp"
188192
;;
189193
*)
190-
abort "unkown role $rl"
194+
abort "unknown role $rl"
191195
;;
192196
esac
193197
}

pkg/deploy/generator/scripts/util-packages.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ dnf_install_pkgs() {
7171
# 2) wait_time - nameref, integer
7272
# * Time to wait before retrying command
7373
# 3) retries - integer, optional
74-
# * Ammount of times to retry command, defaults to 5
74+
# * Amount of times to retry command, defaults to 5
7575
dnf_update_pkgs() {
7676
local -n excludes="${1:-empty_str}"
7777
log "starting"

pkg/deploy/generator/scripts/util-services.sh

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ enable_services() {
2626
# configure_service_aro_gateway
2727
#
2828
# args:
29-
# 1) image - nameref, string;
29+
# 1) image - nameref, string
3030
# * container image
3131
# 2) role - nameref, string
3232
# * VMSS role
@@ -42,6 +42,7 @@ configure_service_aro_gateway() {
4242
log "starting"
4343
log "Configuring aro-gateway service"
4444

45+
# shellcheck disable=SC2034
4546
local -r aro_gateway_conf_filename='/etc/sysconfig/aro-gateway'
4647
local -r add_conf_file="PODMAN_NETWORK='podman'
4748
IPADDRESS='$ipaddress'
@@ -55,6 +56,7 @@ ARO_LOG_LEVEL='$GATEWAYLOGLEVEL'"
5556
local -r aro_gateway_service_filename='/etc/systemd/system/aro-gateway.service'
5657

5758
# shellcheck disable=SC2034
59+
# shellcheck disable=SC2016
5860
# below variable is in single quotes
5961
# as it is to be expanded at systemd start time (by systemd, not this script)
6062
local -r aro_gateway_service_file='[Unit]
@@ -391,7 +393,10 @@ configure_service_aro_mimo_actuator() {
391393
log "starting"
392394
log "Configuring aro-mimo-actuator service"
393395

396+
# shellcheck disable=SC2034
394397
local -r aro_mimo_actuator_conf_filename='/etc/sysconfig/aro-mimo-actuator'
398+
399+
# shellcheck disable=SC2034
395400
local -r add_conf_file="PODMAN_NETWORK='podman'
396401
IPADDRESS='$ipaddress'
397402
ARO_LOG_LEVEL='$MIMOACTUATORLOGLEVEL'"
@@ -1088,22 +1093,41 @@ configure_vmss_aro_services() {
10881093
verify_role "$1"
10891094

10901095
if [ "$r" == "$role_gateway" ]; then
1091-
configure_service_aro_gateway "${images["rp"]}" "$1" "${configs["gateway_config"]}" "${configs["static_ip_address"]}["gateway"]"
1096+
configure_service_aro_gateway "${images["rp"]}" "$1" "${configs["gateway_config"]}" "${configs["static_ip_address"]}[gateway]"
10921097
configure_certs_gateway
10931098
elif [ "$r" == "$role_rp" ]; then
1094-
configure_service_aro_rp "${images["rp"]}" "$1" "${configs["rp_config"]}" "${configs["static_ip_address"]}["rp"]"
1095-
configure_service_aro_mimo_actuator "${images["rp"]}" "${configs["rp_config"]}" "${configs["static_ip_address"]}["mimo_actuator"]"
1096-
configure_service_aro_monitor "${images["rp"]}" "${configs["static_ip_address"]}["monitor"]"
1097-
configure_service_aro_portal "${images["rp"]}" "${configs["static_ip_address"]}["portal"]"
1098-
configure_service_aro_mise "${images["mise"]}" "${configs["static_ip_address"]}["mise"]"
1099-
configure_service_aro_otel_collector "${images["otel"]}" "${configs["static_ip_address"]}" "${configs["static_ip_address"]}["otel_collector"]"
1099+
configure_service_aro_rp "${images["rp"]}" \
1100+
"$1" \
1101+
"${configs[rp_config]}" \
1102+
"${configs[static_ip_address]}[rp]"
1103+
1104+
configure_service_aro_mimo_actuator "${images[rp]}" \
1105+
"${configs[rp_config]}" \
1106+
"${configs[static_ip_address]}[mimo_actuator]"
1107+
1108+
configure_service_aro_monitor "${images[rp]}" "${configs[static_ip_address]}[monitor]"
1109+
1110+
configure_service_aro_portal "${images[rp]}" "${configs[static_ip_address]}[portal]"
1111+
1112+
configure_service_aro_mise "${images[mise]}" "${configs[static_ip_address]}[mise]"
1113+
1114+
configure_service_aro_otel_collector "${images[otel]}" \
1115+
"${configs[static_ip_address]}" \
1116+
"${configs["static_ip_address"]}[otel_collector]"
1117+
11001118
configure_certs_rp
11011119
fi
11021120

1103-
configure_service_fluentbit "${configs["fluentbit"]}" "${images["fluentbit"]}"
1121+
configure_service_fluentbit "${configs[fluentbit]}" "${images[fluentbit]}"
1122+
11041123
configure_timers_mdm_mdsd "$1"
1105-
configure_service_mdm "$1" "${images["mdm"]}" "${configs["static_ip_address"]}["mdm"]"
1106-
configure_service_mdsd "$1" "${configs["mdsd"]}"
1124+
1125+
configure_service_mdm "$1" \
1126+
"${images[mdm]}" \
1127+
"${configs["static_ip_address"]}[mdm]"
1128+
1129+
configure_service_mdsd "$1" "${configs[mdsd]}"
1130+
11071131
run_azsecd_config_scan
11081132
}
11091133

0 commit comments

Comments
 (0)