mirror of
https://github.com/tofuutils/pre-commit-opentofu.git
synced 2025-10-15 17:38:54 +02:00
chore: Implement DRY for HOOK_ID (#405)
This commit is contained in:
parent
2623b7b8be
commit
0f25122485
13 changed files with 6 additions and 30 deletions
|
|
@ -1,6 +1,12 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -eo pipefail
|
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
|
# Init arguments parser
|
||||||
# Arguments:
|
# Arguments:
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,6 @@
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
|
|
||||||
# globals variables
|
# 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
|
# shellcheck disable=SC2155 # No way to assign to readonly variable in separate lines
|
||||||
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||||
# shellcheck source=_common.sh
|
# shellcheck source=_common.sh
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,6 @@
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
|
|
||||||
# globals variables
|
# 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
|
# shellcheck disable=SC2155 # No way to assign to readonly variable in separate lines
|
||||||
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||||
# shellcheck source=_common.sh
|
# shellcheck source=_common.sh
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,6 @@
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
|
|
||||||
# globals variables
|
# 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
|
# shellcheck disable=SC2155 # No way to assign to readonly variable in separate lines
|
||||||
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||||
# shellcheck source=_common.sh
|
# shellcheck source=_common.sh
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,6 @@
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
|
|
||||||
# globals variables
|
# 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
|
# shellcheck disable=SC2155 # No way to assign to readonly variable in separate lines
|
||||||
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||||
# shellcheck source=_common.sh
|
# shellcheck source=_common.sh
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,6 @@
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
|
|
||||||
# globals variables
|
# 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
|
# shellcheck disable=SC2155 # No way to assign to readonly variable in separate lines
|
||||||
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||||
# shellcheck source=_common.sh
|
# shellcheck source=_common.sh
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,6 @@
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
|
|
||||||
# globals variables
|
# 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
|
# shellcheck disable=SC2155 # No way to assign to readonly variable in separate lines
|
||||||
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||||
# shellcheck source=_common.sh
|
# shellcheck source=_common.sh
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,6 @@
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
|
|
||||||
# globals variables
|
# 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
|
# shellcheck disable=SC2155 # No way to assign to readonly variable in separate lines
|
||||||
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||||
# shellcheck source=_common.sh
|
# shellcheck source=_common.sh
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,6 @@
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
|
|
||||||
# globals variables
|
# 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
|
# shellcheck disable=SC2155 # No way to assign to readonly variable in separate lines
|
||||||
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||||
# shellcheck source=_common.sh
|
# shellcheck source=_common.sh
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,6 @@
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
|
|
||||||
# globals variables
|
# 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
|
# shellcheck disable=SC2155 # No way to assign to readonly variable in separate lines
|
||||||
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||||
# shellcheck source=_common.sh
|
# shellcheck source=_common.sh
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,6 @@
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
|
|
||||||
# globals variables
|
# 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
|
# shellcheck disable=SC2155 # No way to assign to readonly variable in separate lines
|
||||||
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||||
# shellcheck source=_common.sh
|
# shellcheck source=_common.sh
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,6 @@
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
|
|
||||||
# globals variables
|
# 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
|
# shellcheck disable=SC2155 # No way to assign to readonly variable in separate lines
|
||||||
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||||
# shellcheck source=_common.sh
|
# shellcheck source=_common.sh
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,6 @@
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
|
|
||||||
# globals variables
|
# 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
|
# shellcheck disable=SC2155 # No way to assign to readonly variable in separate lines
|
||||||
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||||
# shellcheck source=_common.sh
|
# shellcheck source=_common.sh
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue