mirror of
https://github.com/tofuutils/pre-commit-opentofu.git
synced 2025-10-15 17:38:54 +02:00
Only run validate if .tf files exist in the directory. (#20)
* Only run validate if .tf files exist in the directory. * Same fix, different script :)
This commit is contained in:
parent
2d3782cefa
commit
69039c3a8c
2 changed files with 14 additions and 14 deletions
|
|
@ -8,19 +8,19 @@ for file_with_path in "$@"; do
|
||||||
file_with_path="${file_with_path// /__REPLACED__SPACE__}"
|
file_with_path="${file_with_path// /__REPLACED__SPACE__}"
|
||||||
|
|
||||||
paths[index]=$(dirname "$file_with_path")
|
paths[index]=$(dirname "$file_with_path")
|
||||||
let "index+=1"
|
(( "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__/ }"
|
path_uniq="${path_uniq//__REPLACED__SPACE__/ }"
|
||||||
|
|
||||||
pushd "$path_uniq" > /dev/null
|
pushd "$path_uniq" > /dev/null
|
||||||
terraform validate -check-variables=false
|
if [[ -n "$(find . -maxdepth 1 -name '*.tf' -print -quit)" ]] ; then
|
||||||
|
if ! terraform validate -check-variables=false ; then
|
||||||
if [[ "$?" -ne 0 ]]; then
|
echo
|
||||||
echo
|
echo "Failed path: $path_uniq"
|
||||||
echo "Failed path: $path_uniq"
|
echo "================================"
|
||||||
echo "================================"
|
fi
|
||||||
fi
|
fi
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
done
|
done
|
||||||
|
|
|
||||||
|
|
@ -8,19 +8,19 @@ for file_with_path in "$@"; do
|
||||||
file_with_path="${file_with_path// /__REPLACED__SPACE__}"
|
file_with_path="${file_with_path// /__REPLACED__SPACE__}"
|
||||||
|
|
||||||
paths[index]=$(dirname "$file_with_path")
|
paths[index]=$(dirname "$file_with_path")
|
||||||
let "index+=1"
|
(( "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__/ }"
|
path_uniq="${path_uniq//__REPLACED__SPACE__/ }"
|
||||||
|
|
||||||
pushd "$path_uniq" > /dev/null
|
pushd "$path_uniq" > /dev/null
|
||||||
terraform validate -check-variables=true
|
if [[ -n "$(find . -maxdepth 1 -name '*.tf' -print -quit)" ]] ; then
|
||||||
|
if ! terraform validate -check-variables=true ; then
|
||||||
if [[ "$?" -ne 0 ]]; then
|
echo
|
||||||
echo
|
echo "Failed path: $path_uniq"
|
||||||
echo "Failed path: $path_uniq"
|
echo "================================"
|
||||||
echo "================================"
|
fi
|
||||||
fi
|
fi
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
done
|
done
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue