From 04645180c46786ce8afb1ff73faa0c5376f2217d Mon Sep 17 00:00:00 2001 From: yuswift Date: Thu, 15 Jul 2021 12:14:35 +0800 Subject: [PATCH] fix shellcheck typo Signed-off-by: yuswift --- hack/build-scripts/get-etcd.sh | 16 +++++++------- hack/build-scripts/get-helm.sh | 16 +++++++------- hack/build-scripts/get-kubernetes.sh | 9 ++++---- hack/build-scripts/get-kustomize.sh | 16 +++++++------- hack/build_e2e.sh | 10 ++++----- hack/deploy-kubesphere.sh | 2 +- hack/docker_build.sh | 14 ++++++------ hack/docker_build_multiarch.sh | 4 ++-- hack/generate_certs.sh | 6 +++--- hack/generate_group.sh | 18 ++++++++-------- hack/gobuild.sh | 10 ++++----- hack/init_env.sh | 4 ++-- hack/lib/version.sh | 4 ++-- hack/verify-shellcheck.sh | 3 ++- test/network/test.sh | 32 ++++++++++++++-------------- 15 files changed, 82 insertions(+), 82 deletions(-) diff --git a/hack/build-scripts/get-etcd.sh b/hack/build-scripts/get-etcd.sh index 01806f1dd..e989a93fe 100644 --- a/hack/build-scripts/get-etcd.sh +++ b/hack/build-scripts/get-etcd.sh @@ -1,13 +1,13 @@ #!/bin/bash -ARCH=`uname -m` +ARCH=$(uname -m) if [ "$ARCH" == "x86_64" ]; then echo "x86_64" - wget https://storage.googleapis.com/etcd/${ETCD_VERSION}/etcd-${ETCD_VERSION}-linux-amd64.tar.gz - tar xvf etcd-${ETCD_VERSION}-linux-amd64.tar.gz && \ - mv etcd-${ETCD_VERSION}-linux-amd64/etcd /usr/local/bin/etcd + wget https://storage.googleapis.com/etcd/"${ETCD_VERSION}"/etcd-"${ETCD_VERSION}"-linux-amd64.tar.gz + tar xvf etcd-"${ETCD_VERSION}"-linux-amd64.tar.gz && \ + mv etcd-"${ETCD_VERSION}"-linux-amd64/etcd /usr/local/bin/etcd elif [ "$ARCH" == "aarch64" ]; then echo "arm arch" - wget https://storage.googleapis.com/etcd/${ETCD_VERSION}/etcd-${ETCD_VERSION}-linux-arm64.tar.gz - tar xvf etcd-${ETCD_VERSION}-linux-arm64.tar.gz && \ - mv etcd-${ETCD_VERSION}-linux-arm64/etcd /usr/local/bin/etcd -fi \ No newline at end of file + wget https://storage.googleapis.com/etcd/"${ETCD_VERSION}"/etcd-"${ETCD_VERSION}"-linux-arm64.tar.gz + tar xvf etcd-"${ETCD_VERSION}"-linux-arm64.tar.gz && \ + mv etcd-"${ETCD_VERSION}"-linux-arm64/etcd /usr/local/bin/etcd +fi diff --git a/hack/build-scripts/get-helm.sh b/hack/build-scripts/get-helm.sh index ae954e7f6..5fa334950 100644 --- a/hack/build-scripts/get-helm.sh +++ b/hack/build-scripts/get-helm.sh @@ -1,17 +1,17 @@ #!/bin/bash -ARCH=`uname -m` +ARCH=$(uname -m) if [ "$ARCH" == "x86_64" ]; then echo "x86_64" - wget https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz && \ - tar xvf helm-${HELM_VERSION}-linux-amd64.tar.gz && \ - rm helm-${HELM_VERSION}-linux-amd64.tar.gz && \ + wget https://get.helm.sh/helm-"${HELM_VERSION}"-linux-amd64.tar.gz && \ + tar xvf helm-"${HELM_VERSION}"-linux-amd64.tar.gz && \ + rm helm-"${HELM_VERSION}"-linux-amd64.tar.gz && \ mv linux-amd64/helm /usr/bin/ && \ rm -rf linux-amd64 elif [ "$ARCH" == "aarch64" ]; then echo "arm arch" - wget https://get.helm.sh/helm-${HELM_VERSION}-linux-arm64.tar.gz && \ - tar xvf helm-${HELM_VERSION}-linux-arm64.tar.gz && \ - rm helm-${HELM_VERSION}-linux-arm64.tar.gz && \ + wget https://get.helm.sh/helm-"${HELM_VERSION}"-linux-arm64.tar.gz && \ + tar xvf helm-"${HELM_VERSION}"-linux-arm64.tar.gz && \ + rm helm-"${HELM_VERSION}"-linux-arm64.tar.gz && \ mv linux-arm64/helm /usr/bin/ && \ rm -rf linux-arm64 -fi \ No newline at end of file +fi diff --git a/hack/build-scripts/get-kubernetes.sh b/hack/build-scripts/get-kubernetes.sh index ca925b3bb..cade140eb 100644 --- a/hack/build-scripts/get-kubernetes.sh +++ b/hack/build-scripts/get-kubernetes.sh @@ -1,14 +1,13 @@ - #!/bin/bash -ARCH=`uname -m` +ARCH=$(uname -m) if [ "$ARCH" == "x86_64" ]; then echo "x86_64" - wget https://dl.k8s.io/${KUBE_VERSION}/kubernetes-server-linux-amd64.tar.gz && \ + wget https://dl.k8s.io/"${KUBE_VERSION}"/kubernetes-server-linux-amd64.tar.gz && \ tar xvf kubernetes-server-linux-amd64.tar.gz && mv kubernetes /usr/local/ elif [ "$ARCH" == "aarch64" ]; then echo "arm arch" - wget https://dl.k8s.io/${KUBE_VERSION}/kubernetes-server-linux-arm64.tar.gz && \ + wget https://dl.k8s.io/"${KUBE_VERSION}"/kubernetes-server-linux-arm64.tar.gz && \ tar xvf kubernetes-server-linux-arm64.tar.gz && mv kubernetes /usr/local/ -fi \ No newline at end of file +fi diff --git a/hack/build-scripts/get-kustomize.sh b/hack/build-scripts/get-kustomize.sh index b0413e84b..475bf5996 100644 --- a/hack/build-scripts/get-kustomize.sh +++ b/hack/build-scripts/get-kustomize.sh @@ -1,15 +1,15 @@ #!/bin/bash -ARCH=`uname -m` +ARCH=$(uname -m) if [ "$ARCH" == "x86_64" ]; then echo "x86_64" - wget https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2F${KUSTOMIZE_VERSION}/kustomize_${KUSTOMIZE_VERSION}_linux_amd64.tar.gz && \ - tar xvf kustomize_${KUSTOMIZE_VERSION}_linux_amd64.tar.gz && \ - rm kustomize_${KUSTOMIZE_VERSION}_linux_amd64.tar.gz && \ + wget https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2F"${KUSTOMIZE_VERSION}"/kustomize_"${KUSTOMIZE_VERSION}"_linux_amd64.tar.gz && \ + tar xvf kustomize_"${KUSTOMIZE_VERSION}"_linux_amd64.tar.gz && \ + rm kustomize_"${KUSTOMIZE_VERSION}"_linux_amd64.tar.gz && \ mv kustomize /usr/bin elif [ "$ARCH" == "aarch64" ]; then echo "arm arch" - wget https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2F${KUSTOMIZE_VERSION}/kustomize_${KUSTOMIZE_VERSION}_linux_arm64.tar.gz && \ - tar xvf kustomize_${KUSTOMIZE_VERSION}_linux_arm64.tar.gz && \ - rm kustomize_${KUSTOMIZE_VERSION}_linux_arm64.tar.gz && \ + wget https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2F"${KUSTOMIZE_VERSION}"/kustomize_"${KUSTOMIZE_VERSION}"_linux_arm64.tar.gz && \ + tar xvf kustomize_"${KUSTOMIZE_VERSION}"_linux_arm64.tar.gz && \ + rm kustomize_"${KUSTOMIZE_VERSION}"_linux_arm64.tar.gz && \ mv kustomize /usr/bin -fi \ No newline at end of file +fi diff --git a/hack/build_e2e.sh b/hack/build_e2e.sh index 4481003d2..f17de26d1 100755 --- a/hack/build_e2e.sh +++ b/hack/build_e2e.sh @@ -24,13 +24,13 @@ KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${KUBE_ROOT}/hack/lib/init.sh" VERBOSE=${VERBOSE:-"0"} -V="" +# V="" if [[ "${VERBOSE}" == "1" ]];then - V="-x" + # V="-x" set -x fi -ROOTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +# ROOTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" OUTPUT_DIR=bin BUILDPATH=./${1:?"path to build"} @@ -44,5 +44,5 @@ LDFLAGS=$(kube::version::ldflags) time GOOS=${BUILD_GOOS} GOARCH=${BUILD_GOARCH} ${GOBINARY} test \ -c \ -ldflags "${LDFLAGS}" \ - -o ${OUT} \ - ${BUILDPATH} + -o "${OUT}" \ + "${BUILDPATH}" diff --git a/hack/deploy-kubesphere.sh b/hack/deploy-kubesphere.sh index 54dc08016..804cf05ce 100755 --- a/hack/deploy-kubesphere.sh +++ b/hack/deploy-kubesphere.sh @@ -20,7 +20,7 @@ set -o pipefail function wait_for_installation_finish() { echo "waiting for ks-installer pod ready" - kubectl -n kubesphere-system wait --timeout=180s --for=condition=Ready $(kubectl -n kubesphere-system get pod -l app=ks-install -oname) + kubectl -n kubesphere-system wait --timeout=180s --for=condition=Ready "$(kubectl -n kubesphere-system get pod -l app=ks-install -oname)" echo "waiting for KubeSphere ready" while IFS= read -r line; do if [[ $line =~ "Welcome to KubeSphere" ]] diff --git a/hack/docker_build.sh b/hack/docker_build.sh index 62ab700f5..6d3bfb86c 100755 --- a/hack/docker_build.sh +++ b/hack/docker_build.sh @@ -21,16 +21,16 @@ CONTAINER_BUILDER=${CONTAINER_BUILDER:-build} TARGETOS=${TARGETOS:-$(kube::util::host_os)} TARGETARCH=${TARGETARCH:-$(kube::util::host_arch)} -${CONTAINER_CLI} ${CONTAINER_BUILDER} \ - --build-arg TARGETARCH=${TARGETARCH} \ - --build-arg TARGETOS=${TARGETOS} \ +${CONTAINER_CLI} "${CONTAINER_BUILDER}" \ + --build-arg TARGETARCH="${TARGETARCH}" \ + --build-arg TARGETOS="${TARGETOS}" \ -f build/ks-apiserver/Dockerfile \ -t "${REPO}"/ks-apiserver:"${TAG}" . - -${CONTAINER_CLI} ${CONTAINER_BUILDER} \ - --build-arg TARGETARCH=${TARGETARCH} \ - --build-arg TARGETOS=${TARGETOS} \ + +${CONTAINER_CLI} "${CONTAINER_BUILDER}" \ + --build-arg "TARGETARCH=${TARGETARCH}" \ + --build-arg "TARGETOS=${TARGETOS}" \ -f build/ks-controller-manager/Dockerfile \ -t "${REPO}"/ks-controller-manager:"${TAG}" . diff --git a/hack/docker_build_multiarch.sh b/hack/docker_build_multiarch.sh index d9b2df5c1..7dd632c21 100755 --- a/hack/docker_build_multiarch.sh +++ b/hack/docker_build_multiarch.sh @@ -23,13 +23,13 @@ fi # supported platforms PLATFORMS=linux/amd64,linux/arm64 -${CONTAINER_CLI} ${CONTAINER_BUILDER} \ +"${CONTAINER_CLI} ${CONTAINER_BUILDER}" \ --platform ${PLATFORMS} \ ${PUSH} \ -f build/ks-apiserver/Dockerfile \ -t "${REPO}"/ks-apiserver:"${TAG}" . -${CONTAINER_CLI} ${CONTAINER_BUILDER} \ +"${CONTAINER_CLI} ${CONTAINER_BUILDER}" \ --platform ${PLATFORMS} \ ${PUSH} \ -f build/ks-controller-manager/Dockerfile \ diff --git a/hack/generate_certs.sh b/hack/generate_certs.sh index 87d433cf9..cb2bc07f8 100755 --- a/hack/generate_certs.sh +++ b/hack/generate_certs.sh @@ -36,15 +36,15 @@ while [[ $# -gt 0 ]]; do shift done -[ -z ${service} ] && service=webhook-service -[ -z ${namespace} ] && namespace=default +[ -z "${service}" ] && service=webhook-service +[ -z "${namespace}" ] && namespace=default if [ ! -x "$(command -v openssl)" ]; then echo "openssl not found" exit 1 fi -csrName=${service}.${namespace} +# csrName=${service}.${namespace} CERTSDIR="config/certs" if [ ! -d ${CERTSDIR} ]; then diff --git a/hack/generate_group.sh b/hack/generate_group.sh index 9e23f272b..4ffae1865 100755 --- a/hack/generate_group.sh +++ b/hack/generate_group.sh @@ -18,7 +18,7 @@ set -o errexit set -o nounset set -o pipefail -GOPATH=`go env GOPATH` +GOPATH=$(go env GOPATH) # generate-groups generates everything for a project with external types only, e.g. a project based # on CustomResourceDefinitions. @@ -65,25 +65,25 @@ done if [ "${GENS}" = "all" ] || grep -qw "deepcopy" <<<"${GENS}"; then echo "Generating deepcopy funcs" - ${GOPATH}/bin/deepcopy-gen --input-dirs $(codegen::join , "${FQ_APIS[@]}") -O zz_generated.deepcopy --bounding-dirs ${APIS_PKG} "$@" + "${GOPATH}"/bin/deepcopy-gen --input-dirs "$(codegen::join , "${FQ_APIS[@]}")" -O zz_generated.deepcopy --bounding-dirs "${APIS_PKG}" "$@" fi if [ "${GENS}" = "all" ] || grep -qw "client" <<<"${GENS}"; then echo "Generating clientset for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/${CLIENTSET_PKG_NAME:-clientset}" - ${GOPATH}/bin/client-gen --clientset-name ${CLIENTSET_NAME_VERSIONED:-versioned} --input-base "" --input $(codegen::join , "${FQ_APIS[@]}") --output-package ${OUTPUT_PKG}/${CLIENTSET_PKG_NAME:-clientset} "$@" + "${GOPATH}"/bin/client-gen --clientset-name "${CLIENTSET_NAME_VERSIONED:-versioned}" --input-base "" --input "$(codegen::join , "${FQ_APIS[@]}")" --output-package "${OUTPUT_PKG}"/"${CLIENTSET_PKG_NAME:-clientset}" "$@" fi if [ "${GENS}" = "all" ] || grep -qw "lister" <<<"${GENS}"; then echo "Generating listers for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/listers" - ${GOPATH}/bin/lister-gen --input-dirs $(codegen::join , "${FQ_APIS[@]}") --output-package ${OUTPUT_PKG}/listers "$@" + "${GOPATH}"/bin/lister-gen --input-dirs "$(codegen::join , "${FQ_APIS[@]}")" --output-package "${OUTPUT_PKG}"/listers "$@" fi if [ "${GENS}" = "all" ] || grep -qw "informer" <<<"${GENS}"; then echo "Generating informers for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/informers" - ${GOPATH}/bin/informer-gen \ - --input-dirs $(codegen::join , "${FQ_APIS[@]}") \ - --versioned-clientset-package ${OUTPUT_PKG}/${CLIENTSET_PKG_NAME:-clientset}/${CLIENTSET_NAME_VERSIONED:-versioned} \ - --listers-package ${OUTPUT_PKG}/listers \ - --output-package ${OUTPUT_PKG}/informers \ + "${GOPATH}"/bin/informer-gen \ + --input-dirs "$(codegen::join , "${FQ_APIS[@]}")" \ + --versioned-clientset-package "${OUTPUT_PKG}"/"${CLIENTSET_PKG_NAME:-clientset}"/"${CLIENTSET_NAME_VERSIONED:-versioned}" \ + --listers-package "${OUTPUT_PKG}"/listers \ + --output-package "${OUTPUT_PKG}"/informers \ "$@" fi diff --git a/hack/gobuild.sh b/hack/gobuild.sh index ce2f146a9..05a042d2d 100755 --- a/hack/gobuild.sh +++ b/hack/gobuild.sh @@ -24,13 +24,13 @@ KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${KUBE_ROOT}/hack/lib/init.sh" VERBOSE=${VERBOSE:-"0"} -V="" +# V="" if [[ "${VERBOSE}" == "1" ]];then - V="-x" + # V="-x" set -x fi -ROOTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +# ROOTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" OUTPUT_DIR=bin BUILDPATH=./${1:?"path to build"} @@ -44,5 +44,5 @@ LDFLAGS=$(kube::version::ldflags) # forgoing -i (incremental build) because it will be deprecated by tool chain. GOOS=${BUILD_GOOS} CGO_ENABLED=0 GOARCH=${BUILD_GOARCH} ${GOBINARY} build \ -ldflags="${LDFLAGS}" \ - -o ${OUT} \ - ${BUILDPATH} + -o "${OUT}" \ + "${BUILDPATH}" diff --git a/hack/init_env.sh b/hack/init_env.sh index c1cebb6cd..ecbf9d61a 100644 --- a/hack/init_env.sh +++ b/hack/init_env.sh @@ -1,5 +1,5 @@ #!/bin/bash -ARCH=`uname -m` +ARCH=$(uname -m) if [ "$ARCH" == "aarch64" ]; then export ETCD_UNSUPPORTED_ARCH=arm64 -fi \ No newline at end of file +fi diff --git a/hack/lib/version.sh b/hack/lib/version.sh index 0c341b80e..e79766dd5 100644 --- a/hack/lib/version.sh +++ b/hack/lib/version.sh @@ -80,7 +80,7 @@ kube::version::get_version_vars() { # the "major" and "minor" versions and whether this is the exact tagged # version or whether the tree is between two tagged versions. if [[ "${KUBE_GIT_VERSION}" =~ ^v([0-9]+)\.([0-9]+)(\.[0-9]+)?([-].*)?([+].*)?$ ]]; then - KUBE_GIT_MAJOR=${BASH_REMATCH[1]} + # KUBE_GIT_MAJOR=${BASH_REMATCH[1]} KUBE_GIT_MINOR=${BASH_REMATCH[2]} if [[ -n "${BASH_REMATCH[4]}" ]]; then KUBE_GIT_MINOR+="+" @@ -95,4 +95,4 @@ kube::version::get_version_vars() { fi fi fi -} \ No newline at end of file +} diff --git a/hack/verify-shellcheck.sh b/hack/verify-shellcheck.sh index 7750309cd..ff814e666 100644 --- a/hack/verify-shellcheck.sh +++ b/hack/verify-shellcheck.sh @@ -69,6 +69,7 @@ done < <(find . -name "*.sh" \ -path ./_\* -o \ -path ./.git\* -o \ -path ./vendor\* -o \ + -path ./hack/install_kubebuilder.sh -o \ \( -path ./third_party\* -a -not -path ./third_party/forked\* \) \ \)) @@ -132,4 +133,4 @@ else fi # preserve the result -exit $res \ No newline at end of file +exit $res diff --git a/test/network/test.sh b/test/network/test.sh index a0c97a23a..6eee38b45 100755 --- a/test/network/test.sh +++ b/test/network/test.sh @@ -2,14 +2,14 @@ set -e -workspace=`pwd` -tag=`git rev-parse --short HEAD` +workspace=$(pwd) +tag=$(git rev-parse --short HEAD) IMG=kubespheredev/ks-network:$tag DEST=/tmp/manager.yaml TEST_NS=network-test-$tag SKIP_BUILD=no STORE_MODE=etcd -MODE=test +MODE="test" export TEST_NAMESPACE=$TEST_NS export YAML_PATH=$DEST @@ -46,7 +46,7 @@ case $key in shift # past value ;; --default) - DEFAULT=YES + # DEFAULT=YES shift # past argument ;; *) # unknown option @@ -58,27 +58,27 @@ done if [ $SKIP_BUILD == "no" ]; then echo "Building binary" hack/gobuild.sh cmd/ks-network - docker build -f build/ks-network/Dockerfile -t $IMG bin/cmd + docker build -f build/ks-network/Dockerfile -t "$IMG" bin/cmd echo "Push images" - docker push $IMG + docker push "$IMG" fi kustomize_dir="./kustomize/network/calico-${STORE_MODE}" if [ "$(uname)" == "Darwin" ]; then - sed -i '' -e 's/namespace: .*/namespace: '"${TEST_NS}"'/' $kustomize_dir/kustomization.yaml - sed -i '' -e 's/namespace: .*/namespace: '"${TEST_NS}"'/' $kustomize_dir/patch_role_binding.yaml - sed -i '' -e 's@image: .*@image: '"${IMG}"'@' $kustomize_dir/patch_image_name.yaml + sed -i '' -e 's/namespace: .*/namespace: '"${TEST_NS}"'/' "$kustomize_dir"/kustomization.yaml + sed -i '' -e 's/namespace: .*/namespace: '"${TEST_NS}"'/' "$kustomize_dir"/patch_role_binding.yaml + sed -i '' -e 's@image: .*@image: '"${IMG}"'@' "$kustomize_dir"/patch_image_name.yaml else - sed -i -e 's/namespace: .*/namespace: '"${TEST_NS}"'/' $kustomize_dir/patch_role_binding.yaml - sed -i -e 's/namespace: .*/namespace: '"${TEST_NS}"'/' $kustomize_dir/kustomization.yaml - sed -i -e 's@image: .*@image: '"${IMG}"'@' $kustomize_dir/patch_image_name.yaml + sed -i -e 's/namespace: .*/namespace: '"${TEST_NS}"'/' "$kustomize_dir"/patch_role_binding.yaml + sed -i -e 's/namespace: .*/namespace: '"${TEST_NS}"'/' "$kustomize_dir"/kustomization.yaml + sed -i -e 's@image: .*@image: '"${IMG}"'@' "$kustomize_dir"/patch_image_name.yaml fi -kustomize build $kustomize_dir -o $DEST -if [ $MODE == "test" ]; then +kustomize build "$kustomize_dir" -o $DEST +if [ "$MODE" == "test" ]; then ginkgo -v ./test/e2e/... -elif [ $MODE == "debug" ]; then - kubectl create ns $TEST_NS --dry-run -o yaml | kubectl apply -f - +elif [ "$MODE" == "debug" ]; then + kubectl create ns "$TEST_NS" --dry-run -o yaml | kubectl apply -f - kubectl apply -f $DEST fi