mirror of
https://github.com/tofuutils/pre-commit-opentofu.git
synced 2025-10-15 17:38:54 +02:00
feat: Removed coreutils (realpath) from dependencies for MacOS (#368)
This commit is contained in:
parent
4874cfe42e
commit
944a2e5fef
14 changed files with 15 additions and 17 deletions
|
|
@ -114,10 +114,8 @@ Set `-e PRE_COMMIT_COLOR=never` to disable the color output in `pre-commit`.
|
||||||
|
|
||||||
<details><summary><b>MacOS</b></summary><br>
|
<details><summary><b>MacOS</b></summary><br>
|
||||||
|
|
||||||
[`coreutils`](https://formulae.brew.sh/formula/coreutils) is required for hooks on MacOS (due to use of `realpath`).
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
brew install pre-commit terraform-docs tflint tfsec coreutils checkov terrascan infracost tfupdate jq
|
brew install pre-commit terraform-docs tflint tfsec checkov terrascan infracost tfupdate jq
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ function common::is_hook_run_on_whole_repo {
|
||||||
shift 1
|
shift 1
|
||||||
local -a -r files=("$@")
|
local -a -r files=("$@")
|
||||||
# get directory containing `.pre-commit-hooks.yaml` file
|
# get directory containing `.pre-commit-hooks.yaml` file
|
||||||
local -r root_config_dir="$(dirname "$(dirname "$(realpath "${BASH_SOURCE[0]}")")")"
|
local -r root_config_dir="$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)")"
|
||||||
# get included and excluded files from .pre-commit-hooks.yaml file
|
# get included and excluded files from .pre-commit-hooks.yaml file
|
||||||
local -r hook_config_block=$(sed -n "/^- id: $hook_id$/,/^$/p" "$root_config_dir/.pre-commit-hooks.yaml")
|
local -r hook_config_block=$(sed -n "/^- id: $hook_id$/,/^$/p" "$root_config_dir/.pre-commit-hooks.yaml")
|
||||||
local -r included_files=$(awk '$1 == "files:" {print $2; exit}' <<< "$hook_config_block")
|
local -r included_files=$(awk '$1 == "files:" {print $2; exit}' <<< "$hook_config_block")
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ set -eo pipefail
|
||||||
# shellcheck disable=SC2034 # Unused var.
|
# shellcheck disable=SC2034 # Unused var.
|
||||||
readonly HOOK_ID='infracost_breakdown'
|
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="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
|
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||||
# shellcheck source=_common.sh
|
# shellcheck source=_common.sh
|
||||||
. "$SCRIPT_DIR/_common.sh"
|
. "$SCRIPT_DIR/_common.sh"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ set -eo pipefail
|
||||||
# shellcheck disable=SC2034 # Unused var.
|
# shellcheck disable=SC2034 # Unused var.
|
||||||
readonly HOOK_ID='terraform_checkov'
|
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="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
|
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||||
# shellcheck source=_common.sh
|
# shellcheck source=_common.sh
|
||||||
. "$SCRIPT_DIR/_common.sh"
|
. "$SCRIPT_DIR/_common.sh"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ set -eo pipefail
|
||||||
# shellcheck disable=SC2034 # Unused var.
|
# shellcheck disable=SC2034 # Unused var.
|
||||||
readonly HOOK_ID='terraform_docs'
|
readonly HOOK_ID='terraform_docs'
|
||||||
# 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="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
|
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||||
# shellcheck source=_common.sh
|
# shellcheck source=_common.sh
|
||||||
. "$SCRIPT_DIR/_common.sh"
|
. "$SCRIPT_DIR/_common.sh"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ set -eo pipefail
|
||||||
# shellcheck disable=SC2034 # Unused var.
|
# shellcheck disable=SC2034 # Unused var.
|
||||||
readonly HOOK_ID='terraform_fmt'
|
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="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
|
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||||
# shellcheck source=_common.sh
|
# shellcheck source=_common.sh
|
||||||
. "$SCRIPT_DIR/_common.sh"
|
. "$SCRIPT_DIR/_common.sh"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ set -eo pipefail
|
||||||
# hook ID, see `- id` for details in .pre-commit-hooks.yaml file
|
# hook ID, see `- id` for details in .pre-commit-hooks.yaml file
|
||||||
readonly HOOK_ID='terraform_providers_lock'
|
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="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
|
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||||
# shellcheck source=_common.sh
|
# shellcheck source=_common.sh
|
||||||
. "$SCRIPT_DIR/_common.sh"
|
. "$SCRIPT_DIR/_common.sh"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ set -eo pipefail
|
||||||
# hook ID, see `- id` for details in .pre-commit-hooks.yaml file
|
# hook ID, see `- id` for details in .pre-commit-hooks.yaml file
|
||||||
readonly HOOK_ID='terraform_tflint'
|
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="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
|
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||||
# shellcheck source=_common.sh
|
# shellcheck source=_common.sh
|
||||||
. "$SCRIPT_DIR/_common.sh"
|
. "$SCRIPT_DIR/_common.sh"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ set -eo pipefail
|
||||||
# hook ID, see `- id` for details in .pre-commit-hooks.yaml file
|
# hook ID, see `- id` for details in .pre-commit-hooks.yaml file
|
||||||
readonly HOOK_ID='terraform_tfsec'
|
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="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
|
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||||
# shellcheck source=_common.sh
|
# shellcheck source=_common.sh
|
||||||
. "$SCRIPT_DIR/_common.sh"
|
. "$SCRIPT_DIR/_common.sh"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ set -eo pipefail
|
||||||
# shellcheck disable=SC2034 # Unused var.
|
# shellcheck disable=SC2034 # Unused var.
|
||||||
readonly HOOK_ID='terraform_validate'
|
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="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
|
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||||
# shellcheck source=_common.sh
|
# shellcheck source=_common.sh
|
||||||
. "$SCRIPT_DIR/_common.sh"
|
. "$SCRIPT_DIR/_common.sh"
|
||||||
|
|
||||||
|
|
@ -110,7 +110,7 @@ function terraform_validate_ {
|
||||||
|
|
||||||
if [[ -n "$(find "$dir_path" -maxdepth 1 -name '*.tf' -print -quit)" ]]; then
|
if [[ -n "$(find "$dir_path" -maxdepth 1 -name '*.tf' -print -quit)" ]]; then
|
||||||
|
|
||||||
pushd "$(realpath "$dir_path")" > /dev/null
|
pushd "$(cd "$dir_path" && pwd -P)" > /dev/null
|
||||||
|
|
||||||
if [ ! -d .terraform ]; then
|
if [ ! -d .terraform ]; then
|
||||||
set +e
|
set +e
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ set -eo pipefail
|
||||||
# hook ID, see `- id` for details in .pre-commit-hooks.yaml file
|
# hook ID, see `- id` for details in .pre-commit-hooks.yaml file
|
||||||
readonly HOOK_ID='terragrunt_fmt'
|
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="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
|
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||||
# shellcheck source=_common.sh
|
# shellcheck source=_common.sh
|
||||||
. "$SCRIPT_DIR/_common.sh"
|
. "$SCRIPT_DIR/_common.sh"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ set -eo pipefail
|
||||||
# hook ID, see `- id` for details in .pre-commit-hooks.yaml file
|
# hook ID, see `- id` for details in .pre-commit-hooks.yaml file
|
||||||
readonly HOOK_ID='terragrunt_validate'
|
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="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
|
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||||
# shellcheck source=_common.sh
|
# shellcheck source=_common.sh
|
||||||
. "$SCRIPT_DIR/_common.sh"
|
. "$SCRIPT_DIR/_common.sh"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ set -eo pipefail
|
||||||
# hook ID, see `- id` for details in .pre-commit-hooks.yaml file
|
# hook ID, see `- id` for details in .pre-commit-hooks.yaml file
|
||||||
readonly HOOK_ID='terrascan'
|
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="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
|
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||||
# shellcheck source=_common.sh
|
# shellcheck source=_common.sh
|
||||||
. "$SCRIPT_DIR/_common.sh"
|
. "$SCRIPT_DIR/_common.sh"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ set -eo pipefail
|
||||||
# hook ID, see `- id` for details in .pre-commit-hooks.yaml file
|
# hook ID, see `- id` for details in .pre-commit-hooks.yaml file
|
||||||
readonly HOOK_ID='tfupdate'
|
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="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
|
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||||
# shellcheck source=_common.sh
|
# shellcheck source=_common.sh
|
||||||
. "$SCRIPT_DIR/_common.sh"
|
. "$SCRIPT_DIR/_common.sh"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue