Skip to content

Commit 412c4a2

Browse files
committed
chore: update scripts to pass shellcheck
See https://github.com/koalaman/shellcheck Remove unusued files: * push.sh * Dockerfile.e2e * frontend/test-e2e.sh
1 parent f31167a commit 412c4a2

14 files changed

+102
-191
lines changed

build-backend.sh

-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ set -e
55
# Builds the server-side golang resources for tectonic-console. For a
66
# complete build, you must also run build-frontend
77

8-
PROJECT_DIR=$(basename ${PWD})
9-
108
# Use deps from vendor dir.
119
export GOFLAGS="-mod=vendor"
1210

builder-run.sh

+8-8
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,22 @@ set -e
1414
BUILDER_IMAGE="quay.io/coreos/tectonic-console-builder:v19"
1515

1616
# forward whitelisted env variables to docker
17-
ENV_STR=""
18-
VOLUME_MOUNT=""
17+
ENV_STR=()
18+
VOLUME_MOUNT=()
1919
for VAR in ${DOCKER_ENV//,/ }; do
2020
if [ "$VAR" = 'KUBECONFIG' ]
2121
then
22-
VOLUME_MOUNT="-v $KUBECONFIG:/kube/config"
23-
ENV_STR="$ENV_STR -e KUBECONFIG=/kube/config"
22+
VOLUME_MOUNT=("-v" "$KUBECONFIG:/kube/config")
23+
ENV_STR+=("-e" "KUBECONFIG=/kube/config")
2424
else
25-
ENV_STR="$ENV_STR -e $VAR=${!VAR}"
25+
ENV_STR+=("-e" "$VAR=${!VAR}")
2626
fi
2727
done
2828

29-
docker run $ENV_STR --rm --net=host \
29+
docker run "${ENV_STR[@]}" --rm --net=host \
3030
--user="${BUILDER_RUN_USER}" \
31-
$VOLUME_MOUNT \
31+
"${VOLUME_MOUNT[@]}" \
3232
-v "$(pwd)":/go/src/github.com/openshift/console \
3333
--shm-size=512m \
3434
-w /go/src/github.com/openshift/console \
35-
$BUILDER_IMAGE "$@"
35+
"$BUILDER_IMAGE" "$@"

chromium-version.sh

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# shellcheck shell=bash
2+
# Source this script: "source ./chromium-version.sh"
3+
14
# Chrome Version 76.0.3809.0 (Developer Build) (64-bit)
25
export FORCE_CHROME_BRANCH_BASE="665006"
36
export FORCE_CHROME_BRANCH_SHA256SUM="a1ae2e0950828f991119825f62c24464ab3765aa219d150a94fb782a4c66a744"

contrib/environment.sh

+27-15
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,39 @@
1-
# This file is an example of how you might set up your environment to
2-
# run the tectonic console during development. To use it for running
3-
# bridge, do
1+
# shellcheck shell=bash
2+
#
3+
# NOTE: This script is for native Kubernetes. If connecting to an OpenShift
4+
# cluster instead, use contrib/oc-environment.sh.
5+
#
6+
# This file is an example of how you might set up your environment to run the
7+
# OpenShift console during development when connecting to a native Kubernetes
8+
# cluster. To use it for running bridge, do
49
#
510
# . contrib/environment.sh
611
# ./bin/bridge
712
#
13+
# You'll need a working kubectl, and you'll need jq installed and in your path
14+
# for this script to work correctly.
15+
#
16+
# This will use the first secret it finds in the default namespace. All secrets
17+
# must be valid or removed from the namespace.
18+
#
19+
# The environment variables beginning with "BRIDGE_" act just like bridge
20+
# command line arguments - in fact. to get more information about any of them,
21+
# you can run ./bin/bridge --help
822

9-
# You'll need a working kubectl, and you'll need jq installed and in
10-
# your path for this script to work correctly.
11-
12-
# This will use the first secret it finds in the default namespace.
13-
# All secrets must be valid or removed from the namespace.
23+
BRIDGE_USER_AUTH="disabled"
24+
export BRIDGE_USER_AUTH
1425

15-
# The environment variables beginning with "BRIDGE_" act just like
16-
# bridge command line arguments - in fact. to get more information
17-
# about any of them, you can run ./bin/bridge --help
26+
BRIDGE_K8S_MODE="off-cluster"
27+
export BRIDGE_K8S_MODE
1828

19-
export BRIDGE_USER_AUTH="disabled"
20-
export BRIDGE_K8S_MODE="off-cluster"
2129
BRIDGE_K8S_MODE_OFF_CLUSTER_ENDPOINT=$(kubectl config view -o json | jq '{myctx: .["current-context"], ctxs: .contexts[], clusters: .clusters[]}' | jq 'select(.myctx == .ctxs.name)' | jq 'select(.ctxs.context.cluster == .clusters.name)' | jq '.clusters.cluster.server' -r)
2230
export BRIDGE_K8S_MODE_OFF_CLUSTER_ENDPOINT
23-
export BRIDGE_K8S_MODE_OFF_CLUSTER_SKIP_VERIFY_TLS=true
24-
export BRIDGE_K8S_AUTH="bearer-token"
31+
32+
BRIDGE_K8S_MODE_OFF_CLUSTER_SKIP_VERIFY_TLS=true
33+
export BRIDGE_K8S_MODE_OFF_CLUSTER_SKIP_VERIFY_TLS
34+
35+
BRIDGE_K8S_AUTH="bearer-token"
36+
export BRIDGE_K8S_AUTH
2537

2638
secretname=$(kubectl get serviceaccount default --namespace=kube-system -o jsonpath='{.secrets[0].name}')
2739
BRIDGE_K8S_AUTH_BEARER_TOKEN=$(kubectl get secret "$secretname" --namespace=kube-system -o template --template='{{.data.token}}' | base64 --decode)

contrib/oc-environment.sh

+36-19
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,43 @@
1-
# This file is an example of how you might set up your environment to
2-
# run the tectonic console against OpenShift during development. To use it for running
3-
# bridge, do
1+
# shellcheck shell=bash
2+
#
3+
# This file is an example of how you might set up your environment to run the
4+
# console against an OpenShift cluster during development. To use it for
5+
# running bridge, do
46
#
57
# . contrib/oc-environment.sh
68
# ./bin/bridge
79
#
10+
# You'll need oc, and you'll need to be logged into a cluster.
11+
#
12+
# The environment variables beginning with "BRIDGE_" act just like bridge
13+
# command line arguments - in fact. to get more information about any of them,
14+
# you can run ./bin/bridge --help
15+
16+
BRIDGE_USER_AUTH="disabled"
17+
export BRIDGE_USER_AUTH
18+
19+
BRIDGE_K8S_MODE="off-cluster"
20+
export BRIDGE_K8S_MODE
21+
22+
BRIDGE_K8S_MODE_OFF_CLUSTER_ENDPOINT=$(oc whoami --show-server)
23+
export BRIDGE_K8S_MODE_OFF_CLUSTER_ENDPOINT
24+
25+
BRIDGE_K8S_MODE_OFF_CLUSTER_SKIP_VERIFY_TLS=true
26+
export BRIDGE_K8S_MODE_OFF_CLUSTER_SKIP_VERIFY_TLS
27+
28+
BRIDGE_K8S_MODE_OFF_CLUSTER_THANOS=$(oc -n openshift-monitoring get configmap sharing-config -o jsonpath='{.data.thanosURL}')
29+
export BRIDGE_K8S_MODE_OFF_CLUSTER_THANOS
30+
31+
BRIDGE_K8S_MODE_OFF_CLUSTER_PROMETHEUS=$(oc -n openshift-monitoring get configmap sharing-config -o jsonpath='{.data.prometheusURL}')
32+
export BRIDGE_K8S_MODE_OFF_CLUSTER_PROMETHEUS
33+
34+
BRIDGE_K8S_MODE_OFF_CLUSTER_ALERTMANAGER=$(oc -n openshift-monitoring get configmap sharing-config -o jsonpath='{.data.alertmanagerURL}')
35+
export BRIDGE_K8S_MODE_OFF_CLUSTER_ALERTMANAGER
36+
37+
BRIDGE_K8S_AUTH="bearer-token"
38+
export BRIDGE_K8S_AUTH
839

9-
# You'll need a working oc logged in, and you'll need jq installed and in your
10-
# path for this script to work correctly.
11-
12-
# The environment variables beginning with "BRIDGE_" act just like
13-
# bridge command line arguments - in fact. to get more information
14-
# about any of them, you can run ./bin/bridge --help
15-
16-
export BRIDGE_USER_AUTH="disabled"
17-
export BRIDGE_K8S_MODE="off-cluster"
18-
export BRIDGE_K8S_MODE_OFF_CLUSTER_ENDPOINT=$(oc whoami --show-server)
19-
export BRIDGE_K8S_MODE_OFF_CLUSTER_SKIP_VERIFY_TLS=true
20-
export BRIDGE_K8S_MODE_OFF_CLUSTER_THANOS=$(oc -n openshift-monitoring get configmap sharing-config -o jsonpath='{.data.thanosURL}')
21-
export BRIDGE_K8S_MODE_OFF_CLUSTER_PROMETHEUS=$(oc -n openshift-monitoring get configmap sharing-config -o jsonpath='{.data.prometheusURL}')
22-
export BRIDGE_K8S_MODE_OFF_CLUSTER_ALERTMANAGER=$(oc -n openshift-monitoring get configmap sharing-config -o jsonpath='{.data.alertmanagerURL}')
23-
export BRIDGE_K8S_AUTH="bearer-token"
24-
export BRIDGE_K8S_AUTH_BEARER_TOKEN=$(oc whoami --show-token)
40+
BRIDGE_K8S_AUTH_BEARER_TOKEN=$(oc whoami --show-token)
41+
export BRIDGE_K8S_AUTH_BEARER_TOKEN
2542

2643
echo "Using $BRIDGE_K8S_MODE_OFF_CLUSTER_ENDPOINT"

e2e.Dockerfile

-19
This file was deleted.

examples/run-bridge.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ set -exuo pipefail
77
--ca-file=examples/ca.crt \
88
--k8s-auth=openshift \
99
--k8s-mode=off-cluster \
10-
--k8s-mode-off-cluster-endpoint=$(oc whoami --show-server) \
10+
--k8s-mode-off-cluster-endpoint="$(oc whoami --show-server)" \
1111
--k8s-mode-off-cluster-skip-verify-tls=true \
1212
--listen=http://127.0.0.1:9000 \
1313
--public-dir=./frontend/public/dist \
1414
--user-auth=openshift \
1515
--user-auth-oidc-client-id=console-oauth-client \
1616
--user-auth-oidc-client-secret-file=examples/console-client-secret \
1717
--user-auth-oidc-ca-file=examples/ca.crt \
18-
--k8s-mode-off-cluster-prometheus=$(oc -n openshift-monitoring get configmap sharing-config -o jsonpath='{.data.prometheusURL}') \
19-
--k8s-mode-off-cluster-alertmanager=$(oc -n openshift-monitoring get configmap sharing-config -o jsonpath='{.data.alertmanagerURL}') \
20-
--k8s-mode-off-cluster-thanos=$(oc -n openshift-monitoring get configmap sharing-config -o jsonpath='{.data.prometheusURL}')
18+
--k8s-mode-off-cluster-prometheus="$(oc -n openshift-monitoring get configmap sharing-config -o jsonpath='{.data.prometheusURL}')" \
19+
--k8s-mode-off-cluster-alertmanager="$(oc -n openshift-monitoring get configmap sharing-config -o jsonpath='{.data.alertmanagerURL}')" \
20+
--k8s-mode-off-cluster-thanos="$(oc -n openshift-monitoring get configmap sharing-config -o jsonpath='{.data.prometheusURL}')"

frontend/test-e2e.sh

-58
This file was deleted.

push.sh

-45
This file was deleted.

shellcheck.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
shellcheck --external-sources -- *.sh contrib/*.sh examples/*.sh

test-backend.sh

+10-10
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ export GOFLAGS="-mod=vendor"
2121
COVER=${COVER:-"-cover"}
2222

2323
TESTABLE="pkg/auth pkg/proxy pkg/server pkg/helm/actions pkg/helm/handlers"
24-
FORMATTABLE="cmd pkg"
24+
FORMATTABLE=(cmd pkg)
2525

2626
# user has not provided PKG override
2727
if [ -z "${PKG}" ]; then
2828
TEST=${TESTABLE}
29-
FMT=${FORMATTABLE}
29+
FMT=("${FORMATTABLE[@]}")
3030

3131
# user has provided PKG override
3232
else
@@ -35,28 +35,28 @@ else
3535
TEST=${TEST//./}
3636

3737
# only run gofmt on packages provided by user
38-
FMT="${TEST}"
38+
FMT=("${TEST[@]}")
3939
fi
4040

4141
# split TEST into an array and prepend repo path to each local package
42-
split=(${TEST// / })
43-
TEST=${split[@]/#/github.com/openshift/console/}
42+
read -ra split <<<"$TEST"
43+
TEST=("${split[@]/#/github.com/openshift/console/}")
4444

4545
echo "Running tests..."
46-
go test ${COVER} $@ ${TEST}
46+
go test "${COVER}" "$@" "${TEST[@]}"
4747

4848
echo "Checking gofmt..."
49-
fmtRes=$(gofmt -l ${FMT})
49+
fmtRes=$(gofmt -l "${FMT[@]}")
5050
if [ -n "${fmtRes}" ]; then
5151
echo -e "gofmt checking failed:\n${fmtRes}"
5252
exit 255
5353
fi
5454

5555
echo "Checking govet..."
56-
vetRes=$(go vet ${TEST})
56+
vetRes=$(go vet "${TEST[@]}")
5757
if [ -n "${vetRes}" ]; then
58-
echo -e "govet checking failed:\n${vetRes}"
59-
exit 255
58+
echo -e "govet checking failed:\n${vetRes}"
59+
exit 255
6060
fi
6161

6262
echo "Success"

test-ciphers.sh

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
CONSOLE_URL=$(oc get console.config.openshift.io cluster --template '{{.status.consoleURL}}')
44
if [ -z "${CONSOLE_URL}" ]
@@ -22,8 +22,7 @@ VALID_CIPHER_SAMPLE=(
2222

2323
for CIPHER in "${VALID_CIPHER_SAMPLE[@]}"
2424
do
25-
RESULT=$(openssl s_client -connect "${SERVER}" -cipher "${CIPHER}" -CAfile /tmp/default-ingress-cert-file.txt 2>&1)
26-
if [[ $? -eq 0 ]]
25+
if openssl s_client -connect "${SERVER}" -cipher "${CIPHER}" -CAfile /tmp/default-ingress-cert-file.txt 2>&1
2726
then
2827
echo "valid cipher was correctly accepted (${CIPHER})"
2928
else
@@ -47,12 +46,11 @@ INVALID_CIPHER_SAMPLE=(
4746

4847
for CIPHER in "${INVALID_CIPHER_SAMPLE[@]}"
4948
do
50-
RESULT=$(openssl s_client -connect "${SERVER}" -cipher "${CIPHER}" -CAfile /tmp/default-ingress-cert-file.txt 2>&1)
51-
if [[ $? -eq 0 ]]
49+
if openssl s_client -connect "${SERVER}" -cipher "${CIPHER}" -CAfile /tmp/default-ingress-cert-file.txt 2>&1
5250
then
5351
echo "invalid cipher suite used to connect to console (${CIPHER})"
5452
exit 1
5553
else
5654
echo "invalid cipher was correctly denied (${CIPHER})"
5755
fi
58-
done
56+
done

0 commit comments

Comments
 (0)