pre-commit-opentofu/terraform_validate_with_variables.sh
2018-01-24 13:57:41 +01:00

22 lines
441 B
Bash
Executable file

#!/usr/bin/env bash
set -e
declare -a paths
index=0
for file_with_path in "$@"; do
paths[index]=$(dirname "$file_with_path")
let "index+=1"
done
for path_uniq in $(echo "${paths[*]}" | tr ' ' '\n' | sort -u); do
pushd "$path_uniq" > /dev/null
terraform validate -check-variables=true
if [[ "$?" -ne 0 ]]; then
echo
echo "Failed path: $path_uniq"
echo "================================"
fi
popd > /dev/null
done