Skip to content

Commit a068f9c

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 5579f3f commit a068f9c

File tree

3 files changed

+50
-22
lines changed

3 files changed

+50
-22
lines changed

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_IS_SET
@@ -72,7 +75,8 @@ xtrace_set() {
7275
# Wrapper for echo that includes the function name
7376
# args:
7477
# 1) msg - string
75-
# 2) stack_level - int; optional
78+
# 2) stack_level - int
79+
# * optional
7680
# * defaults to the function at the bottom of the call stack
7781
log() {
7882
local -r msg="${1:-"log message is empty"}"
@@ -95,8 +99,8 @@ abort() {
9599
# args:
96100
# 1) filename - string
97101
# 2) file_contents - string
98-
# 3) clobber - boolean; optional
99-
# * defaults to false
102+
# 3) clobber - boolean
103+
# * Optional; defaults to false
100104
write_file() {
101105
local -n filename="$1"
102106
local -n file_contents="$2"
@@ -158,11 +162,11 @@ verify_role() {
158162
# get_keyvault_suffix()
159163
#
160164
# args:
161-
# 1) rl - nameref, string;
165+
# 1) rl - nameref, string
162166
# * role to get short role for
163-
# 2) kv_suffix - nameref, string;
167+
# 2) kv_suffix - nameref, string
164168
# * short role will be assigned to this nameref
165-
# 3) sec_prefix - nameref, string;
169+
# 3) sec_prefix - nameref, string
166170
# * keyvault certificate prefix will be assigned to this nameref
167171
get_keyvault_suffix() {
168172
local -n rl="$1"
@@ -182,7 +186,7 @@ get_keyvault_suffix() {
182186
sec_prefix="$role_rp"
183187
;;
184188
*)
185-
abort "unkown role $rl"
189+
abort "unknown role $rl"
186190
;;
187191
esac
188192
}

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)