File tree 3 files changed +23
-16
lines changed
3 files changed +23
-16
lines changed Original file line number Diff line number Diff line change 22
22
23
23
# Check YAML file syntax
24
24
$ERRORS_ONLY || echo -e " $( tput setaf 6) Checking yaml syntax for $module_path ...$( tput sgr0) "
25
- if test -e /usr/bin/yamllint
26
- then
25
+ if type yamllint > /dev/null 2>&1 ; then
27
26
yamllint $YAMLLINT_CONFIG -f parsable $1 & > " $error_msg "
28
27
else
29
28
ruby -e " require 'yaml'; YAML.parse(File.open('$1 '))" 2> " $error_msg " > /dev/null
Original file line number Diff line number Diff line change @@ -110,25 +110,29 @@ for changedfile in $files_to_check; do
110
110
echo " erb not installed. Skipping erb template checks..."
111
111
fi
112
112
113
- # check hiera data (yaml/yml/eyaml/eyml ) syntax
114
- if echo " $changedfile " | grep -iq ' \.e\?ya\?ml $' ; then
115
- ${subhook_root} /yaml_syntax_check .sh " $changedfile "
113
+ # check json (i.e. metadata.json ) syntax
114
+ if echo " $changedfile " | grep -iq ' \.json $' ; then
115
+ ${subhook_root} /json_syntax_check .sh " $changedfile "
116
116
RC=$?
117
117
if [[ " $RC " -ne 0 ]]; then
118
118
failures=$(( failures + 1 ))
119
119
fi
120
120
fi
121
+ else
122
+ echo " ruby not installed. Skipping erb/json checks..."
123
+ fi
121
124
122
- # check json (i.e. metadata.json) syntax
123
- if echo " $changedfile " | grep -iq ' \.json$' ; then
124
- ${subhook_root} /json_syntax_check.sh " $changedfile "
125
+ if type yamllint > /dev/null 2>&1 || type ruby > /dev/null 2>&1 ; then
126
+ # check hiera data (yaml/yml/eyaml/eyml) syntax
127
+ if echo " $changedfile " | grep -iq ' \.e\?ya\?ml$' ; then
128
+ ${subhook_root} /yaml_syntax_check.sh " $changedfile "
125
129
RC=$?
126
130
if [[ " $RC " -ne 0 ]]; then
127
131
failures=$(( failures + 1 ))
128
132
fi
129
133
fi
130
134
else
131
- echo " ruby not installed. Skipping erb/ yaml/json checks..."
135
+ echo " yamllint nor ruby not installed. Skipping yaml checks..."
132
136
fi
133
137
134
138
# puppet manifest styleguide compliance
Original file line number Diff line number Diff line change @@ -116,25 +116,29 @@ while read -r oldrev newrev refname; do
116
116
echo " erb not installed. Skipping erb template checks..."
117
117
fi
118
118
119
- # check hiera data (yaml/yml ) syntax
120
- if [[ $( echo " $changedfile " | grep -q ' \.*\.yaml$\|\.*\.yml $' ; echo $? ) -eq 0 ]]; then
121
- ${subhook_root} /yaml_syntax_check .sh " $tmpmodule " " ${tmptree} /"
119
+ # check hiera data (json ) syntax
120
+ if [[ $( echo " $changedfile " | grep -q ' \.*\.json $' ; echo $? ) -eq 0 ]]; then
121
+ ${subhook_root} /json_syntax_check .sh " $tmpmodule " " ${tmptree} /"
122
122
RC=$?
123
123
if [[ $RC -ne 0 ]]; then
124
124
failures=$(( failures + 1 ))
125
125
fi
126
126
fi
127
+ else
128
+ echo " ruby not installed. Skipping ruby/erb/json checks..."
129
+ fi
127
130
128
- # check hiera data (json) syntax
129
- if [[ $( echo " $changedfile " | grep -q ' \.*\.json$' ; echo $? ) -eq 0 ]]; then
130
- ${subhook_root} /json_syntax_check.sh " $tmpmodule " " ${tmptree} /"
131
+ if type yamllint > /dev/null 2>&1 || type ruby > /dev/null 2>&1 ; then
132
+ # check hiera data (yaml/yml/eyaml/eyml) syntax
133
+ if echo " $changedfile " | grep -iq ' \.e\?ya\?ml$' ; then
134
+ ${subhook_root} /yaml_syntax_check.sh " $tmpmodule " " ${tmptree} /"
131
135
RC=$?
132
136
if [[ $RC -ne 0 ]]; then
133
137
failures=$(( failures + 1 ))
134
138
fi
135
139
fi
136
140
else
137
- echo " ruby not installed. Skipping erb/ yaml/ruby checks..."
141
+ echo " yamllint nor ruby not installed. Skipping yaml checks..."
138
142
fi
139
143
140
144
# puppet manifest styleguide compliance
You can’t perform that action at this time.
0 commit comments