Skip to content

Commit dd78ea8

Browse files
authored
Refactor: replace mapfile with while loop for file list population in validation scripts (#5)
* patch: update pre-commit hook stages for flux validation script * refactor: replace mapfile with while loop for file list population in validation scripts * fix: update pre-commit hook stages for eslint and sample file generation scripts
1 parent 4ab2077 commit dd78ea8

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

.pre-commit-hooks.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
description: "A script to validate eslint rules on Javascript and Typescript files."
1111
entry: ./scripts/validate-eslint.sh
1212
language: script
13-
stages: [commit]
13+
stages: ["pre-commit"]
1414
- id: run-samplr
1515
name: generate sample .env files
1616
description: "A script to generate sample files."
1717
entry: ./scripts/samplr/run-samplr.sh
1818
language: script
19-
stages: [commit]
19+
stages: ["pre-commit"]

scripts/validate-flux.sh

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,11 @@ print_summary() {
227227
# validate_files
228228

229229
validate_files() {
230-
mapfile -t fileList < <(get_git_diff_files "./" ".*\.ya\?ml$")
230+
fileList=()
231+
while IFS= read -r file; do
232+
fileList+=("$file")
233+
done < <(get_git_diff_files "./" ".*\.ya\?ml$")
234+
231235
if [ ${#fileList[@]} -eq 0 ]; then
232236
echo "No files to validate"
233237
exit 0
@@ -257,7 +261,12 @@ validate_clusters() {
257261

258262
echo -n "VALIDATING CLUSTERS ..."
259263
[[ $DEBUG -eq 1 ]] && echo -e "\n${CYAN}INFO${NC} - Validating clusters"
260-
mapfile -t clusterList < <(get_git_diff_files "./clusters" ".*\.ya\?ml$")
264+
265+
clusterList=()
266+
while IFS= read -r file; do
267+
clusterList+=("$file")
268+
done < <(get_git_diff_files "./clusters" ".*\.ya\?ml$")
269+
261270
for file in "${clusterList[@]}"; do
262271
local failed_checks
263272
[[ $DEBUG -eq 1 ]] && echo -e "${CYAN}INFO${NC} - Validating ${file}"
@@ -290,7 +299,12 @@ validate_clusters() {
290299
validate_kustomize() {
291300
echo -n "VALIDATING KUSTOMIZE ..."
292301
[[ $DEBUG -eq 1 ]] && echo -e "\n${CYAN}INFO${NC} - Validating kustomize overlays"
293-
mapfile -t kustomizeList < <(get_git_diff_files "./" "$kustomize_config")
302+
303+
kustomizeList=()
304+
while IFS= read -r file; do
305+
kustomizeList+=("$file")
306+
done < <(get_git_diff_files "./" "$kustomize_config")
307+
294308
for file in "${kustomizeList[@]}"; do
295309
local failed_checks=0
296310
if [[ "$file" == *"$kustomize_config" ]]; then

0 commit comments

Comments
 (0)