forked from hashicorp/terraform-provider-azurerm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tooling: adding a script to validate the examples in the
./examples
…
… folder are valid
- Loading branch information
1 parent
8fda9c9
commit 209917d
Showing
3 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ website/node_modules | |
*.iml | ||
*.test | ||
.terraform.tfstate.lock.info | ||
.terraform.lock.hcl | ||
|
||
website/vendor | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env bash | ||
|
||
echo "==> Checking examples validate with 'terraform validate'..." | ||
|
||
exampleDirs=$(find ./examples -mindepth 2 -maxdepth 2 -type d '!' -exec test -e "{}/*.tf" ';' -print | sort) | ||
examplesWithErrors=() | ||
hasError=false | ||
|
||
for d in $exampleDirs; do | ||
echo "Validating $d.." | ||
exampleHasErrors=false | ||
terraform -chdir=$d init > /dev/null || exampleHasErrors=true | ||
if ! ${exampleHasErrors}; then | ||
terraform -chdir=$d validate > /dev/null || exampleHasErrors=true | ||
fi | ||
if ${exampleHasErrors}; then | ||
examplesWithErrors[${#examplesWithErrors[@]}]=$d | ||
hasError=true | ||
fi | ||
done | ||
|
||
if ${hasError}; then | ||
echo "------------------------------------------------" | ||
echo "" | ||
echo "The directories listed below failed to validate using 'terraform validate'" | ||
echo "Please fix the validation errors for these, these can be found by running" | ||
echo "'terraform init' and then 'terraform validate':" | ||
for exampleDir in "${examplesWithErrors[@]}" | ||
do | ||
echo "- $exampleDir" | ||
done | ||
exit 1 | ||
fi | ||
|
||
exit 0 |