Skip to content

Commit

Permalink
format: Introduce shellcheck [1] for shell script analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
mxinden committed Jul 8, 2018
1 parent 17477a1 commit cd70982
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}' -- {}

```

Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}' -- {}

9 changes: 5 additions & 4 deletions experimental/custom-metrics-api/gencerts.sh
Original file line number Diff line number Diff line change
@@ -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'
;;
Expand All @@ -17,14 +17,15 @@ 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
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
7 changes: 4 additions & 3 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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

0 comments on commit cd70982

Please sign in to comment.