diff options
| author | Lars Kellogg-Stedman <lars@redhat.com> | 2014-10-14 12:17:47 -0400 |
|---|---|---|
| committer | Lars Kellogg-Stedman <lars@redhat.com> | 2014-10-14 15:21:22 -0400 |
| commit | bfbf1b8c9b3a0abba86474aeb72b950142723d73 (patch) | |
| tree | 6dd25e33a223a6f9011375b01a38302fe83e1968 /tools/validate-json.sh | |
| parent | 20e88776bc9b85b2a3a0f7a86004f6b04520e9a8 (diff) | |
| download | kolla-bfbf1b8c9b3a0abba86474aeb72b950142723d73.tar.gz kolla-bfbf1b8c9b3a0abba86474aeb72b950142723d73.zip | |
add better validation checks (part 1)
This patch adds a script for validating YAML files, and replaces the
existing JSON checks with one largely identical to the YAML check.
This also provides a script that can be installed as a pre-commit hook
that will perform this checks when you commit changes. You can install
the hook by running tools/pre-commit-hook --install.
Change-Id: Ib4742a9db062362cfa61d669c691151bc1ca376c
Diffstat (limited to 'tools/validate-json.sh')
| -rwxr-xr-x | tools/validate-json.sh | 35 |
1 files changed, 2 insertions, 33 deletions
diff --git a/tools/validate-json.sh b/tools/validate-json.sh index 35338e8d9..296ef781c 100755 --- a/tools/validate-json.sh +++ b/tools/validate-json.sh @@ -1,34 +1,3 @@ -#!/bin/bash -set -e -ret=0 +#!/bin/sh -# For MacOSX users the freebsd's mktemp by default behave diferently, -# installing the coreutils from brew would give you this but that would be -# renamed to gmktemp to don't conflict with the stand mktemp, so let just use -# that if available. -if type -p gmktemp &>/dev/null; then - TMPFILE=$(gmktemp) -else - TMPFILE=$(mktemp) -fi - -function clean { - rm -f ${TMPFILE} -} -trap clean EXIT - -linter=jsonlint -type -p jsonlint &>/dev/null || linter=python - -for f in $(find docker -type f -name '*.json');do - if [[ ${linter} == jsonlint ]];then - jsonlint -s ${f} >${TMPFILE} - egrep -q 'has errors$' ${TMPFILE} && { cat ${TMPFILE}; ret=1 ;} - else - python -m json.tool ${f} &>/dev/null || { echo "$f: has json errors"; ret=1; } - fi -done - -cat ${TMPFILE} - -exit ${ret} +true |
