From 1ee932a538b7daddcbe2e1c3450604085b634274 Mon Sep 17 00:00:00 2001 From: Luke Exton Date: Fri, 28 Apr 2023 01:59:13 -0400 Subject: [PATCH 1/3] (fix) TFLint: cache failure output --- hooks/terraform_tflint.sh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/hooks/terraform_tflint.sh b/hooks/terraform_tflint.sh index d488cb734..bf57e72eb 100755 --- a/hooks/terraform_tflint.sh +++ b/hooks/terraform_tflint.sh @@ -50,16 +50,15 @@ function per_dir_hook_unique_part { shift local -a -r args=("$@") - # Print checked PATH **only** if TFLint have any messages - # shellcheck disable=SC2091,SC2068 # Suppress error output - $(tflint ${args[@]} 2>&1) 2> /dev/null || { - common::colorify "yellow" "TFLint in $dir_path/:" + COMMAND_OUTPUT=$({ tflint "${args[@]}"; } 2>&1) + local exit_code=$? - tflint "${args[@]}" - } + if [ $exit_code -ne 0 ]; then + common::colorify "yellow" "TFLint in $dir_path/:" + echo "$COMMAND_OUTPUT" + fi # return exit code to common::per_dir_hook - local exit_code=$? return $exit_code } From cdb22b7c1ce6a5326ac839244c54ae48b4e264e7 Mon Sep 17 00:00:00 2001 From: Maksym Vlasov Date: Fri, 28 Apr 2023 15:41:23 +0300 Subject: [PATCH 2/3] Apply suggestions from code review --- hooks/terraform_tflint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hooks/terraform_tflint.sh b/hooks/terraform_tflint.sh index bf57e72eb..d6251db9a 100755 --- a/hooks/terraform_tflint.sh +++ b/hooks/terraform_tflint.sh @@ -50,12 +50,12 @@ function per_dir_hook_unique_part { shift local -a -r args=("$@") - COMMAND_OUTPUT=$({ tflint "${args[@]}"; } 2>&1) + TFLINT_OUTPUT=$({ tflint "${args[@]}"; } 2>&1) local exit_code=$? if [ $exit_code -ne 0 ]; then common::colorify "yellow" "TFLint in $dir_path/:" - echo "$COMMAND_OUTPUT" + echo "$TFLINT_OUTPUT" fi # return exit code to common::per_dir_hook From 0ce11dfad2152c7cd4a893a9c222d80f2b0daf7f Mon Sep 17 00:00:00 2001 From: Maksym Vlasov Date: Fri, 28 Apr 2023 18:08:25 +0300 Subject: [PATCH 3/3] Apply suggestions from code review --- hooks/terraform_tflint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/terraform_tflint.sh b/hooks/terraform_tflint.sh index d6251db9a..1a74ce344 100755 --- a/hooks/terraform_tflint.sh +++ b/hooks/terraform_tflint.sh @@ -50,7 +50,7 @@ function per_dir_hook_unique_part { shift local -a -r args=("$@") - TFLINT_OUTPUT=$({ tflint "${args[@]}"; } 2>&1) + TFLINT_OUTPUT=$(tflint "${args[@]}" 2>&1) local exit_code=$? if [ $exit_code -ne 0 ]; then