diff --git a/hooks/_common.sh b/hooks/_common.sh index 09debf5da..eb17ef815 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 867f7008c..b5460205c 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 91d80b673..06013bf96 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 4c589f9de..241a1aeef 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 9b02800ba..a0f406808 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 09b12d9e5..5795a318f 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 b4a94a492..4b5d8f06d 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 78a0da8f8..cbbab532e 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 1a7abed28..4e1718427 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 750812428..f6233628c 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 198e56c14..e7ffee46d 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 daae13301..16f6c750e 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 d7c08085e..309ee877c 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