-
-
Save mrpatrick/6089368 to your computer and use it in GitHub Desktop.
Removing puppet-lint validation and from check
This file contains hidden or 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
#!/bin/bash | |
# pre-commit git hook to check the validity of a puppet manifest | |
# | |
# Prerequisites: | |
# gem install puppet-lint puppet | |
# | |
# Install: | |
# /path/to/repo/.git/hooks/pre-comit | |
echo "### Checking if puppet manifests are valid ###" | |
# validating the whole manifest takes too long. uncomment this | |
# if you want to test the whole shebang. | |
# for file in `find . -name "*.pp"` | |
# for file in `git diff --name-only --cached | grep -E '\.(pp|erb)'` | |
for file in `git diff --name-only --cached | grep -E '\.(pp)'` | |
do | |
if [[ -f $file ]] | |
then | |
puppet parser validate $file | |
if [[ $? -ne 0 ]] | |
then | |
echo "ERROR: puppet parser failed at: $file" | |
syntax_is_bad=1 | |
else | |
echo "OK: $file looks valid" | |
fi | |
fi | |
done | |
echo "" | |
if [[ $syntax_is_bad -eq 1 ]] | |
then | |
echo "FATAL: Syntax is bad. See above errors" | |
echo "Bailing" | |
exit 1 | |
else | |
echo "Everything looks good." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment