mirror of
https://github.com/tofuutils/pre-commit-opentofu.git
synced 2025-10-15 17:38:54 +02:00
feat: add terragrunt validate hook (#134)
This commit is contained in:
parent
2e40ade8d0
commit
f6caf2195a
3 changed files with 32 additions and 0 deletions
|
|
@ -58,6 +58,14 @@
|
||||||
files: (\.hcl)$
|
files: (\.hcl)$
|
||||||
exclude: \.terraform\/.*$
|
exclude: \.terraform\/.*$
|
||||||
|
|
||||||
|
- id: terragrunt_validate
|
||||||
|
name: Terragrunt validate
|
||||||
|
description: Validates all Terragrunt configuration files.
|
||||||
|
entry: terragrunt_validate.sh
|
||||||
|
language: script
|
||||||
|
files: (\.hcl)$
|
||||||
|
exclude: \.terraform\/.*$
|
||||||
|
|
||||||
- id: terraform_tfsec
|
- id: terraform_tfsec
|
||||||
name: Terraform validate with tfsec
|
name: Terraform validate with tfsec
|
||||||
description: Static analysis of Terraform templates to spot potential security issues.
|
description: Static analysis of Terraform templates to spot potential security issues.
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,7 @@ There are several [pre-commit](https://pre-commit.com/) hooks to keep Terraform
|
||||||
| `terraform_docs_replace` | Runs `terraform-docs` and pipes the output directly to README.md |
|
| `terraform_docs_replace` | Runs `terraform-docs` and pipes the output directly to README.md |
|
||||||
| `terraform_tflint` | Validates all Terraform configuration files with [TFLint](https://github.com/terraform-linters/tflint). |
|
| `terraform_tflint` | Validates all Terraform configuration files with [TFLint](https://github.com/terraform-linters/tflint). |
|
||||||
| `terragrunt_fmt` | Rewrites all [Terragrunt](https://github.com/gruntwork-io/terragrunt) configuration files (`*.hcl`) to a canonical format. |
|
| `terragrunt_fmt` | Rewrites all [Terragrunt](https://github.com/gruntwork-io/terragrunt) configuration files (`*.hcl`) to a canonical format. |
|
||||||
|
| `terragrunt_validate` | Validates all [Terragrunt](https://github.com/gruntwork-io/terragrunt) configuration files (`*.hcl`) |
|
||||||
| `terraform_tfsec` | [TFSec](https://github.com/liamg/tfsec) static analysis of terraform templates to spot potential security issues. |
|
| `terraform_tfsec` | [TFSec](https://github.com/liamg/tfsec) static analysis of terraform templates to spot potential security issues. |
|
||||||
|
|
||||||
Check the [source file](https://github.com/antonbabenko/pre-commit-terraform/blob/master/.pre-commit-hooks.yaml) to know arguments used for each hook.
|
Check the [source file](https://github.com/antonbabenko/pre-commit-terraform/blob/master/.pre-commit-hooks.yaml) to know arguments used for each hook.
|
||||||
|
|
|
||||||
23
terragrunt_validate.sh
Executable file
23
terragrunt_validate.sh
Executable file
|
|
@ -0,0 +1,23 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
declare -a paths
|
||||||
|
|
||||||
|
index=0
|
||||||
|
|
||||||
|
for file_with_path in "$@"; do
|
||||||
|
file_with_path="${file_with_path// /__REPLACED__SPACE__}"
|
||||||
|
|
||||||
|
paths[index]=$(dirname "$file_with_path")
|
||||||
|
|
||||||
|
let "index+=1"
|
||||||
|
done
|
||||||
|
|
||||||
|
for path_uniq in $(echo "${paths[*]}" | tr ' ' '\n' | sort -u); do
|
||||||
|
path_uniq="${path_uniq//__REPLACED__SPACE__/ }"
|
||||||
|
|
||||||
|
pushd "$path_uniq" > /dev/null
|
||||||
|
terragrunt validate
|
||||||
|
popd > /dev/null
|
||||||
|
done
|
||||||
Loading…
Add table
Add a link
Reference in a new issue