From 47e6cad282ff5b2cd7f305399d05dae7a2ab279b Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Wed, 9 Oct 2019 14:45:46 -0400 Subject: [PATCH 1/2] Add hack/shellcheck.sh. --- hack/shellcheck.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 hack/shellcheck.sh diff --git a/hack/shellcheck.sh b/hack/shellcheck.sh new file mode 100755 index 000000000..7987af0e3 --- /dev/null +++ b/hack/shellcheck.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +set -eux + +IS_CONTAINER=${IS_CONTAINER:-false} + +if [ "${IS_CONTAINER}" != "false" ]; then + TOP_DIR="${1:-.}" + find "${TOP_DIR}" -path ./vendor -prune -o -name '*.sh' -exec shellcheck -s bash {} \+ +else + podman run --rm \ + --env IS_CONTAINER=TRUE \ + --volume "${PWD}:/workdir:ro,z" \ + --entrypoint sh \ + --workdir /workdir \ + registry.hub.docker.com/koalaman/shellcheck-alpine:stable \ + /workdir/hack/shellcheck.sh "${@}" +fi; From 2664ab628c5bcc5016181fab4c83599ca1de5710 Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Wed, 9 Oct 2019 15:17:51 -0400 Subject: [PATCH 2/2] Fix shellcheck warnings. --- hack/gofmt.sh | 2 +- hack/govet.sh | 2 +- hack/unit.sh | 6 +++--- tools/install_kustomize.sh | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/hack/gofmt.sh b/hack/gofmt.sh index bb043da79..fa8fb247e 100755 --- a/hack/gofmt.sh +++ b/hack/gofmt.sh @@ -6,7 +6,7 @@ IS_CONTAINER=${IS_CONTAINER:-false} if [ "${IS_CONTAINER}" != "false" ]; then TOP_DIR="${1:-.}" - go fmt ${TOP_DIR}/pkg/... ${TOP_DIR}/cmd/... + go fmt "${TOP_DIR}"/pkg/... "${TOP_DIR}"/cmd/... else podman run --rm \ --env IS_CONTAINER=TRUE \ diff --git a/hack/govet.sh b/hack/govet.sh index 69f49c6c6..912f1004a 100755 --- a/hack/govet.sh +++ b/hack/govet.sh @@ -6,7 +6,7 @@ IS_CONTAINER=${IS_CONTAINER:-false} if [ "${IS_CONTAINER}" != "false" ]; then TOP_DIR="${1:-.}" - go vet ${TOP_DIR}/pkg/... ${TOP_DIR}/cmd/... + go vet "${TOP_DIR}"/pkg/... "${TOP_DIR}"/cmd/... else podman run --rm \ --env IS_CONTAINER=TRUE \ diff --git a/hack/unit.sh b/hack/unit.sh index 7bb4d9c5f..b4e8d6ca9 100755 --- a/hack/unit.sh +++ b/hack/unit.sh @@ -7,10 +7,10 @@ IS_CONTAINER=${IS_CONTAINER:-false} if [ "${IS_CONTAINER}" != "false" ]; then TOP_DIR="${1:-$(pwd)}" cd / - ${TOP_DIR}/tools/install_kustomize.sh - ${TOP_DIR}/tools/install_kubebuilder.sh + "${TOP_DIR}"/tools/install_kustomize.sh + "${TOP_DIR}"/tools/install_kubebuilder.sh mv kubebuilder /usr/local/. - cd ${TOP_DIR} + cd "${TOP_DIR}" go test ./pkg/... ./cmd/... -coverprofile /cover.out else podman run --rm \ diff --git a/tools/install_kustomize.sh b/tools/install_kustomize.sh index eb1b30d4a..df337acbc 100755 --- a/tools/install_kustomize.sh +++ b/tools/install_kustomize.sh @@ -1,4 +1,4 @@ #!/bin/bash -x -mkdir -p $GOPATH/bin -curl -L https://github.com/kubernetes-sigs/kustomize/releases/download/v2.0.3/kustomize_2.0.3_linux_amd64 -o $GOPATH/bin/kustomize -chmod +x $GOPATH/bin/kustomize +mkdir -p "$GOPATH"/bin +curl -L https://github.com/kubernetes-sigs/kustomize/releases/download/v2.0.3/kustomize_2.0.3_linux_amd64 -o "$GOPATH"/bin/kustomize +chmod +x "$GOPATH"/bin/kustomize