Permalink
Browse files

Changed way of linting YAML files. (#90)

* Changed way of linting YAML files.

* Fixed checking for puppet syntax
  • Loading branch information...
krzyzakp committed Dec 5, 2016
1 parent 0d54866 commit d315776feb71f506917ebf4fb513013b4da12273
Showing with 6 additions and 12 deletions.
  1. +1 −0 Gemfile
  2. +3 −10 commit_hooks/puppet_manifest_syntax_check.sh
  3. +1 −1 commit_hooks/yaml_syntax_check.sh
  4. +1 −1 pre-commit
View
@@ -5,5 +5,6 @@ gem 'rspec-puppet'
gem 'json_pure'
gem 'psych'
gem 'metadata-json-lint'
gem 'yaml-lint'
gem 'puppet', '3.8.6'
gem 'puppet-lint', '2.0.0'
@@ -4,19 +4,12 @@
# to a puppet manifest file for which it will run syntax checks against.
manifest_path="$1"
module_dir="$2"
USE_PUPPET_FUTURE_PARSER="$3"
USE_PUPPET_FUTURE_PARSER="$2"
syntax_errors=0
error_msg=$(mktemp /tmp/error_msg_puppet-syntax.XXXXX)
if [[ $module_dir ]]; then
manifest_name="${manifest_path##*$module_dir}"
error_msg_filter="sed -e s|$module_dir||"
else
manifest_name="$manifest_path"
error_msg_filter="sed"
fi
manifest_name="$manifest_path"
error_msg_filter="sed"
# Get list of new/modified manifest and template files to check (in git index)
# Check puppet manifest syntax
@@ -14,7 +14,7 @@ fi
# Check YAML file syntax
$ERRORS_ONLY || echo -e "$(tput setaf 6)Checking yaml syntax for $module_path...$(tput sgr0)"
ruby -e "require 'yaml'; YAML.parse(File.open('$1'))" 2> "$error_msg" > /dev/null
yaml-lint $1 > "$error_msg"
if [ $? -ne 0 ]; then
sed -e "s/^/$(tput setaf 1)/" -e "s/$/$(tput sgr0)/" "$error_msg"
syntax_errors=$((syntax_errors + 1))
View
@@ -82,7 +82,7 @@ for changedfile in $files_to_check; do
failures=$((failures + 1))
fi
elif echo "$changedfile" | grep -iq '\.pp$'; then
${subhook_root}/puppet_manifest_syntax_check.sh "$changedfile_native" "" "$USE_PUPPET_FUTURE_PARSER"
${subhook_root}/puppet_manifest_syntax_check.sh "$changedfile_native" "$USE_PUPPET_FUTURE_PARSER"
RC=$?
if [[ "$RC" -ne 0 ]]; then
failures=$((failures + 1))

0 comments on commit d315776

Please sign in to comment.