Skip to content

Commit

Permalink
chore: update scripts to pass shellcheck
Browse files Browse the repository at this point in the history
See https://github.com/koalaman/shellcheck

Remove unusued files:
* push.sh
* Dockerfile.e2e
* frontend/test-e2e.sh
  • Loading branch information
spadgett committed Feb 22, 2020
1 parent f31167a commit 412c4a2
Show file tree
Hide file tree
Showing 14 changed files with 102 additions and 191 deletions.
2 changes: 0 additions & 2 deletions build-backend.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ set -e
# Builds the server-side golang resources for tectonic-console. For a
# complete build, you must also run build-frontend

PROJECT_DIR=$(basename ${PWD})

# Use deps from vendor dir.
export GOFLAGS="-mod=vendor"

Expand Down
16 changes: 8 additions & 8 deletions builder-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ set -e
BUILDER_IMAGE="quay.io/coreos/tectonic-console-builder:v19"

# forward whitelisted env variables to docker
ENV_STR=""
VOLUME_MOUNT=""
ENV_STR=()
VOLUME_MOUNT=()
for VAR in ${DOCKER_ENV//,/ }; do
if [ "$VAR" = 'KUBECONFIG' ]
then
VOLUME_MOUNT="-v $KUBECONFIG:/kube/config"
ENV_STR="$ENV_STR -e KUBECONFIG=/kube/config"
VOLUME_MOUNT=("-v" "$KUBECONFIG:/kube/config")
ENV_STR+=("-e" "KUBECONFIG=/kube/config")
else
ENV_STR="$ENV_STR -e $VAR=${!VAR}"
ENV_STR+=("-e" "$VAR=${!VAR}")
fi
done

docker run $ENV_STR --rm --net=host \
docker run "${ENV_STR[@]}" --rm --net=host \
--user="${BUILDER_RUN_USER}" \
$VOLUME_MOUNT \
"${VOLUME_MOUNT[@]}" \
-v "$(pwd)":/go/src/github.com/openshift/console \
--shm-size=512m \
-w /go/src/github.com/openshift/console \
$BUILDER_IMAGE "$@"
"$BUILDER_IMAGE" "$@"
3 changes: 3 additions & 0 deletions chromium-version.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# shellcheck shell=bash
# Source this script: "source ./chromium-version.sh"

# Chrome Version 76.0.3809.0 (Developer Build) (64-bit)
export FORCE_CHROME_BRANCH_BASE="665006"
export FORCE_CHROME_BRANCH_SHA256SUM="a1ae2e0950828f991119825f62c24464ab3765aa219d150a94fb782a4c66a744"
42 changes: 27 additions & 15 deletions contrib/environment.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,39 @@
# This file is an example of how you might set up your environment to
# run the tectonic console during development. To use it for running
# bridge, do
# shellcheck shell=bash
#
# NOTE: This script is for native Kubernetes. If connecting to an OpenShift
# cluster instead, use contrib/oc-environment.sh.
#
# This file is an example of how you might set up your environment to run the
# OpenShift console during development when connecting to a native Kubernetes
# cluster. To use it for running bridge, do
#
# . contrib/environment.sh
# ./bin/bridge
#
# You'll need a working kubectl, and you'll need jq installed and in your path
# for this script to work correctly.
#
# This will use the first secret it finds in the default namespace. All secrets
# must be valid or removed from the namespace.
#
# The environment variables beginning with "BRIDGE_" act just like bridge
# command line arguments - in fact. to get more information about any of them,
# you can run ./bin/bridge --help

# You'll need a working kubectl, and you'll need jq installed and in
# your path for this script to work correctly.

# This will use the first secret it finds in the default namespace.
# All secrets must be valid or removed from the namespace.
BRIDGE_USER_AUTH="disabled"
export BRIDGE_USER_AUTH

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

export BRIDGE_USER_AUTH="disabled"
export BRIDGE_K8S_MODE="off-cluster"
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)
export BRIDGE_K8S_MODE_OFF_CLUSTER_ENDPOINT
export BRIDGE_K8S_MODE_OFF_CLUSTER_SKIP_VERIFY_TLS=true
export BRIDGE_K8S_AUTH="bearer-token"

BRIDGE_K8S_MODE_OFF_CLUSTER_SKIP_VERIFY_TLS=true
export BRIDGE_K8S_MODE_OFF_CLUSTER_SKIP_VERIFY_TLS

BRIDGE_K8S_AUTH="bearer-token"
export BRIDGE_K8S_AUTH

secretname=$(kubectl get serviceaccount default --namespace=kube-system -o jsonpath='{.secrets[0].name}')
BRIDGE_K8S_AUTH_BEARER_TOKEN=$(kubectl get secret "$secretname" --namespace=kube-system -o template --template='{{.data.token}}' | base64 --decode)
Expand Down
55 changes: 36 additions & 19 deletions contrib/oc-environment.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,43 @@
# This file is an example of how you might set up your environment to
# run the tectonic console against OpenShift during development. To use it for running
# bridge, do
# shellcheck shell=bash
#
# This file is an example of how you might set up your environment to run the
# console against an OpenShift cluster during development. To use it for
# running bridge, do
#
# . contrib/oc-environment.sh
# ./bin/bridge
#
# You'll need oc, and you'll need to be logged into a cluster.
#
# The environment variables beginning with "BRIDGE_" act just like bridge
# command line arguments - in fact. to get more information about any of them,
# you can run ./bin/bridge --help

BRIDGE_USER_AUTH="disabled"
export BRIDGE_USER_AUTH

BRIDGE_K8S_MODE="off-cluster"
export BRIDGE_K8S_MODE

BRIDGE_K8S_MODE_OFF_CLUSTER_ENDPOINT=$(oc whoami --show-server)
export BRIDGE_K8S_MODE_OFF_CLUSTER_ENDPOINT

BRIDGE_K8S_MODE_OFF_CLUSTER_SKIP_VERIFY_TLS=true
export BRIDGE_K8S_MODE_OFF_CLUSTER_SKIP_VERIFY_TLS

BRIDGE_K8S_MODE_OFF_CLUSTER_THANOS=$(oc -n openshift-monitoring get configmap sharing-config -o jsonpath='{.data.thanosURL}')
export BRIDGE_K8S_MODE_OFF_CLUSTER_THANOS

BRIDGE_K8S_MODE_OFF_CLUSTER_PROMETHEUS=$(oc -n openshift-monitoring get configmap sharing-config -o jsonpath='{.data.prometheusURL}')
export BRIDGE_K8S_MODE_OFF_CLUSTER_PROMETHEUS

BRIDGE_K8S_MODE_OFF_CLUSTER_ALERTMANAGER=$(oc -n openshift-monitoring get configmap sharing-config -o jsonpath='{.data.alertmanagerURL}')
export BRIDGE_K8S_MODE_OFF_CLUSTER_ALERTMANAGER

BRIDGE_K8S_AUTH="bearer-token"
export BRIDGE_K8S_AUTH

# You'll need a working oc logged in, and you'll need jq installed and in your
# path for this script to work correctly.

# The environment variables beginning with "BRIDGE_" act just like
# bridge command line arguments - in fact. to get more information
# about any of them, you can run ./bin/bridge --help

export BRIDGE_USER_AUTH="disabled"
export BRIDGE_K8S_MODE="off-cluster"
export BRIDGE_K8S_MODE_OFF_CLUSTER_ENDPOINT=$(oc whoami --show-server)
export BRIDGE_K8S_MODE_OFF_CLUSTER_SKIP_VERIFY_TLS=true
export BRIDGE_K8S_MODE_OFF_CLUSTER_THANOS=$(oc -n openshift-monitoring get configmap sharing-config -o jsonpath='{.data.thanosURL}')
export BRIDGE_K8S_MODE_OFF_CLUSTER_PROMETHEUS=$(oc -n openshift-monitoring get configmap sharing-config -o jsonpath='{.data.prometheusURL}')
export BRIDGE_K8S_MODE_OFF_CLUSTER_ALERTMANAGER=$(oc -n openshift-monitoring get configmap sharing-config -o jsonpath='{.data.alertmanagerURL}')
export BRIDGE_K8S_AUTH="bearer-token"
export BRIDGE_K8S_AUTH_BEARER_TOKEN=$(oc whoami --show-token)
BRIDGE_K8S_AUTH_BEARER_TOKEN=$(oc whoami --show-token)
export BRIDGE_K8S_AUTH_BEARER_TOKEN

echo "Using $BRIDGE_K8S_MODE_OFF_CLUSTER_ENDPOINT"
19 changes: 0 additions & 19 deletions e2e.Dockerfile

This file was deleted.

8 changes: 4 additions & 4 deletions examples/run-bridge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ set -exuo pipefail
--ca-file=examples/ca.crt \
--k8s-auth=openshift \
--k8s-mode=off-cluster \
--k8s-mode-off-cluster-endpoint=$(oc whoami --show-server) \
--k8s-mode-off-cluster-endpoint="$(oc whoami --show-server)" \
--k8s-mode-off-cluster-skip-verify-tls=true \
--listen=http://127.0.0.1:9000 \
--public-dir=./frontend/public/dist \
--user-auth=openshift \
--user-auth-oidc-client-id=console-oauth-client \
--user-auth-oidc-client-secret-file=examples/console-client-secret \
--user-auth-oidc-ca-file=examples/ca.crt \
--k8s-mode-off-cluster-prometheus=$(oc -n openshift-monitoring get configmap sharing-config -o jsonpath='{.data.prometheusURL}') \
--k8s-mode-off-cluster-alertmanager=$(oc -n openshift-monitoring get configmap sharing-config -o jsonpath='{.data.alertmanagerURL}') \
--k8s-mode-off-cluster-thanos=$(oc -n openshift-monitoring get configmap sharing-config -o jsonpath='{.data.prometheusURL}')
--k8s-mode-off-cluster-prometheus="$(oc -n openshift-monitoring get configmap sharing-config -o jsonpath='{.data.prometheusURL}')" \
--k8s-mode-off-cluster-alertmanager="$(oc -n openshift-monitoring get configmap sharing-config -o jsonpath='{.data.alertmanagerURL}')" \
--k8s-mode-off-cluster-thanos="$(oc -n openshift-monitoring get configmap sharing-config -o jsonpath='{.data.prometheusURL}')"
58 changes: 0 additions & 58 deletions frontend/test-e2e.sh

This file was deleted.

45 changes: 0 additions & 45 deletions push.sh

This file was deleted.

3 changes: 3 additions & 0 deletions shellcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

shellcheck --external-sources -- *.sh contrib/*.sh examples/*.sh
20 changes: 10 additions & 10 deletions test-backend.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ export GOFLAGS="-mod=vendor"
COVER=${COVER:-"-cover"}

TESTABLE="pkg/auth pkg/proxy pkg/server pkg/helm/actions pkg/helm/handlers"
FORMATTABLE="cmd pkg"
FORMATTABLE=(cmd pkg)

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

# user has provided PKG override
else
Expand All @@ -35,28 +35,28 @@ else
TEST=${TEST//./}

# only run gofmt on packages provided by user
FMT="${TEST}"
FMT=("${TEST[@]}")
fi

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

echo "Running tests..."
go test ${COVER} $@ ${TEST}
go test "${COVER}" "$@" "${TEST[@]}"

echo "Checking gofmt..."
fmtRes=$(gofmt -l ${FMT})
fmtRes=$(gofmt -l "${FMT[@]}")
if [ -n "${fmtRes}" ]; then
echo -e "gofmt checking failed:\n${fmtRes}"
exit 255
fi

echo "Checking govet..."
vetRes=$(go vet ${TEST})
vetRes=$(go vet "${TEST[@]}")
if [ -n "${vetRes}" ]; then
echo -e "govet checking failed:\n${vetRes}"
exit 255
echo -e "govet checking failed:\n${vetRes}"
exit 255
fi

echo "Success"
10 changes: 4 additions & 6 deletions test-ciphers.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

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

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

for CIPHER in "${INVALID_CIPHER_SAMPLE[@]}"
do
RESULT=$(openssl s_client -connect "${SERVER}" -cipher "${CIPHER}" -CAfile /tmp/default-ingress-cert-file.txt 2>&1)
if [[ $? -eq 0 ]]
if openssl s_client -connect "${SERVER}" -cipher "${CIPHER}" -CAfile /tmp/default-ingress-cert-file.txt 2>&1
then
echo "invalid cipher suite used to connect to console (${CIPHER})"
exit 1
else
echo "invalid cipher was correctly denied (${CIPHER})"
fi
done
done
Loading

0 comments on commit 412c4a2

Please sign in to comment.