Format tfvars files explicitely, because terraform fmt ignores them (#9)

This commit is contained in:
Anton Babenko 2018-03-06 13:58:03 +01:00 committed by GitHub
commit b0d43204ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,10 +2,17 @@
set -e
declare -a paths
declare -a tfvars_files
index=0
for file_with_path in "$@"; do
paths[index]=$(dirname "$file_with_path")
if [[ "$file_with_path" == *".tfvars" ]]; then
tfvars_files+=("$file_with_path")
fi
let "index+=1"
done
@ -14,3 +21,8 @@ for path_uniq in $(echo "${paths[*]}" | tr ' ' '\n' | sort -u); do
terraform fmt
popd > /dev/null
done
# terraform.tfvars are excluded by `terraform fmt`
for tfvars_file in "${tfvars_files[@]}"; do
terraform fmt "$tfvars_file"
done