mirror of
https://github.com/tofuutils/pre-commit-opentofu.git
synced 2025-10-15 17:38:54 +02:00
Allow to have spaces in directories (#11)
This commit is contained in:
parent
e6267fd150
commit
41d4951aff
5 changed files with 17 additions and 2 deletions
|
|
@ -1,9 +1,10 @@
|
||||||
repos:
|
repos:
|
||||||
- repo: git://github.com/pre-commit/pre-commit-hooks
|
- repo: git://github.com/pre-commit/pre-commit-hooks
|
||||||
sha: v1.2.0
|
rev: v1.2.3
|
||||||
hooks:
|
hooks:
|
||||||
- id: check-yaml
|
- id: check-yaml
|
||||||
- id: end-of-file-fixer
|
- id: end-of-file-fixer
|
||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
- id: check-case-conflict
|
- id: check-case-conflict
|
||||||
- id: check-merge-conflict
|
- id: check-merge-conflict
|
||||||
|
- id: check-executables-have-shebangs
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ An example `.pre-commit-config.yaml`:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- repo: git://github.com/antonbabenko/pre-commit-terraform
|
- repo: git://github.com/antonbabenko/pre-commit-terraform
|
||||||
sha: v1.5.0
|
sha: v1.6.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: terraform_fmt
|
- id: terraform_fmt
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@ declare -a tfvars_files
|
||||||
index=0
|
index=0
|
||||||
|
|
||||||
for file_with_path in "$@"; do
|
for file_with_path in "$@"; do
|
||||||
|
file_with_path="${file_with_path// /__REPLACED__SPACE__}"
|
||||||
|
|
||||||
paths[index]=$(dirname "$file_with_path")
|
paths[index]=$(dirname "$file_with_path")
|
||||||
|
|
||||||
if [[ "$file_with_path" == *".tfvars" ]]; then
|
if [[ "$file_with_path" == *".tfvars" ]]; then
|
||||||
|
|
@ -17,6 +19,8 @@ for file_with_path in "$@"; do
|
||||||
done
|
done
|
||||||
|
|
||||||
for path_uniq in $(echo "${paths[*]}" | tr ' ' '\n' | sort -u); do
|
for path_uniq in $(echo "${paths[*]}" | tr ' ' '\n' | sort -u); do
|
||||||
|
path_uniq="${path_uniq//__REPLACED__SPACE__/ }"
|
||||||
|
|
||||||
pushd "$path_uniq" > /dev/null
|
pushd "$path_uniq" > /dev/null
|
||||||
terraform fmt
|
terraform fmt
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
|
|
@ -24,5 +28,7 @@ done
|
||||||
|
|
||||||
# terraform.tfvars are excluded by `terraform fmt`
|
# terraform.tfvars are excluded by `terraform fmt`
|
||||||
for tfvars_file in "${tfvars_files[@]}"; do
|
for tfvars_file in "${tfvars_files[@]}"; do
|
||||||
|
tfvars_file="${tfvars_file//__REPLACED__SPACE__/ }"
|
||||||
|
|
||||||
terraform fmt "$tfvars_file"
|
terraform fmt "$tfvars_file"
|
||||||
done
|
done
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,15 @@ declare -a paths
|
||||||
index=0
|
index=0
|
||||||
|
|
||||||
for file_with_path in "$@"; do
|
for file_with_path in "$@"; do
|
||||||
|
file_with_path="${file_with_path// /__REPLACED__SPACE__}"
|
||||||
|
|
||||||
paths[index]=$(dirname "$file_with_path")
|
paths[index]=$(dirname "$file_with_path")
|
||||||
let "index+=1"
|
let "index+=1"
|
||||||
done
|
done
|
||||||
|
|
||||||
for path_uniq in $(echo "${paths[*]}" | tr ' ' '\n' | sort -u); do
|
for path_uniq in $(echo "${paths[*]}" | tr ' ' '\n' | sort -u); do
|
||||||
|
path_uniq="${path_uniq//__REPLACED__SPACE__/ }"
|
||||||
|
|
||||||
pushd "$path_uniq" > /dev/null
|
pushd "$path_uniq" > /dev/null
|
||||||
terraform validate -check-variables=false
|
terraform validate -check-variables=false
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,15 @@ declare -a paths
|
||||||
index=0
|
index=0
|
||||||
|
|
||||||
for file_with_path in "$@"; do
|
for file_with_path in "$@"; do
|
||||||
|
file_with_path="${file_with_path// /__REPLACED__SPACE__}"
|
||||||
|
|
||||||
paths[index]=$(dirname "$file_with_path")
|
paths[index]=$(dirname "$file_with_path")
|
||||||
let "index+=1"
|
let "index+=1"
|
||||||
done
|
done
|
||||||
|
|
||||||
for path_uniq in $(echo "${paths[*]}" | tr ' ' '\n' | sort -u); do
|
for path_uniq in $(echo "${paths[*]}" | tr ' ' '\n' | sort -u); do
|
||||||
|
path_uniq="${path_uniq//__REPLACED__SPACE__/ }"
|
||||||
|
|
||||||
pushd "$path_uniq" > /dev/null
|
pushd "$path_uniq" > /dev/null
|
||||||
terraform validate -check-variables=true
|
terraform validate -check-variables=true
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue