mirror of
https://github.com/tofuutils/pre-commit-opentofu.git
synced 2025-10-15 17:38:54 +02:00
Format tfvars files explicitely, because terraform fmt ignores them (#9)
This commit is contained in:
parent
c6f81e3730
commit
b0d43204ca
1 changed files with 12 additions and 0 deletions
|
|
@ -2,10 +2,17 @@
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
declare -a paths
|
declare -a paths
|
||||||
|
declare -a tfvars_files
|
||||||
|
|
||||||
index=0
|
index=0
|
||||||
|
|
||||||
for file_with_path in "$@"; do
|
for file_with_path in "$@"; do
|
||||||
paths[index]=$(dirname "$file_with_path")
|
paths[index]=$(dirname "$file_with_path")
|
||||||
|
|
||||||
|
if [[ "$file_with_path" == *".tfvars" ]]; then
|
||||||
|
tfvars_files+=("$file_with_path")
|
||||||
|
fi
|
||||||
|
|
||||||
let "index+=1"
|
let "index+=1"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
@ -14,3 +21,8 @@ for path_uniq in $(echo "${paths[*]}" | tr ' ' '\n' | sort -u); do
|
||||||
terraform fmt
|
terraform fmt
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# terraform.tfvars are excluded by `terraform fmt`
|
||||||
|
for tfvars_file in "${tfvars_files[@]}"; do
|
||||||
|
terraform fmt "$tfvars_file"
|
||||||
|
done
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue