format: Introduce shellcheck [1] for shell script analysis

[1] https://github.com/koalaman/shellcheck
This commit is contained in:
Max Leonard Inden
2018-06-18 23:00:48 +02:00
parent 17477a1107
commit cd709826c9
5 changed files with 12 additions and 13 deletions

View File

@@ -3,8 +3,6 @@ JSONNET_FMT := jsonnet fmt -n 2 --max-blank-lines 2 --string-style s --comment-s
JB_BINARY:=$(GOPATH)/bin/jb
EMBEDMD_BINARY:=$(GOPATH)/bin/embedmd
# edit 1
all: generate fmt test
../../hack/jsonnet-docker-image: ../../scripts/jsonnet/Dockerfile
@@ -26,10 +24,9 @@ generate-in-docker: ../../hack/jsonnet-docker-image
generate: manifests **.md
**.md: $(EMBEDMD_BINARY) $(shell find examples) build.sh example.jsonnet
echo '>>> inside **.md'
$(EMBEDMD_BINARY) -w `find . -name "*.md" | grep -v vendor`
manifests: vendor example.jsonnet
manifests: vendor example.jsonnet build.sh
rm -rf manifests
./build.sh

View File

@@ -112,7 +112,7 @@ rm -rf manifests
mkdir manifests
# optional, but we would like to generate yaml, not json
jsonnet -J vendor -m manifests ${1-example.jsonnet} | xargs -I{} sh -c 'cat $1 | gojsontoyaml > $1.yaml; rm -f $1' -- {}
jsonnet -J vendor -m manifests "${1-example.jsonnet}" | xargs -I{} sh -c 'cat {} | gojsontoyaml > {}.yaml; rm -f {}' -- {}
```

View File

@@ -9,5 +9,5 @@ rm -rf manifests
mkdir manifests
# optional, but we would like to generate yaml, not json
jsonnet -J vendor -m manifests ${1-example.jsonnet} | xargs -I{} sh -c 'cat $1 | gojsontoyaml > $1.yaml; rm -f $1' -- {}
jsonnet -J vendor -m manifests "${1-example.jsonnet}" | xargs -I{} sh -c 'cat {} | gojsontoyaml > {}.yaml; rm -f {}' -- {}

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# Detect if we are on mac or should use GNU base64 options
case `uname` in
case $(uname) in
Darwin)
b64_opts='-b=0'
;;
@@ -17,7 +17,8 @@ echo '{"signing":{"default":{"expiry":"43800h","usages":["signing","key encipher
export SERVICE_NAME=custom-metrics-apiserver
export ALT_NAMES='"custom-metrics-apiserver.monitoring","custom-metrics-apiserver.monitoring.svc"'
echo '{"CN":"'${SERVICE_NAME}'","hosts":['${ALT_NAMES}'],"key":{"algo":"rsa","size":2048}}' | cfssl gencert -ca=metrics-ca.crt -ca-key=metrics-ca.key -config=metrics-ca-config.json - | cfssljson -bare apiserver
echo "{\"CN\":\"${SERVICE_NAME}\", \"hosts\": [${ALT_NAMES}], \"key\": {\"algo\": \"rsa\",\"size\": 2048}}" | \
cfssl gencert -ca=metrics-ca.crt -ca-key=metrics-ca.key -config=metrics-ca-config.json - | cfssljson -bare apiserver
cat <<-EOF > cm-adapter-serving-certs.yaml
apiVersion: v1
@@ -25,6 +26,6 @@ kind: Secret
metadata:
name: cm-adapter-serving-certs
data:
serving.crt: $(cat apiserver.pem | base64 ${b64_opts})
serving.key: $(cat apiserver-key.pem | base64 ${b64_opts})
serving.crt: $(base64 ${b64_opts} < apiserver.pem)
serving.key: $(base64 ${b64_opts} < apiserver-key.pem)
EOF

View File

@@ -8,7 +8,8 @@ for i in examples/jsonnet-snippets/*.jsonnet; do
[ -f "$i" ] || break
echo "Testing: ${i}"
echo ""
snippet="local kp = $(<${i});
fileContent=$(<"$i")
snippet="local kp = $fileContent;
$(<examples/jsonnet-build-snippet/build-snippet.jsonnet)"
echo "${snippet}" > "test.jsonnet"
@@ -25,8 +26,8 @@ for i in examples/*.jsonnet; do
echo "Testing: ${i}"
echo ""
echo "\`\`\`"
echo "$(<${i})"
cat "${i}"
echo "\`\`\`"
echo ""
jsonnet -J vendor ${i} > /dev/null
jsonnet -J vendor "${i}" > /dev/null
done