Skip to content

Commit

Permalink
refactor: reduce check if args is empty/null and don't substituted it…
Browse files Browse the repository at this point in the history
… removing empty string being produced
  • Loading branch information
tomowatt committed May 30, 2024
1 parent 7b44125 commit 1a5aa93
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions hooks/post-command
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,6 @@ if [[ -n "${PARAMETER_FILES}" ]]; then
args+=("--parameter-files=${PARAMETER_FILES}")
fi

# check if the args array is not empty and expand parameters into string
# else use an empty string, to avoid 'unbound variable' on expansion of arrays if empty

cmd_args=""
if [[ "${#args[@]}" -ne 0 ]]; then
cmd_args+="${args[*]}"
fi

# Get the architecture of the machine for running the container image due to "latest" not being multi-architecture
# Available images: `latest`, `latest-amd64` and `latest-arm64`
# therefore default case will use `latest`
Expand Down Expand Up @@ -146,7 +138,7 @@ iacScan() {
-f human \
-o /scan/result/output,human \
--name "$BUILDKITE_JOB_ID" \
--path "/scan/$FILE_PATH" "${cmd_args}"
--path "/scan/$FILE_PATH" ${args:+"${args[@]}"}

exit_code="$?"
case $exit_code in
Expand Down

0 comments on commit 1a5aa93

Please sign in to comment.