mirror of
https://github.com/tofuutils/pre-commit-opentofu.git
synced 2025-10-15 17:38:54 +02:00
feat: Add possibility to share tflint config file for subdirs (#149)
This commit is contained in:
parent
e4ab41045d
commit
cf07b5ea3f
2 changed files with 14 additions and 2 deletions
10
README.md
10
README.md
|
|
@ -121,6 +121,16 @@ if they are present in `README.md`.
|
||||||
- '--args=--enable-rule=terraform_documented_variables'
|
- '--args=--enable-rule=terraform_documented_variables'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
1. When you have multiple directories and want to run `tflint` in all of them and share single config file it is impractical to hard-code the path to `.tflint.hcl` file. The solution is to use `__GIT_WORKING_DIR__` placeholder which will be replaced by `terraform_tflint` hooks with Git working directory (repo root) at run time. For example:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
hooks:
|
||||||
|
- id: terraform_tflint
|
||||||
|
args:
|
||||||
|
- '--args=--config=__GIT_WORKING_DIR__/.tflint.hcl'
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Notes about terraform_tfsec hooks
|
## Notes about terraform_tfsec hooks
|
||||||
|
|
||||||
1. `terraform_tfsec` will consume modified files that pre-commit
|
1. `terraform_tfsec` will consume modified files that pre-commit
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -e
|
set -eo pipefail
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
initialize_
|
initialize_
|
||||||
|
|
@ -35,7 +35,8 @@ parse_cmdline_() {
|
||||||
case $argv in
|
case $argv in
|
||||||
-a | --args)
|
-a | --args)
|
||||||
shift
|
shift
|
||||||
ARGS+=("$1")
|
expanded_arg="${1//__GIT_WORKING_DIR__/$PWD}"
|
||||||
|
ARGS+=("$expanded_arg")
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--)
|
--)
|
||||||
|
|
@ -45,6 +46,7 @@ parse_cmdline_() {
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tflint_() {
|
tflint_() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue