Merge "Add YAML sytax check"

This commit is contained in:
Jenkins 2015-12-21 11:29:10 +00:00 committed by Gerrit Code Review
commit 46dde66afd

View File

@ -1,5 +1,4 @@
#!/bin/bash #!/bin/bash
usage="$(basename "$0") [-h] [-m MODULE] [-a] -- runs syntax check for puppet modules, by default runs tests only for changed modules. usage="$(basename "$0") [-h] [-m MODULE] [-a] -- runs syntax check for puppet modules, by default runs tests only for changed modules.
where: where:
@ -88,7 +87,7 @@ function check_lint {
# Function that checks syntax # Function that checks syntax
function check_syntax { function check_syntax {
exit_code=0 exit_code=0
all_files=`find . -name "*.pp" -o -name "*.erb" -o -name "*.sh" -o -path "*/files/ocf/*"` all_files=`find . -name "*.pp" -o -name "*.erb" -o -name "*.sh" -o -name '*.yaml' -o -name '*.yml' -o -path "*/files/ocf/*"`
for x in $all_files; do for x in $all_files; do
case $x in case $x in
*.pp ) *.pp )
@ -100,6 +99,12 @@ function check_syntax {
*.sh ) *.sh )
bash -n $x bash -n $x
;; ;;
*.yaml | *.yml )
ruby -ryaml -e "
puts 'Checking YAML file: ${x}'
YAML.load_file('${x}')
exit(0)"
;;
*files/ocf/* ) *files/ocf/* )
case $(file --mime --brief $x) in case $(file --mime --brief $x) in
*x-shellscript*) *x-shellscript*)