blob: 35338e8d958dfa5a8a2658c5bcfd58be46d17cf7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#!/bin/bash
set -e
ret=0
# 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}
|