diff --git a/hooks/_common.sh b/hooks/_common.sh index 09debf5..eb17ef8 100644 --- a/hooks/_common.sh +++ b/hooks/_common.sh @@ -1,6 +1,12 @@ #!/usr/bin/env bash set -eo pipefail +# Hook ID, based on hook filename. +# Hook filename MUST BE same with `- id` in .pre-commit-hooks.yaml file +# shellcheck disable=SC2034 # Unused var. +HOOK_ID=${0##*/} +readonly HOOK_ID=${HOOK_ID%%.*} + ####################################################################### # Init arguments parser # Arguments: diff --git a/hooks/infracost_breakdown.sh b/hooks/infracost_breakdown.sh index 867f700..b546020 100755 --- a/hooks/infracost_breakdown.sh +++ b/hooks/infracost_breakdown.sh @@ -2,9 +2,6 @@ set -eo pipefail # globals variables -# hook ID, see `- id` for details in .pre-commit-hooks.yaml file -# shellcheck disable=SC2034 # Unused var. -readonly HOOK_ID='infracost_breakdown' # shellcheck disable=SC2155 # No way to assign to readonly variable in separate lines readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" # shellcheck source=_common.sh diff --git a/hooks/terraform_checkov.sh b/hooks/terraform_checkov.sh index 91d80b6..06013bf 100755 --- a/hooks/terraform_checkov.sh +++ b/hooks/terraform_checkov.sh @@ -2,9 +2,6 @@ set -eo pipefail # globals variables -# hook ID, see `- id` for details in .pre-commit-hooks.yaml file -# shellcheck disable=SC2034 # Unused var. -readonly HOOK_ID='terraform_checkov' # shellcheck disable=SC2155 # No way to assign to readonly variable in separate lines readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" # shellcheck source=_common.sh diff --git a/hooks/terraform_fmt.sh b/hooks/terraform_fmt.sh index 4c589f9..241a1ae 100755 --- a/hooks/terraform_fmt.sh +++ b/hooks/terraform_fmt.sh @@ -2,9 +2,6 @@ set -eo pipefail # globals variables -# hook ID, see `- id` for details in .pre-commit-hooks.yaml file -# shellcheck disable=SC2034 # Unused var. -readonly HOOK_ID='terraform_fmt' # shellcheck disable=SC2155 # No way to assign to readonly variable in separate lines readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" # shellcheck source=_common.sh diff --git a/hooks/terraform_providers_lock.sh b/hooks/terraform_providers_lock.sh index 9b02800..a0f4068 100755 --- a/hooks/terraform_providers_lock.sh +++ b/hooks/terraform_providers_lock.sh @@ -3,8 +3,6 @@ set -eo pipefail # globals variables -# hook ID, see `- id` for details in .pre-commit-hooks.yaml file -readonly HOOK_ID='terraform_providers_lock' # shellcheck disable=SC2155 # No way to assign to readonly variable in separate lines readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" # shellcheck source=_common.sh diff --git a/hooks/terraform_tflint.sh b/hooks/terraform_tflint.sh index 09b12d9..5795a31 100755 --- a/hooks/terraform_tflint.sh +++ b/hooks/terraform_tflint.sh @@ -3,8 +3,6 @@ set -eo pipefail # globals variables -# hook ID, see `- id` for details in .pre-commit-hooks.yaml file -readonly HOOK_ID='terraform_tflint' # shellcheck disable=SC2155 # No way to assign to readonly variable in separate lines readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" # shellcheck source=_common.sh diff --git a/hooks/terraform_tfsec.sh b/hooks/terraform_tfsec.sh index b4a94a4..4b5d8f0 100755 --- a/hooks/terraform_tfsec.sh +++ b/hooks/terraform_tfsec.sh @@ -2,8 +2,6 @@ set -eo pipefail # globals variables -# hook ID, see `- id` for details in .pre-commit-hooks.yaml file -readonly HOOK_ID='terraform_tfsec' # shellcheck disable=SC2155 # No way to assign to readonly variable in separate lines readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" # shellcheck source=_common.sh diff --git a/hooks/terraform_validate.sh b/hooks/terraform_validate.sh index 78a0da8..cbbab53 100755 --- a/hooks/terraform_validate.sh +++ b/hooks/terraform_validate.sh @@ -2,9 +2,6 @@ set -eo pipefail # globals variables -# hook ID, see `- id` for details in .pre-commit-hooks.yaml file -# shellcheck disable=SC2034 # Unused var. -readonly HOOK_ID='terraform_validate' # shellcheck disable=SC2155 # No way to assign to readonly variable in separate lines readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" # shellcheck source=_common.sh diff --git a/hooks/terraform_wrapper_module_for_each.sh b/hooks/terraform_wrapper_module_for_each.sh index 1a7abed..4e17184 100755 --- a/hooks/terraform_wrapper_module_for_each.sh +++ b/hooks/terraform_wrapper_module_for_each.sh @@ -2,10 +2,6 @@ set -eo pipefail # globals variables -# hook ID, see `- id` for details in .pre-commit-hooks.yaml file -# shellcheck disable=SC2034 # Unused var. -HOOK_ID=${0##*/} -readonly HOOK_ID=${HOOK_ID%%.*} # shellcheck disable=SC2155 # No way to assign to readonly variable in separate lines readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" # shellcheck source=_common.sh diff --git a/hooks/terragrunt_fmt.sh b/hooks/terragrunt_fmt.sh index 7508124..f623362 100755 --- a/hooks/terragrunt_fmt.sh +++ b/hooks/terragrunt_fmt.sh @@ -2,8 +2,6 @@ set -eo pipefail # globals variables -# hook ID, see `- id` for details in .pre-commit-hooks.yaml file -readonly HOOK_ID='terragrunt_fmt' # shellcheck disable=SC2155 # No way to assign to readonly variable in separate lines readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" # shellcheck source=_common.sh diff --git a/hooks/terragrunt_validate.sh b/hooks/terragrunt_validate.sh index 198e56c..e7ffee4 100755 --- a/hooks/terragrunt_validate.sh +++ b/hooks/terragrunt_validate.sh @@ -2,8 +2,6 @@ set -eo pipefail # globals variables -# hook ID, see `- id` for details in .pre-commit-hooks.yaml file -readonly HOOK_ID='terragrunt_validate' # shellcheck disable=SC2155 # No way to assign to readonly variable in separate lines readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" # shellcheck source=_common.sh diff --git a/hooks/terrascan.sh b/hooks/terrascan.sh index daae133..16f6c75 100755 --- a/hooks/terrascan.sh +++ b/hooks/terrascan.sh @@ -2,8 +2,6 @@ set -eo pipefail # globals variables -# hook ID, see `- id` for details in .pre-commit-hooks.yaml file -readonly HOOK_ID='terrascan' # shellcheck disable=SC2155 # No way to assign to readonly variable in separate lines readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" # shellcheck source=_common.sh diff --git a/hooks/tfupdate.sh b/hooks/tfupdate.sh index d7c0808..309ee87 100755 --- a/hooks/tfupdate.sh +++ b/hooks/tfupdate.sh @@ -2,8 +2,6 @@ set -eo pipefail # globals variables -# hook ID, see `- id` for details in .pre-commit-hooks.yaml file -readonly HOOK_ID='tfupdate' # shellcheck disable=SC2155 # No way to assign to readonly variable in separate lines readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" # shellcheck source=_common.sh