Skip to content

Commit 79543a3

Browse files
Fix shellcheck issues in the kubectl-mongodb plugin scripts (#297)
# Summary This RP fixes the shellcheck (info) issues that we saw in the `kubectl-mongodb` plugin related scripts when we ran `make precommit`. Most of the issues are fixed when I didn't actually have to make any change but I had to disable check for some lines where it was expected to make some change and I was not sure if that would impact things functionally. ## Proof of Work NA
1 parent 7390ab5 commit 79543a3

File tree

3 files changed

+36
-32
lines changed

3 files changed

+36
-32
lines changed

scripts/release/kubectl-mongodb/install_istio_separate_network.sh

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,46 +15,46 @@ curl -L https://istio.io/downloadIstio | sh -
1515
function_check_external_ip_assigned() {
1616
while : ; do
1717
ip=$(kubectl --context="$1" get svc istio-eastwestgateway -n istio-system --output jsonpath='{.status.loadBalancer.ingress[0].ip}')
18-
if [ -n "$ip" ]
18+
if [ -n "${ip}" ]
1919
then
20-
echo "external ip assigned $ip"
20+
echo "external ip assigned ${ip}"
2121
break
2222
else
2323
echo "waiting for external ip to be assigned"
2424
fi
2525
done
2626
}
2727

28-
cd istio-${ISTIO_VERSION}
28+
cd "istio-${ISTIO_VERSION}"
2929
mkdir -p certs
3030
pushd certs
3131

3232
# create root trust for the clusters
3333
make -f ../tools/certs/Makefile.selfsigned.mk root-ca
34-
make -f ../tools/certs/Makefile.selfsigned.mk ${CTX_CLUSTER1}-cacerts
35-
make -f ../tools/certs/Makefile.selfsigned.mk ${CTX_CLUSTER2}-cacerts
36-
make -f ../tools/certs/Makefile.selfsigned.mk ${CTX_CLUSTER3}-cacerts
34+
make -f ../tools/certs/Makefile.selfsigned.mk "${CTX_CLUSTER1}-cacerts"
35+
make -f ../tools/certs/Makefile.selfsigned.mk "${CTX_CLUSTER2}-cacerts"
36+
make -f ../tools/certs/Makefile.selfsigned.mk "${CTX_CLUSTER3}-cacerts"
3737

3838
kubectl --context="${CTX_CLUSTER1}" create ns istio-system
3939
kubectl --context="${CTX_CLUSTER1}" create secret generic cacerts -n istio-system \
40-
--from-file=${CTX_CLUSTER1}/ca-cert.pem \
41-
--from-file=${CTX_CLUSTER1}/ca-key.pem \
42-
--from-file=${CTX_CLUSTER1}/root-cert.pem \
43-
--from-file=${CTX_CLUSTER1}/cert-chain.pem
40+
--from-file="${CTX_CLUSTER1}/ca-cert.pem" \
41+
--from-file="${CTX_CLUSTER1}/ca-key.pem" \
42+
--from-file="${CTX_CLUSTER1}/root-cert.pem" \
43+
--from-file="${CTX_CLUSTER1}/cert-chain.pem"
4444

4545
kubectl --context="${CTX_CLUSTER2}" create ns istio-system
4646
kubectl --context="${CTX_CLUSTER2}" create secret generic cacerts -n istio-system \
47-
--from-file=${CTX_CLUSTER2}/ca-cert.pem \
48-
--from-file=${CTX_CLUSTER2}/ca-key.pem \
49-
--from-file=${CTX_CLUSTER2}/root-cert.pem \
50-
--from-file=${CTX_CLUSTER2}/cert-chain.pem
47+
--from-file="${CTX_CLUSTER2}/ca-cert.pem" \
48+
--from-file="${CTX_CLUSTER2}/ca-key.pem" \
49+
--from-file="${CTX_CLUSTER2}/root-cert.pem" \
50+
--from-file="${CTX_CLUSTER2}/cert-chain.pem"
5151

5252
kubectl --context="${CTX_CLUSTER3}" create ns istio-system
5353
kubectl --context="${CTX_CLUSTER3}" create secret generic cacerts -n istio-system \
54-
--from-file=${CTX_CLUSTER3}/ca-cert.pem \
55-
--from-file=${CTX_CLUSTER3}/ca-key.pem \
56-
--from-file=${CTX_CLUSTER3}/root-cert.pem \
57-
--from-file=${CTX_CLUSTER3}/cert-chain.pem
54+
--from-file="${CTX_CLUSTER3}/ca-cert.pem" \
55+
--from-file="${CTX_CLUSTER3}/ca-key.pem" \
56+
--from-file="${CTX_CLUSTER3}/root-cert.pem" \
57+
--from-file="${CTX_CLUSTER3}/cert-chain.pem"
5858
popd
5959

6060
# label namespace in cluster1
@@ -184,5 +184,5 @@ bin/istioctl x create-remote-secret \
184184

185185
# cleanup: delete the istio repo at the end
186186
cd ..
187-
rm -r istio-${ISTIO_VERSION}
187+
rm -r "istio-${ISTIO_VERSION}"
188188
rm -f cluster1.yaml cluster2.yaml cluster3.yaml

scripts/release/kubectl-mongodb/sign.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#!/usr/bin/env bash
2+
# Disables shellcheck on lines 15-21, because vars seem to be assigned to themselves.
3+
# and we are not sure if removing this would be an issue.
4+
# shellcheck disable=SC2269
25

36
set -euo pipefail
47

@@ -28,14 +31,14 @@ echo "Signing artifact ${ARTIFACT} and saving signature to ${SIGNATURE}"
2831
} > "${SIGNING_ENVFILE}"
2932

3033
echo "Logging in artifactory.corp"
31-
echo ${ARTIFACTORY_PASSWORD} | docker login --password-stdin --username ${ARTIFACTORY_USERNAME} ${ARTIFACTORY_URL}
34+
echo "${ARTIFACTORY_PASSWORD}" | docker login --password-stdin --username "${ARTIFACTORY_USERNAME}" "${ARTIFACTORY_URL}"
3235

3336
echo "Signing artifact"
3437
echo "Envfile is ${SIGNING_ENVFILE}"
3538
docker run \
3639
--env-file="${SIGNING_ENVFILE}" \
3740
--rm \
38-
-v $(pwd):$(pwd) \
39-
-w $(pwd) \
40-
${SIGNING_IMAGE_URI} \
41-
cosign sign-blob --key "${PKCS11_URI}" --output-signature ${SIGNATURE} ${ARTIFACT} --yes
41+
-v "$(pwd)":"$(pwd)" \
42+
-w "$(pwd)" \
43+
"${SIGNING_IMAGE_URI}" \
44+
cosign sign-blob --key "${PKCS11_URI}" --output-signature "${SIGNATURE}" "${ARTIFACT}" --yes

scripts/release/kubectl-mongodb/verify.sh

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ SIGNATURE="${ARTIFACT}.sig"
1111
HOSTED_SIGN_PUBKEY="https://cosign.mongodb.com/mongodb-enterprise-kubernetes-operator.pem" # to complete
1212
TMPDIR=${TMPDIR:-/tmp}
1313
KEY_FILE="${TMPDIR}/host-public.key"
14-
SIGNING_IMAGE_URI=${SIGNING_IMAGE_URI}
14+
# shellcheck disable=SC2269
15+
SIGNING_IMAGE_URI="${SIGNING_IMAGE_URI}"
1516

16-
curl -o ${KEY_FILE} "${HOSTED_SIGN_PUBKEY}"
17+
curl -o "${KEY_FILE}" "${HOSTED_SIGN_PUBKEY}"
1718
echo "Verifying signature ${SIGNATURE} of artifact ${ARTIFACT}"
1819
echo "Keyfile is ${KEY_FILE}"
1920

@@ -22,11 +23,11 @@ echo "Keyfile is ${KEY_FILE}"
2223

2324
docker run \
2425
--rm \
25-
-v $(pwd):$(pwd) \
26-
-v ${KEY_FILE}:${KEY_FILE} \
27-
-w $(pwd) \
28-
${SIGNING_IMAGE_URI} \
29-
cosign verify-blob --key ${KEY_FILE} --signature ${SIGNATURE} ${ARTIFACT}
26+
-v "$(pwd)":"$(pwd)" \
27+
-v "${KEY_FILE}":"${KEY_FILE}" \
28+
-w "$(pwd)" \
29+
"${SIGNING_IMAGE_URI}" \
30+
cosign verify-blob --key "${KEY_FILE}" --signature "${SIGNATURE}" "${ARTIFACT}"
3031

3132
# Without below line, Evergreen fails at archiving with "open dist/kubectl-[...]/kubectl-mongodb.sig: permission denied
32-
sudo chmod 666 ${SIGNATURE}
33+
sudo chmod 666 "${SIGNATURE}"

0 commit comments

Comments
 (0)