-
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.
Merge pull request #1 from ucraft-com/terraform
add terraform-docs tool in pre-commit
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
|
||
echo "Start git pre-commit hooks"; | ||
|
||
echo "Start terraform docs"; | ||
for i in `ls -d */`;do | ||
if ! git diff --cached --quiet "${i}" | ||
then | ||
echo "Generating doc file: ${i}"; | ||
terraform-docs markdown table --output-file README.md --output-mode inject "${i}"; | ||
fi | ||
done | ||
echo "End terraform docs"; | ||
|
||
echo "Start terraform fmt"; | ||
for y in $(find . -name '*.tf' -print) | ||
do | ||
if ! git diff --cached --quiet "${y}" | ||
then | ||
echo "Formatting the file: ${y}"; | ||
terraform fmt -write=true "${y}" | ||
fi | ||
done | ||
echo "End terraform fmt"; | ||
|
||
echo "End git pre-commit hooks"; |