diff --git a/build/build-plugin.sh b/build/build-plugin.sh index 6dd52d85a..6d0de4c01 100755 --- a/build/build-plugin.sh +++ b/build/build-plugin.sh @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -if ! [ -z $DEBUG ]; then +if [ -n "$DEBUG" ]; then set -x fi @@ -52,24 +52,24 @@ function build_for_arch(){ arch=$2 extension=$3 - env GOOS=${os} GOARCH=${arch} go build \ - ${GOBUILD_FLAGS} \ + env GOOS="${os}" GOARCH="${arch}" go build \ + "${GOBUILD_FLAGS}" \ -ldflags "-s -w \ - -X ${PKG}/version.RELEASE=${TAG} \ - -X ${PKG}/version.COMMIT=${GIT_COMMIT} \ - -X ${PKG}/version.REPO=${REPO_INFO}" \ - -o ${release}/kubectl-ingress_nginx${extension} ${PKG}/cmd/plugin + -X ${PKG}/version.RELEASE=${TAG} \ + -X ${PKG}/version.COMMIT=${GIT_COMMIT} \ + -X ${PKG}/version.REPO=${REPO_INFO}" \ + -o "${release}/kubectl-ingress_nginx${extension}" "${PKG}/cmd/plugin" - tar -C ${release} -zcvf ${release}/kubectl-ingress_nginx-${os}-${arch}.tar.gz kubectl-ingress_nginx${extension} - rm ${release}/kubectl-ingress_nginx${extension} - hash=`sha256sum ${release}/kubectl-ingress_nginx-${os}-${arch}.tar.gz | awk '{ print $1 }'` - sed -i "s/%%%shasum_${os}_${arch}%%%/${hash}/g" ${release}/ingress-nginx.yaml + tar -C "${release}" -zcvf "${release}/kubectl-ingress_nginx-${os}-${arch}.tar.gz" "kubectl-ingress_nginx${extension}" + rm "${release}/kubectl-ingress_nginx${extension}" + hash=$(sha256sum "${release}/kubectl-ingress_nginx-${os}-${arch}.tar.gz" | awk '{ print $1 }') + sed -i "s/%%%shasum_${os}_${arch}%%%/${hash}/g" "${release}/ingress-nginx.yaml" } -rm -rf ${release} -mkdir ${release} +rm -rf "${release}" +mkdir "${release}" -cp cmd/plugin/ingress-nginx.yaml.tmpl ${release}/ingress-nginx.yaml +cp cmd/plugin/ingress-nginx.yaml.tmpl "${release}/ingress-nginx.yaml" sed -i "s/%%%tag%%%/${TAG}/g" ${release}/ingress-nginx.yaml diff --git a/build/build.sh b/build/build.sh index 3f37ca447..3a8c9f773 100755 --- a/build/build.sh +++ b/build/build.sh @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -if ! [ -z $DEBUG ]; then +if [ -n "$DEBUG" ]; then set -x fi @@ -46,17 +46,17 @@ fi export CGO_ENABLED=0 go build \ - ${GOBUILD_FLAGS} \ - -ldflags "-s -w \ - -X ${PKG}/version.RELEASE=${TAG} \ - -X ${PKG}/version.COMMIT=${GIT_COMMIT} \ - -X ${PKG}/version.REPO=${REPO_INFO}" \ - -o bin/${ARCH}/nginx-ingress-controller ${PKG}/cmd/nginx + "${GOBUILD_FLAGS}" \ + -ldflags "-s -w \ + -X ${PKG}/version.RELEASE=${TAG} \ + -X ${PKG}/version.COMMIT=${GIT_COMMIT} \ + -X ${PKG}/version.REPO=${REPO_INFO}" \ + -o "bin/${ARCH}/nginx-ingress-controller" "${PKG}/cmd/nginx" go build \ - ${GOBUILD_FLAGS} \ - -ldflags "-s -w \ - -X ${PKG}/version.RELEASE=${TAG} \ - -X ${PKG}/version.COMMIT=${GIT_COMMIT} \ - -X ${PKG}/version.REPO=${REPO_INFO}" \ - -o bin/${ARCH}/dbg ${PKG}/cmd/dbg + "${GOBUILD_FLAGS}" \ + -ldflags "-s -w \ + -X ${PKG}/version.RELEASE=${TAG} \ + -X ${PKG}/version.COMMIT=${GIT_COMMIT} \ + -X ${PKG}/version.REPO=${REPO_INFO}" \ + -o "bin/${ARCH}/dbg" "${PKG}/cmd/dbg" diff --git a/build/cover.sh b/build/cover.sh index 3b25c4a23..17b5be3b1 100755 --- a/build/cover.sh +++ b/build/cover.sh @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -if ! [ -z $DEBUG ]; then +if [ -n "$DEBUG" ]; then set -x fi @@ -23,17 +23,17 @@ set -o nounset set -o pipefail if [ -z "${PKG}" ]; then - echo "PKG must be set" - exit 1 + echo "PKG must be set" + exit 1 fi rm -rf coverage.txt -for d in `go list ${PKG}/... | grep -v vendor | grep -v '/test/e2e' | grep -v images`; do - t=$(date +%s); - go test -coverprofile=cover.out -covermode=atomic $d || exit 1; - echo "Coverage test $d took $(($(date +%s)-$t)) seconds"; - if [ -f cover.out ]; then - cat cover.out >> coverage.txt; - rm cover.out; - fi; +for d in $(go list "${PKG}/..." | grep -v vendor | grep -v '/test/e2e' | grep -v images); do + t=$(date +%s); + go test -coverprofile=cover.out -covermode=atomic "$d" || exit 1; + echo "Coverage test $d took $(($(date +%s)-$t)) seconds"; + if [ -f cover.out ]; then + cat cover.out >> coverage.txt; + rm cover.out; + fi; done diff --git a/build/dev-env.sh b/build/dev-env.sh index 59b883cdc..3b2874434 100755 --- a/build/dev-env.sh +++ b/build/dev-env.sh @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -if ! [ -z $DEBUG ]; then +if [ -n "$DEBUG" ]; then set -x fi @@ -35,7 +35,7 @@ export REGISTRY=${REGISTRY:-ingress-controller} DEV_IMAGE=${REGISTRY}/nginx-ingress-controller:${TAG} if [ -z "${SKIP_MINIKUBE_START}" ]; then - test $(minikube status | grep Running | wc -l) -ge 2 && $(minikube status | grep -q 'Correctly Configured') || minikube start \ + test "$(minikube status | grep -c Running) -ge 2 && $(minikube status | grep -q 'Correctly Configured')" || minikube start \ --extra-config=kubelet.sync-frequency=1s \ --extra-config=apiserver.authorization-mode=RBAC @@ -52,15 +52,15 @@ for tool in kubectl kustomize; do $tool version || brew install $tool done -if ! kubectl get namespace $NAMESPACE; then - kubectl create namespace $NAMESPACE +if ! kubectl get namespace "${NAMESPACE}"; then + kubectl create namespace "${NAMESPACE}" fi ROOT=./deploy/minikube pushd $ROOT -kustomize edit set namespace $NAMESPACE -kustomize edit set image quay.io/kubernetes-ingress-controller/nginx-ingress-controller=${DEV_IMAGE} +kustomize edit set namespace "${NAMESPACE}" +kustomize edit set image "quay.io/kubernetes-ingress-controller/nginx-ingress-controller=${DEV_IMAGE}" popd echo "[dev-env] deploying NGINX Ingress controller in namespace $NAMESPACE" diff --git a/build/run-in-docker.sh b/build/run-in-docker.sh index 049f866f5..0e321d471 100755 --- a/build/run-in-docker.sh +++ b/build/run-in-docker.sh @@ -14,8 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -if ! [ -z $DEBUG ]; then - set -x +if [ -n "$DEBUG" ]; then + set -x fi set -o errexit @@ -24,7 +24,7 @@ set -o pipefail E2E_IMAGE=quay.io/kubernetes-ingress-controller/e2e:v06262019-ecce3fd7b -DOCKER_OPTS=${DOCKER_OPTS:-""} +DOCKER_OPTS=${DOCKER_OPTS:-} FLAGS=$@ @@ -33,20 +33,21 @@ ARCH=$(go env GOARCH) MINIKUBE_PATH=${HOME}/.minikube MINIKUBE_VOLUME="-v ${MINIKUBE_PATH}:${MINIKUBE_PATH}" -if [ ! -d ${MINIKUBE_PATH} ]; then +if [ ! -d "${MINIKUBE_PATH}" ]; then echo "Minikube directory not found! Volume will be excluded from docker build." MINIKUBE_VOLUME="" fi docker run \ - --tty \ - --rm \ - ${DOCKER_OPTS} \ - -v ${HOME}/.kube:/${HOME}/.kube \ - -v ${PWD}:/go/src/${PKG} \ - -v ${PWD}/.gocache:${HOME}/.cache/go-build \ - -v ${PWD}/bin/${ARCH}:/go/bin/linux_${ARCH} \ - -v /var/run/docker.sock:/var/run/docker.sock \ - ${MINIKUBE_VOLUME} \ - -w /go/src/${PKG} \ - ${E2E_IMAGE} ${FLAGS} + --tty \ + --rm \ + ${DOCKER_OPTS} \ + -v "${HOME}/.kube:${HOME}/.kube" \ + -v "${PWD}:/go/src/${PKG}" \ + -v "${PWD}/.gocache:${HOME}/.cache/go-build" \ + -v "${PWD}/bin/${ARCH}:/go/bin/linux_${ARCH}" \ + -v "/var/run/docker.sock:/var/run/docker.sock" \ + ${MINIKUBE_VOLUME} \ + -w "/go/src/${PKG}" \ + -u $(id -u ${USER}):$(id -g ${USER}) \ + ${E2E_IMAGE} /bin/bash -c "${FLAGS}" diff --git a/build/run-ingress-controller.sh b/build/run-ingress-controller.sh index 6e7aba01b..eb629953a 100755 --- a/build/run-ingress-controller.sh +++ b/build/run-ingress-controller.sh @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -if ! [ -z "$DEBUG" ]; then +if [ -n "$DEBUG" ]; then set -x fi @@ -47,7 +47,7 @@ fi function cleanup { echo -e "${BGREEN}Stoping kubectl proxy${NC}" rm -rf "${SSL_VOLUME}" - kill $proxy_pid + kill "$proxy_pid" } trap cleanup EXIT @@ -78,7 +78,7 @@ sleep 1 echo -e "\n${BGREEN}kubectl proxy PID: ${BGREEN}$proxy_pid${NC}" -until $(curl --output /dev/null -fsSL http://localhost:8001/); do +until curl --output /dev/null -fsSL http://localhost:8001/; do echo -e "${RED}waiting for kubectl proxy${NC}" sleep 5 done diff --git a/build/static-check.sh b/build/static-check.sh index 49f408f90..521a1d408 100755 --- a/build/static-check.sh +++ b/build/static-check.sh @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -if ! [ -z $DEBUG ]; then +if [ -n "$DEBUG" ]; then set -x fi @@ -23,8 +23,8 @@ set -o nounset set -o pipefail if [ -z "${PKG}" ]; then - echo "PKG must be set" - exit 1 + echo "PKG must be set" + exit 1 fi hack/verify-all.sh diff --git a/build/test-lua.sh b/build/test-lua.sh index b843f66fd..a515b6799 100755 --- a/build/test-lua.sh +++ b/build/test-lua.sh @@ -15,7 +15,7 @@ # limitations under the License. -if ! [ -z $DEBUG ]; then +if [ -n "$DEBUG" ]; then set -x fi @@ -25,8 +25,6 @@ set -o pipefail resty \ -I ./rootfs/etc/nginx/lua \ - -I /usr/local/lib/lua \ - -I /usr/lib/lua-platform-path/lua/5.1 \ --shdict "configuration_data 5M" \ --shdict "certificate_data 16M" \ --shdict "balancer_ewma 1M" \ diff --git a/build/test.sh b/build/test.sh index 758b4e593..c94d2ac79 100755 --- a/build/test.sh +++ b/build/test.sh @@ -15,7 +15,7 @@ # limitations under the License. -if ! [ -z $DEBUG ]; then +if [ -n "$DEBUG" ]; then set -x fi @@ -24,9 +24,9 @@ set -o nounset set -o pipefail if [ -z "${PKG}" ]; then - echo "PKG must be set" - exit 1 + echo "PKG must be set" + exit 1 fi go test -v -race -tags "cgo" \ - $(go list ${PKG}/... | grep -v vendor | grep -v '/test/e2e' | grep -v images | grep -v "docs/examples") + $(go list "${PKG}/..." | grep -v vendor | grep -v '/test/e2e' | grep -v images | grep -v "docs/examples")