From 2b327d5ca8fb41a24f3d07b239eede76129e9162 Mon Sep 17 00:00:00 2001 From: Manuel Alejandro de Brito Fontes Date: Wed, 26 May 2021 21:48:14 -0400 Subject: [PATCH 1/2] Run shellcheck against scripts --- components/BUILD.yaml | 4 +-- components/blobserve/telepresence.sh | 2 +- components/common-go/go-get-kubernetes.sh | 8 +++-- components/content-service-api/generate.sh | 11 +++---- components/dashboard/remove-sources.sh | 10 ++++--- components/ide/code/startup.sh | 10 ++++--- components/ide/theia/package-libs.sh | 14 ++++----- components/ide/theia/startup.sh | 10 ++++--- components/image-builder-api/generate.sh | 11 +++---- components/image-builder/debug.sh | 4 +-- .../gitpod-layer/alpine/gitpod/layer.sh | 6 ++-- .../gitpod-layer/debian/gitpod/layer.sh | 6 ++-- .../scripts/generate-dockerfile.sh | 6 ++-- .../tests/positive/verify.sh | 2 +- .../workspace-image-layer/tests/runtests.sh | 20 ++++++------- components/local-app-api/generate.sh | 19 ++++++------ .../local-app-api/typescript-grpcweb/build.sh | 4 +-- components/registry-facade-api/generate.sh | 9 +++--- components/registry-facade/telepresence.sh | 2 +- components/supervisor-api/generate.sh | 20 +++++++------ .../supervisor-api/typescript-grpc/build.sh | 29 +++++++++---------- .../typescript-grpcweb/build.sh | 14 +++++---- .../supervisor-api/typescript-rest/build.sh | 22 ++++++++------ components/ws-daemon-api/generate.sh | 23 ++++++++------- components/ws-daemon/debug.sh | 2 +- .../seccomp-profile-installer/generate.sh | 0 .../shiftfs-module-loader/entrypoint.sh | 9 +++--- components/ws-manager-api/generate.sh | 13 +++++---- components/ws-manager-bridge-api/generate.sh | 11 +++---- components/ws-manager/telepresence.sh | 2 +- components/ws-proxy/telepresence.sh | 4 +-- .../certs/create-letsencrypt-certs.sh | 3 +- .../gitpod-gitlab/gitlab/entrypoint.sh | 19 +++++++----- install/docker/gitpod-image/entrypoint.sh | 8 +++-- install/installer/entrypoint.sh | 6 ++-- scripts/branch-namespace.sh | 6 ++-- scripts/go-licenses.sh | 18 ++++++------ scripts/protoc-generator.sh | 25 ++++++++-------- test/entrypoint.sh | 3 +- test/leeway-build.sh | 16 +++++----- 40 files changed, 222 insertions(+), 189 deletions(-) mode change 100644 => 100755 components/supervisor-api/typescript-rest/build.sh delete mode 100644 components/ws-daemon/seccomp-profile-installer/generate.sh diff --git a/components/BUILD.yaml b/components/BUILD.yaml index c1a164eff2e94b..f0b3a2cb50a996 100644 --- a/components/BUILD.yaml +++ b/components/BUILD.yaml @@ -99,7 +99,7 @@ scripts: srcs: - components/**/* script: | - GO_COMPONENTS=( content-service-api image-builder-api registry-facade-api supervisor-api ws-daemon-api ws-manager-api ws-manager-bridge-api ) + GO_COMPONENTS=( local-app-api content-service-api image-builder-api registry-facade-api supervisor-api ws-daemon-api ws-manager-api ws-manager-bridge-api ) for COMPONENT in "${GO_COMPONENTS[@]}";do echo "Generating code for component $COMPONENT..." @@ -108,7 +108,7 @@ scripts: popd > /dev/null done - WEB_COMPONENTS=( supervisor-api/typescript-grpc supervisor-api/typescript-rest supervisor-api/typescript-grpcweb ) + WEB_COMPONENTS=( local-app-api/typescript-grpcweb supervisor-api/typescript-grpc supervisor-api/typescript-rest supervisor-api/typescript-grpcweb ) for COMPONENT in "${WEB_COMPONENTS[@]}";do echo "Generating code for component $COMPONENT..." pushd $COMPONENT > /dev/null diff --git a/components/blobserve/telepresence.sh b/components/blobserve/telepresence.sh index 97f8ef841ba7dc..50c86c1697d789 100755 --- a/components/blobserve/telepresence.sh +++ b/components/blobserve/telepresence.sh @@ -11,4 +11,4 @@ if [ "$1" == "intp" ]; then exit $? fi -telepresence --mount /tmp/c --swap-deployment registry-facade --method vpn-tcp --run $0 dbg-intp +telepresence --mount /tmp/c --swap-deployment registry-facade --method vpn-tcp --run "$0" dbg-intp diff --git a/components/common-go/go-get-kubernetes.sh b/components/common-go/go-get-kubernetes.sh index 5480ec88c85ebd..3cacbf230f4fb9 100755 --- a/components/common-go/go-get-kubernetes.sh +++ b/components/common-go/go-get-kubernetes.sh @@ -18,15 +18,16 @@ fi set -euo pipefail echo "Retrieving kubernetes module file" -GM=$(go mod download -json k8s.io/kubernetes@v1.$VERSION | jq -r .GoMod) -MODS=($(cat $GM | egrep "^\s+k8s.io/.*v0.0.0$" | tr -d '\t' | cut -d ' ' -f 1)) +GM=$(go mod download -json k8s.io/kubernetes@v1."$VERSION" | jq -r .GoMod) +# shellcheck disable=SC2002,SC2207 +MODS=($(cat "$GM" | grep -E "^\s+k8s.io/.*v0.0.0$" | tr -d '\t' | cut -d ' ' -f 1)) useSemver=$(echo "console.log(\"1.${VERSION}\" >= \"1.17\")" | node -) if [ "$useSemver" = "true" ]; then echo "Version is newer than 1.17 - using semver" fi -echo "Adding ${MODS[@]}" +echo Adding "${MODS[@]}" for MOD in "${MODS[@]}"; do if [ "$useSemver" = "true" ]; then V="v0.${VERSION}" @@ -35,4 +36,5 @@ for MOD in "${MODS[@]}"; do fi go mod edit "-replace=${MOD}=${MOD}@${V}" done + go get -v ./... diff --git a/components/content-service-api/generate.sh b/components/content-service-api/generate.sh index 230e38e8caea47..2c8f8b07e17792 100755 --- a/components/content-service-api/generate.sh +++ b/components/content-service-api/generate.sh @@ -8,15 +8,16 @@ set -o errexit set -o nounset set -o pipefail -ROOT_DIR=$(cd $(dirname "${BASH_SOURCE}") && pwd -P)/../../ -COMPONENTS_DIR=$ROOT_DIR/components +ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)/../../ +COMPONENTS_DIR="$ROOT_DIR"/components # include protoc bash functions -source $ROOT_DIR/scripts/protoc-generator.sh +# shellcheck disable=SC1090,SC1091 +source "$ROOT_DIR"/scripts/protoc-generator.sh install_dependencies -go_protoc $COMPONENTS_DIR -typescript_protoc $COMPONENTS_DIR +go_protoc "$COMPONENTS_DIR" +typescript_protoc "$COMPONENTS_DIR" go generate typescript/util/generate-ws-ready.go diff --git a/components/dashboard/remove-sources.sh b/components/dashboard/remove-sources.sh index 8999260c0714a5..77d1a3d5ba8ce6 100755 --- a/components/dashboard/remove-sources.sh +++ b/components/dashboard/remove-sources.sh @@ -4,12 +4,13 @@ rm -rvf dist/*.map; # ensure all files using Google Analytics have the proper format +# shellcheck disable=SC2044 for i in $(find public/ -name "*.html"); do - if grep -q "Global site tag" $i; then - if ! grep -q -- "-- gtag end --" $i; then + if grep -q "Global site tag" "$i"; then + if ! grep -q -- "-- gtag end --" "$i"; then echo "$i does not have a gtag end marker. This would break the remove-sources.sh script." echo 'Please add after the Google Analytics block' - exit -1 + exit 1 fi fi done @@ -17,6 +18,7 @@ done # remove Google Analytics echo "BEWARE: This script actually modifies files in the source tree" rm public/google2db8c31aefd7ebbd.html +# shellcheck disable=SC2044 for i in $(find public/ -name "*.html"); do - sed -i '/