Skip to content

Commit

Permalink
Only run validate if .tf files exist in the directory. (#20)
Browse files Browse the repository at this point in the history
* Only run validate if .tf files exist in the directory.

* Same fix, different script :)
  • Loading branch information
robinbowes authored and antonbabenko committed May 24, 2018
1 parent 2d3782c commit 69039c3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
14 changes: 7 additions & 7 deletions terraform_validate_no_variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ for file_with_path in "$@"; do
file_with_path="${file_with_path// /__REPLACED__SPACE__}"

paths[index]=$(dirname "$file_with_path")
let "index+=1"
(( "index+=1" ))
done

for path_uniq in $(echo "${paths[*]}" | tr ' ' '\n' | sort -u); do
path_uniq="${path_uniq//__REPLACED__SPACE__/ }"

pushd "$path_uniq" > /dev/null
terraform validate -check-variables=false

if [[ "$?" -ne 0 ]]; then
echo
echo "Failed path: $path_uniq"
echo "================================"
if [[ -n "$(find . -maxdepth 1 -name '*.tf' -print -quit)" ]] ; then
if ! terraform validate -check-variables=false ; then
echo
echo "Failed path: $path_uniq"
echo "================================"
fi
fi
popd > /dev/null
done
14 changes: 7 additions & 7 deletions terraform_validate_with_variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ for file_with_path in "$@"; do
file_with_path="${file_with_path// /__REPLACED__SPACE__}"

paths[index]=$(dirname "$file_with_path")
let "index+=1"
(( "index+=1" ))
done

for path_uniq in $(echo "${paths[*]}" | tr ' ' '\n' | sort -u); do
path_uniq="${path_uniq//__REPLACED__SPACE__/ }"

pushd "$path_uniq" > /dev/null
terraform validate -check-variables=true

if [[ "$?" -ne 0 ]]; then
echo
echo "Failed path: $path_uniq"
echo "================================"
if [[ -n "$(find . -maxdepth 1 -name '*.tf' -print -quit)" ]] ; then
if ! terraform validate -check-variables=true ; then
echo
echo "Failed path: $path_uniq"
echo "================================"
fi
fi
popd > /dev/null
done

0 comments on commit 69039c3

Please sign in to comment.