Skip to content

Commit a7dfe3c

Browse files
chore: Improve comments
1 parent 8000c6d commit a7dfe3c

1 file changed

Lines changed: 15 additions & 11 deletions

File tree

rust/operator-binary/src/controller/build/scripts/update-security-config.sh

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,14 @@ function warn () {
7272
log WARN "$message"
7373
}
7474

75+
# Return the configuration file in SECURITY_CONFIG_DIR for the given file type
7576
function config_file () {
7677
filetype="$1"
7778

7879
echo "$SECURITY_CONFIG_DIR/${CONFIG_FILENAME[$filetype]}"
7980
}
8081

81-
# Create link for every configuration file in SECURITY_CONFIG_DIR
82+
# Create a link for every configuration file in SECURITY_CONFIG_DIR
8283
function symlink_config_files () {
8384
for filetype in "${CONFIG_FILETYPES[@]}"
8485
do
@@ -88,6 +89,7 @@ function symlink_config_files () {
8889
done
8990
}
9091

92+
# Initialize the variable managed_filetypes
9193
function initialize_managed_config_filetypes () {
9294
for filetype in "${CONFIG_FILETYPES[@]}"
9395
do
@@ -102,6 +104,7 @@ function initialize_managed_config_filetypes () {
102104
done
103105
}
104106

107+
# Calculate the hashes of the managed configuration files
105108
function calculate_config_hashes () {
106109
for filetype in "${managed_filetypes[@]}"
107110
do
@@ -124,9 +127,8 @@ function wait_seconds_or_shutdown () {
124127
"$VECTOR_CONTROL_DIR"
125128
fi
126129

127-
# Only the file named "shutdown" should be created in
128-
# VECTOR_CONTROL_DIR. If another file is created instead, this
129-
# function will return early; this is acceptable and has no adverse
130+
# Only the file named "shutdown" should be created in VECTOR_CONTROL_DIR. If another file is
131+
# created instead, this function will return early; this is acceptable and has no adverse
130132
# effects.
131133
if test -e "$VECTOR_CONTROL_DIR/shutdown"
132134
then
@@ -159,6 +161,7 @@ function wait_for_shutdown () {
159161
exit 0
160162
}
161163

164+
# Return if this pod is responsible for managing the security configuration or wait for shutdown
162165
function check_pod () {
163166
POD_INDEX="${POD_NAME##*-}"
164167

@@ -176,6 +179,7 @@ function check_pod () {
176179
fi
177180
}
178181

182+
# Initialize the security index with all (managed and unmanaged) configuration files
179183
function initialize_security_index() {
180184
info "Initialize the security index."
181185

@@ -193,7 +197,8 @@ function initialize_security_index() {
193197
done
194198
}
195199

196-
function update_config () {
200+
# Update the security index with the managed configuration files
201+
function update_security_index () {
197202
last_applied_config_hashes=$(calculate_config_hashes)
198203

199204
for filetype in "${managed_filetypes[@]}"
@@ -216,7 +221,8 @@ function update_config () {
216221
done
217222
}
218223

219-
function update_security_index() {
224+
# Initialize or update the security index
225+
function apply_configuration_files() {
220226
info "Check the status of the security index."
221227

222228
STATUS_CODE=$(curl \
@@ -230,8 +236,7 @@ function update_security_index() {
230236
if test "$STATUS_CODE" = "200"
231237
then
232238
info "The security index is already initialized."
233-
234-
update_config
239+
update_security_index
235240
elif test "$STATUS_CODE" = "404"
236241
then
237242
initialize_security_index
@@ -242,8 +247,7 @@ function update_security_index() {
242247
fi
243248
}
244249

245-
# Ensure that VECTOR_CONTROL_DIR exists, so that calls to inotifywait do not
246-
# fail.
250+
# Ensure that VECTOR_CONTROL_DIR exists, so that calls to inotifywait do not fail
247251
mkdir --parents "$VECTOR_CONTROL_DIR"
248252

249253
check_pod
@@ -252,6 +256,6 @@ initialize_managed_config_filetypes
252256

253257
while true
254258
do
255-
update_security_index
259+
apply_configuration_files
256260
wait_for_configuration_changes_or_shutdown
257261
done

0 commit comments

Comments
 (0)