From e3946682f84530757a680052c786d52b767792a7 Mon Sep 17 00:00:00 2001 From: MaxymVlasov Date: Thu, 6 Jan 2022 20:06:29 +0200 Subject: [PATCH 1/4] Document functions https://google.github.io/styleguide/shellguide.html#function-comments --- hooks/_common.sh | 39 ++++++++++++++++++++++++++++++- hooks/infracost_breakdown.sh | 13 +++++++++++ hooks/terraform_docs.sh | 26 +++++++++++++++++++++ hooks/terraform_fmt.sh | 24 ++++++++++++++++++- hooks/terraform_providers_lock.sh | 11 ++++++++- hooks/terraform_tflint.sh | 11 ++++++++- hooks/terraform_tfsec.sh | 11 ++++++++- hooks/terraform_validate.sh | 31 ++++++++++++++++++++++++ hooks/terragrunt_fmt.sh | 11 ++++++++- hooks/terragrunt_validate.sh | 11 ++++++++- hooks/terrascan.sh | 11 ++++++++- 11 files changed, 191 insertions(+), 8 deletions(-) diff --git a/hooks/_common.sh b/hooks/_common.sh index a835b5d18..7c4261959 100644 --- a/hooks/_common.sh +++ b/hooks/_common.sh @@ -1,13 +1,29 @@ #!/usr/bin/env bash set -eo pipefail +####################################################################### +# Init arguments parser +# Arguments: +# script_dir - absolute path to hook dir location +####################################################################### function common::initialize { local -r script_dir=$1 # source getopt function - # shellcheck source=lib_getopt + # shellcheck source=../lib_getopt . "$script_dir/../lib_getopt" } +####################################################################### +# Parse provided to script args and filenames and populate each to +# appropriate Global +# Globals (init and populate): +# ARGS (array) arguments that configure wrapped tool behavior +# HOOK_CONFIG (array) arguments that configure hook behavior +# FILES (array) filenames to check +# Arguments: +# $@ (array) all specified in `hooks.[].args` in +# `.pre-commit-config.yaml` and filenames. +####################################################################### function common::parse_cmdline { # common global arrays. # Populated via `common::parse_cmdline` and can be used inside hooks' functions @@ -39,6 +55,17 @@ function common::parse_cmdline { done } +####################################################################### +# Hook execution boilerplate logic that common for hooks, that run on +# per dir basis. +# 1. Because hook run on whole dir, reduce file paths to uniq dir paths +# 2. Run for each dir `per_dir_hook_unique_part`, on all paths +# 2.1. If at least 1 check failed - change exit code to non-zero +# 3. Complete hook execution and return exit code +# Arguments: +# args (string with array) arguments that configure wrapped tool behavior +# files (array) filenames to check +####################################################################### function common::per_dir_hook { local -r args="$1" shift 1 @@ -82,6 +109,16 @@ function common::per_dir_hook { exit $final_exit_code } +####################################################################### +# Colorify provided string and print out it to stdout +# Environment variables: +# PRE_COMMIT_COLOR (string) If set to `never` - do not colorify string +# Arguments: +# COLOR (string) Color name that will be used for colorify +# TEXT (string) +# Outputs: +# Print out provided text to stdout +####################################################################### function common::colorify { # shellcheck disable=SC2034 local -r red="\e[0m\e[31m" diff --git a/hooks/infracost_breakdown.sh b/hooks/infracost_breakdown.sh index 911bcacaf..e13c98930 100755 --- a/hooks/infracost_breakdown.sh +++ b/hooks/infracost_breakdown.sh @@ -13,6 +13,19 @@ function main { infracost_breakdown_ "${HOOK_CONFIG[*]}" "${ARGS[*]}" } +####################################################################### +# Wrapper around `infracost breakdown` tool that check and compare +# infra cost by provided hook_config +# Environment variables: +# PRE_COMMIT_COLOR (string) If set to `never` - force tool output to +# plain text +# Arguments: +# hook_config (string with array) arguments that configure hook behavior +# args (string with array) arguments that configure wrapped tool behavior +# Outputs: +# Print out hook checks status (Passed/Failed), total monthly cost and +# diff, summary about infracost check (non-supported resources etc.) +####################################################################### function infracost_breakdown_ { local -r hook_config="$1" local args diff --git a/hooks/terraform_docs.sh b/hooks/terraform_docs.sh index b1757c343..2737f4940 100755 --- a/hooks/terraform_docs.sh +++ b/hooks/terraform_docs.sh @@ -17,6 +17,14 @@ function main { terraform_docs_ "${HOOK_CONFIG[*]}" "$ARGS" "${FILES[@]}" } +####################################################################### +# Functions that prepares hacks for old versions of `terraform`` and +# `terraform-docs` that them call `terraform_docs` +# Arguments: +# hook_config (string with array) arguments that configure hook behavior +# args (string with array) arguments that configure wrapped tool behavior +# files (array) filenames to check +####################################################################### function terraform_docs_ { local -r hook_config="$1" local -r args="$2" @@ -61,6 +69,18 @@ function terraform_docs_ { fi } +####################################################################### +# Wrapper around `terraform-docs` tool that check and change/create +# (depends on on provided hook_config) terraform documentation in +# markdown format +# Arguments: +# terraform_docs_awk_file (string) filename where awk hack for old +# `terraform-docs` populated. Needed for tf 0.12+. +# Hack skipped when `terraform_docs_awk_file == "0"` +# hook_config (string with array) arguments that configure hook behavior +# args (string with array) arguments that configure wrapped tool behavior +# files (array) filenames to check +####################################################################### function terraform_docs { local -r terraform_docs_awk_file="$1" local -r hook_config="$2" @@ -183,6 +203,12 @@ function terraform_docs { done } +####################################################################### +# Functions that create file with awk hacks for old versions of +# `terraform-docs` +# Arguments: +# output_file (string) filename where hack will be written +####################################################################### function terraform_docs_awk { local -r output_file=$1 diff --git a/hooks/terraform_fmt.sh b/hooks/terraform_fmt.sh index 9657af2dc..a37e2c5c8 100755 --- a/hooks/terraform_fmt.sh +++ b/hooks/terraform_fmt.sh @@ -13,6 +13,19 @@ function main { terraform_fmt_ "${ARGS[*]}" "${FILES[@]}" } +####################################################################### +# Hook execution boilerplate logic that common for hooks, that run on +# per dir basis. Little bit extended than `common::per_dir_hook` +# 1. Because hook run on whole dir, reduce file paths to uniq dir paths +# (uniq) 1.1. Collect paths to *.tfvars files to separate variable +# 2. Run for each dir `per_dir_hook_unique_part`, on all paths +# (uniq) 2.1. Run `terraform fmt` on each *.tfvars file +# 2.2. If at least 1 check failed - change exit code to non-zero +# 3. Complete hook execution and return exit code +# Arguments: +# args (string with array) arguments that configure wrapped tool behavior +# files (array) filenames to check +####################################################################### function terraform_fmt_ { local -r args="$1" shift 1 @@ -72,8 +85,17 @@ function terraform_fmt_ { } +####################################################################### +# Uniq part of `common::per_dir_hook`. That function executes in loop +# on each provided dir path. Run wrapped tool with specified arguments +# Arguments: +# args (string with array) arguments that configure wrapped tool behavior +# dir_path (string) PATH to dir from git repo root. Can be used in +# error logging +# Outputs: +# If failed - print out hook checks status +####################################################################### function per_dir_hook_unique_part { - # common logic located in common::per_dir_hook local -r args="$1" local -r dir_path="$2" diff --git a/hooks/terraform_providers_lock.sh b/hooks/terraform_providers_lock.sh index b5fb7ec31..d8b0bd745 100755 --- a/hooks/terraform_providers_lock.sh +++ b/hooks/terraform_providers_lock.sh @@ -14,8 +14,17 @@ function main { common::per_dir_hook "${ARGS[*]}" "${FILES[@]}" } +####################################################################### +# Uniq part of `common::per_dir_hook`. That function executes in loop +# on each provided dir path. Run wrapped tool with specified arguments +# Arguments: +# args (string with array) arguments that configure wrapped tool behavior +# dir_path (string) PATH to dir from git repo root. Can be used in +# error logging +# Outputs: +# If failed - print out hook checks status +####################################################################### function per_dir_hook_unique_part { - # common logic located in common::per_dir_hook local -r args="$1" local -r dir_path="$2" diff --git a/hooks/terraform_tflint.sh b/hooks/terraform_tflint.sh index 6d154c50b..cc0f39b0b 100755 --- a/hooks/terraform_tflint.sh +++ b/hooks/terraform_tflint.sh @@ -17,8 +17,17 @@ function main { common::per_dir_hook "$ARGS" "${FILES[@]}" } +####################################################################### +# Uniq part of `common::per_dir_hook`. That function executes in loop +# on each provided dir path. Run wrapped tool with specified arguments +# Arguments: +# args (string with array) arguments that configure wrapped tool behavior +# dir_path (string) PATH to dir from git repo root. Can be used in +# error logging +# Outputs: +# If failed - print out hook checks status +####################################################################### function per_dir_hook_unique_part { - # common logic located in common::per_dir_hook local -r args="$1" local -r dir_path="$2" diff --git a/hooks/terraform_tfsec.sh b/hooks/terraform_tfsec.sh index 284106bfa..204af5f8b 100755 --- a/hooks/terraform_tfsec.sh +++ b/hooks/terraform_tfsec.sh @@ -16,8 +16,17 @@ function main { common::per_dir_hook "$ARGS" "${FILES[@]}" } +####################################################################### +# Uniq part of `common::per_dir_hook`. That function executes in loop +# on each provided dir path. Run wrapped tool with specified arguments +# Arguments: +# args (string with array) arguments that configure wrapped tool behavior +# dir_path (string) PATH to dir from git repo root. Can be used in +# error logging +# Outputs: +# If failed - print out hook checks status +####################################################################### function per_dir_hook_unique_part { - # common logic located in common::per_dir_hook local -r args="$1" # shellcheck disable=SC2034 # Unused var. local -r dir_path="$2" diff --git a/hooks/terraform_validate.sh b/hooks/terraform_validate.sh index 4cb50c946..54a360011 100755 --- a/hooks/terraform_validate.sh +++ b/hooks/terraform_validate.sh @@ -15,6 +15,19 @@ function main { terraform_validate_ } +####################################################################### +# Parse provided to script args and filenames and populate each to +# appropriate Global +# Globals (init and populate): +# ARGS (array) arguments that configure wrapped tool behavior +# INIT_ARGS (array) arguments for `terraform init` command` +# ENVS (array) environment variables that will be used with +# `terraform` commands +# FILES (array) filenames to check +# Arguments: +# $@ (array) all specified in `hooks.[].args` in +# `.pre-commit-config.yaml` and filenames. +####################################################################### function parse_cmdline_ { declare argv argv=$(getopt -o e:i:a: --long envs:,init-args:,args: -- "$@") || return @@ -46,6 +59,24 @@ function parse_cmdline_ { done } +####################################################################### +# Wrapper around `terraform validate` tool that check is code are valid +# 1. Export provided envs to environment +# 2. Because hook run on whole dir, reduce file paths to uniq dir paths +# 3. In each dir that have *.tf files: +# 3.1. Check is `.terraform` exist and if not - run `terraform init` +# 3.2. Run `terraform validate` +# 3.3. If at least 1 check failed - change exit code to non-zero +# 4. Complete hook execution and return exit code +# Globals: +# ARGS (array) arguments that configure wrapped tool behavior +# INIT_ARGS (array) arguments for `terraform init` command` +# ENVS (array) environment variables that will be used with +# `terraform` commands +# FILES (array) filenames to check +# Outputs: +# If failed - print out hook checks status +####################################################################### function terraform_validate_ { # Setup environment variables diff --git a/hooks/terragrunt_fmt.sh b/hooks/terragrunt_fmt.sh index d91cc9fcc..917d243f6 100755 --- a/hooks/terragrunt_fmt.sh +++ b/hooks/terragrunt_fmt.sh @@ -13,8 +13,17 @@ function main { common::per_dir_hook "${ARGS[*]}" "${FILES[@]}" } +####################################################################### +# Uniq part of `common::per_dir_hook`. That function executes in loop +# on each provided dir path. Run wrapped tool with specified arguments +# Arguments: +# args (string with array) arguments that configure wrapped tool behavior +# dir_path (string) PATH to dir from git repo root. Can be used in +# error logging +# Outputs: +# If failed - print out hook checks status +####################################################################### function per_dir_hook_unique_part { - # common logic located in common::per_dir_hook local -r args="$1" # shellcheck disable=SC2034 # Unused var. local -r dir_path="$2" diff --git a/hooks/terragrunt_validate.sh b/hooks/terragrunt_validate.sh index 96fe3963d..192ebd18a 100755 --- a/hooks/terragrunt_validate.sh +++ b/hooks/terragrunt_validate.sh @@ -13,8 +13,17 @@ function main { common::per_dir_hook "${ARGS[*]}" "${FILES[@]}" } +####################################################################### +# Uniq part of `common::per_dir_hook`. That function executes in loop +# on each provided dir path. Run wrapped tool with specified arguments +# Arguments: +# args (string with array) arguments that configure wrapped tool behavior +# dir_path (string) PATH to dir from git repo root. Can be used in +# error logging +# Outputs: +# If failed - print out hook checks status +####################################################################### function per_dir_hook_unique_part { - # common logic located in common::per_dir_hook local -r args="$1" # shellcheck disable=SC2034 # Unused var. local -r dir_path="$2" diff --git a/hooks/terrascan.sh b/hooks/terrascan.sh index 3bf78c7d2..07b14e837 100755 --- a/hooks/terrascan.sh +++ b/hooks/terrascan.sh @@ -13,8 +13,17 @@ function main { common::per_dir_hook "${ARGS[*]}" "${FILES[@]}" } +####################################################################### +# Uniq part of `common::per_dir_hook`. That function executes in loop +# on each provided dir path. Run wrapped tool with specified arguments +# Arguments: +# args (string with array) arguments that configure wrapped tool behavior +# dir_path (string) PATH to dir from git repo root. Can be used in +# error logging +# Outputs: +# If failed - print out hook checks status +####################################################################### function per_dir_hook_unique_part { - # common logic located in common::per_dir_hook local -r args="$1" # shellcheck disable=SC2034 # Unused var. local -r dir_path="$2" From 76cf7c74581e370401f0ec6e4b7d930b0ea0b8f4 Mon Sep 17 00:00:00 2001 From: Maksym Vlasov Date: Fri, 7 Jan 2022 15:15:58 +0200 Subject: [PATCH 2/4] Apply suggestions from code review Co-authored-by: George L. Yermulnik --- hooks/_common.sh | 16 ++++++++-------- hooks/infracost_breakdown.sh | 7 +++---- hooks/terraform_docs.sh | 6 +++--- hooks/terraform_fmt.sh | 12 ++++++------ hooks/terraform_providers_lock.sh | 2 +- hooks/terraform_tflint.sh | 2 +- hooks/terraform_tfsec.sh | 2 +- hooks/terraform_validate.sh | 10 +++++----- hooks/terragrunt_fmt.sh | 2 +- hooks/terragrunt_validate.sh | 2 +- hooks/terrascan.sh | 2 +- 11 files changed, 31 insertions(+), 32 deletions(-) diff --git a/hooks/_common.sh b/hooks/_common.sh index 7c4261959..ae221b4de 100644 --- a/hooks/_common.sh +++ b/hooks/_common.sh @@ -14,8 +14,8 @@ function common::initialize { } ####################################################################### -# Parse provided to script args and filenames and populate each to -# appropriate Global +# Parse args and filenames passed to script and populate respective +# global variables with appropriate values # Globals (init and populate): # ARGS (array) arguments that configure wrapped tool behavior # HOOK_CONFIG (array) arguments that configure hook behavior @@ -56,9 +56,9 @@ function common::parse_cmdline { } ####################################################################### -# Hook execution boilerplate logic that common for hooks, that run on -# per dir basis. -# 1. Because hook run on whole dir, reduce file paths to uniq dir paths +# Hook execution boilerplate logic which is common to hooks, that run +# on per dir basis. +# 1. Because hook runs on whole dir, reduce file paths to uniq dir paths # 2. Run for each dir `per_dir_hook_unique_part`, on all paths # 2.1. If at least 1 check failed - change exit code to non-zero # 3. Complete hook execution and return exit code @@ -110,11 +110,11 @@ function common::per_dir_hook { } ####################################################################### -# Colorify provided string and print out it to stdout +# Colorize provided string and print it out to stdout # Environment variables: -# PRE_COMMIT_COLOR (string) If set to `never` - do not colorify string +# PRE_COMMIT_COLOR (string) If set to `never` - do not colorize output # Arguments: -# COLOR (string) Color name that will be used for colorify +# COLOR (string) Color name that will be used to colorize # TEXT (string) # Outputs: # Print out provided text to stdout diff --git a/hooks/infracost_breakdown.sh b/hooks/infracost_breakdown.sh index e13c98930..267971d65 100755 --- a/hooks/infracost_breakdown.sh +++ b/hooks/infracost_breakdown.sh @@ -14,11 +14,10 @@ function main { } ####################################################################### -# Wrapper around `infracost breakdown` tool that check and compare -# infra cost by provided hook_config +# Wrapper around `infracost breakdown` tool which checks and compares +# infra cost based on provided hook_config # Environment variables: -# PRE_COMMIT_COLOR (string) If set to `never` - force tool output to -# plain text +# PRE_COMMIT_COLOR (string) If set to `never` - do not colorize output # Arguments: # hook_config (string with array) arguments that configure hook behavior # args (string with array) arguments that configure wrapped tool behavior diff --git a/hooks/terraform_docs.sh b/hooks/terraform_docs.sh index 2737f4940..05b34edcc 100755 --- a/hooks/terraform_docs.sh +++ b/hooks/terraform_docs.sh @@ -18,7 +18,7 @@ function main { } ####################################################################### -# Functions that prepares hacks for old versions of `terraform`` and +# Function which prepares hacks for old versions of `terraform` and # `terraform-docs` that them call `terraform_docs` # Arguments: # hook_config (string with array) arguments that configure hook behavior @@ -204,10 +204,10 @@ function terraform_docs { } ####################################################################### -# Functions that create file with awk hacks for old versions of +# Function which creates file with `awk` hacks for old versions of # `terraform-docs` # Arguments: -# output_file (string) filename where hack will be written +# output_file (string) filename where hack will be written to ####################################################################### function terraform_docs_awk { local -r output_file=$1 diff --git a/hooks/terraform_fmt.sh b/hooks/terraform_fmt.sh index a37e2c5c8..eaa72556a 100755 --- a/hooks/terraform_fmt.sh +++ b/hooks/terraform_fmt.sh @@ -14,12 +14,12 @@ function main { } ####################################################################### -# Hook execution boilerplate logic that common for hooks, that run on -# per dir basis. Little bit extended than `common::per_dir_hook` -# 1. Because hook run on whole dir, reduce file paths to uniq dir paths -# (uniq) 1.1. Collect paths to *.tfvars files to separate variable +# Hook execution boilerplate logic which is common to hooks, that run +# on per dir basis. Little bit extended than `common::per_dir_hook` +# 1. Because hook runs on whole dir, reduce file paths to uniq dir paths +# (unique) 1.1. Collect paths to *.tfvars files in a separate variable # 2. Run for each dir `per_dir_hook_unique_part`, on all paths -# (uniq) 2.1. Run `terraform fmt` on each *.tfvars file +# (unique) 2.1. Run `terraform fmt` on each *.tfvars file # 2.2. If at least 1 check failed - change exit code to non-zero # 3. Complete hook execution and return exit code # Arguments: @@ -86,7 +86,7 @@ function terraform_fmt_ { } ####################################################################### -# Uniq part of `common::per_dir_hook`. That function executes in loop +# Unique part of `common::per_dir_hook`. The function is executed in loop # on each provided dir path. Run wrapped tool with specified arguments # Arguments: # args (string with array) arguments that configure wrapped tool behavior diff --git a/hooks/terraform_providers_lock.sh b/hooks/terraform_providers_lock.sh index d8b0bd745..a63e76c80 100755 --- a/hooks/terraform_providers_lock.sh +++ b/hooks/terraform_providers_lock.sh @@ -15,7 +15,7 @@ function main { } ####################################################################### -# Uniq part of `common::per_dir_hook`. That function executes in loop +# Unique part of `common::per_dir_hook`. The function is executed in loop # on each provided dir path. Run wrapped tool with specified arguments # Arguments: # args (string with array) arguments that configure wrapped tool behavior diff --git a/hooks/terraform_tflint.sh b/hooks/terraform_tflint.sh index cc0f39b0b..b8ff08458 100755 --- a/hooks/terraform_tflint.sh +++ b/hooks/terraform_tflint.sh @@ -18,7 +18,7 @@ function main { } ####################################################################### -# Uniq part of `common::per_dir_hook`. That function executes in loop +# Unique part of `common::per_dir_hook`. The function is executed in loop # on each provided dir path. Run wrapped tool with specified arguments # Arguments: # args (string with array) arguments that configure wrapped tool behavior diff --git a/hooks/terraform_tfsec.sh b/hooks/terraform_tfsec.sh index 204af5f8b..a7747c7a7 100755 --- a/hooks/terraform_tfsec.sh +++ b/hooks/terraform_tfsec.sh @@ -17,7 +17,7 @@ function main { } ####################################################################### -# Uniq part of `common::per_dir_hook`. That function executes in loop +# Unique part of `common::per_dir_hook`. The function is executed in loop # on each provided dir path. Run wrapped tool with specified arguments # Arguments: # args (string with array) arguments that configure wrapped tool behavior diff --git a/hooks/terraform_validate.sh b/hooks/terraform_validate.sh index 54a360011..9af292b9a 100755 --- a/hooks/terraform_validate.sh +++ b/hooks/terraform_validate.sh @@ -16,11 +16,11 @@ function main { } ####################################################################### -# Parse provided to script args and filenames and populate each to -# appropriate Global +# Parse args and filenames passed to script and populate respective +# global variables with appropriate values # Globals (init and populate): # ARGS (array) arguments that configure wrapped tool behavior -# INIT_ARGS (array) arguments for `terraform init` command` +# INIT_ARGS (array) arguments to `terraform init` command # ENVS (array) environment variables that will be used with # `terraform` commands # FILES (array) filenames to check @@ -62,9 +62,9 @@ function parse_cmdline_ { ####################################################################### # Wrapper around `terraform validate` tool that check is code are valid # 1. Export provided envs to environment -# 2. Because hook run on whole dir, reduce file paths to uniq dir paths +# 2. Because hook runs on whole dir, reduce file paths to uniq dir paths # 3. In each dir that have *.tf files: -# 3.1. Check is `.terraform` exist and if not - run `terraform init` +# 3.1. Check if `.terraform` dir exists and if not - run `terraform init` # 3.2. Run `terraform validate` # 3.3. If at least 1 check failed - change exit code to non-zero # 4. Complete hook execution and return exit code diff --git a/hooks/terragrunt_fmt.sh b/hooks/terragrunt_fmt.sh index 917d243f6..2fb7d3c10 100755 --- a/hooks/terragrunt_fmt.sh +++ b/hooks/terragrunt_fmt.sh @@ -14,7 +14,7 @@ function main { } ####################################################################### -# Uniq part of `common::per_dir_hook`. That function executes in loop +# Unique part of `common::per_dir_hook`. The function is executed in loop # on each provided dir path. Run wrapped tool with specified arguments # Arguments: # args (string with array) arguments that configure wrapped tool behavior diff --git a/hooks/terragrunt_validate.sh b/hooks/terragrunt_validate.sh index 192ebd18a..50b0a16ab 100755 --- a/hooks/terragrunt_validate.sh +++ b/hooks/terragrunt_validate.sh @@ -14,7 +14,7 @@ function main { } ####################################################################### -# Uniq part of `common::per_dir_hook`. That function executes in loop +# Unique part of `common::per_dir_hook`. The function is executed in loop # on each provided dir path. Run wrapped tool with specified arguments # Arguments: # args (string with array) arguments that configure wrapped tool behavior diff --git a/hooks/terrascan.sh b/hooks/terrascan.sh index 07b14e837..07401f8b5 100755 --- a/hooks/terrascan.sh +++ b/hooks/terrascan.sh @@ -14,7 +14,7 @@ function main { } ####################################################################### -# Uniq part of `common::per_dir_hook`. That function executes in loop +# Unique part of `common::per_dir_hook`. The function is executed in loop # on each provided dir path. Run wrapped tool with specified arguments # Arguments: # args (string with array) arguments that configure wrapped tool behavior From 9f6b0e135e76d02a89351467a619a1522f5cf429 Mon Sep 17 00:00:00 2001 From: Maksym Vlasov Date: Fri, 7 Jan 2022 15:44:15 +0200 Subject: [PATCH 3/4] Apply suggestions from code review Co-authored-by: George L. Yermulnik --- hooks/terraform_docs.sh | 4 ++-- hooks/terraform_fmt.sh | 4 ++-- hooks/terraform_providers_lock.sh | 4 ++-- hooks/terraform_tflint.sh | 4 ++-- hooks/terraform_tfsec.sh | 4 ++-- hooks/terragrunt_fmt.sh | 4 ++-- hooks/terragrunt_validate.sh | 4 ++-- hooks/terrascan.sh | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/hooks/terraform_docs.sh b/hooks/terraform_docs.sh index 05b34edcc..e71aae474 100755 --- a/hooks/terraform_docs.sh +++ b/hooks/terraform_docs.sh @@ -71,11 +71,11 @@ function terraform_docs_ { ####################################################################### # Wrapper around `terraform-docs` tool that check and change/create -# (depends on on provided hook_config) terraform documentation in +# (depends on provided hook_config) terraform documentation in # markdown format # Arguments: # terraform_docs_awk_file (string) filename where awk hack for old -# `terraform-docs` populated. Needed for tf 0.12+. +# `terraform-docs` was written. Needed for TF 0.12+. # Hack skipped when `terraform_docs_awk_file == "0"` # hook_config (string with array) arguments that configure hook behavior # args (string with array) arguments that configure wrapped tool behavior diff --git a/hooks/terraform_fmt.sh b/hooks/terraform_fmt.sh index eaa72556a..84746a62b 100755 --- a/hooks/terraform_fmt.sh +++ b/hooks/terraform_fmt.sh @@ -90,8 +90,8 @@ function terraform_fmt_ { # on each provided dir path. Run wrapped tool with specified arguments # Arguments: # args (string with array) arguments that configure wrapped tool behavior -# dir_path (string) PATH to dir from git repo root. Can be used in -# error logging +# dir_path (string) PATH to dir relative to git repo root. +# Can be used in error logging # Outputs: # If failed - print out hook checks status ####################################################################### diff --git a/hooks/terraform_providers_lock.sh b/hooks/terraform_providers_lock.sh index a63e76c80..510ff3b4d 100755 --- a/hooks/terraform_providers_lock.sh +++ b/hooks/terraform_providers_lock.sh @@ -19,8 +19,8 @@ function main { # on each provided dir path. Run wrapped tool with specified arguments # Arguments: # args (string with array) arguments that configure wrapped tool behavior -# dir_path (string) PATH to dir from git repo root. Can be used in -# error logging +# dir_path (string) PATH to dir relative to git repo root. +# Can be used in error logging # Outputs: # If failed - print out hook checks status ####################################################################### diff --git a/hooks/terraform_tflint.sh b/hooks/terraform_tflint.sh index b8ff08458..b3788a92e 100755 --- a/hooks/terraform_tflint.sh +++ b/hooks/terraform_tflint.sh @@ -22,8 +22,8 @@ function main { # on each provided dir path. Run wrapped tool with specified arguments # Arguments: # args (string with array) arguments that configure wrapped tool behavior -# dir_path (string) PATH to dir from git repo root. Can be used in -# error logging +# dir_path (string) PATH to dir relative to git repo root. +# Can be used in error logging # Outputs: # If failed - print out hook checks status ####################################################################### diff --git a/hooks/terraform_tfsec.sh b/hooks/terraform_tfsec.sh index a7747c7a7..f39c0285d 100755 --- a/hooks/terraform_tfsec.sh +++ b/hooks/terraform_tfsec.sh @@ -21,8 +21,8 @@ function main { # on each provided dir path. Run wrapped tool with specified arguments # Arguments: # args (string with array) arguments that configure wrapped tool behavior -# dir_path (string) PATH to dir from git repo root. Can be used in -# error logging +# dir_path (string) PATH to dir relative to git repo root. +# Can be used in error logging # Outputs: # If failed - print out hook checks status ####################################################################### diff --git a/hooks/terragrunt_fmt.sh b/hooks/terragrunt_fmt.sh index 2fb7d3c10..c750241df 100755 --- a/hooks/terragrunt_fmt.sh +++ b/hooks/terragrunt_fmt.sh @@ -18,8 +18,8 @@ function main { # on each provided dir path. Run wrapped tool with specified arguments # Arguments: # args (string with array) arguments that configure wrapped tool behavior -# dir_path (string) PATH to dir from git repo root. Can be used in -# error logging +# dir_path (string) PATH to dir relative to git repo root. +# Can be used in error logging # Outputs: # If failed - print out hook checks status ####################################################################### diff --git a/hooks/terragrunt_validate.sh b/hooks/terragrunt_validate.sh index 50b0a16ab..e68497eea 100755 --- a/hooks/terragrunt_validate.sh +++ b/hooks/terragrunt_validate.sh @@ -18,8 +18,8 @@ function main { # on each provided dir path. Run wrapped tool with specified arguments # Arguments: # args (string with array) arguments that configure wrapped tool behavior -# dir_path (string) PATH to dir from git repo root. Can be used in -# error logging +# dir_path (string) PATH to dir relative to git repo root. +# Can be used in error logging # Outputs: # If failed - print out hook checks status ####################################################################### diff --git a/hooks/terrascan.sh b/hooks/terrascan.sh index 07401f8b5..31315aadd 100755 --- a/hooks/terrascan.sh +++ b/hooks/terrascan.sh @@ -18,8 +18,8 @@ function main { # on each provided dir path. Run wrapped tool with specified arguments # Arguments: # args (string with array) arguments that configure wrapped tool behavior -# dir_path (string) PATH to dir from git repo root. Can be used in -# error logging +# dir_path (string) PATH to dir relative to git repo root. +# Can be used in error logging # Outputs: # If failed - print out hook checks status ####################################################################### From 256157e164ac1513084419b6a58b63464be1f4d3 Mon Sep 17 00:00:00 2001 From: Maksym Vlasov Date: Fri, 7 Jan 2022 15:50:43 +0200 Subject: [PATCH 4/4] Apply suggestions from code review Co-authored-by: George L. Yermulnik --- hooks/terraform_validate.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hooks/terraform_validate.sh b/hooks/terraform_validate.sh index 9af292b9a..a123d5fbd 100755 --- a/hooks/terraform_validate.sh +++ b/hooks/terraform_validate.sh @@ -60,8 +60,8 @@ function parse_cmdline_ { } ####################################################################### -# Wrapper around `terraform validate` tool that check is code are valid -# 1. Export provided envs to environment +# Wrapper around `terraform validate` tool that checks if code is valid +# 1. Export provided env var K/V pairs to environment # 2. Because hook runs on whole dir, reduce file paths to uniq dir paths # 3. In each dir that have *.tf files: # 3.1. Check if `.terraform` dir exists and if not - run `terraform init`