Merge pull request #4250 from aledbf/lint-scripts

Lint shell scripts
This commit is contained in:
Kubernetes Prow Robot 2019-06-28 15:41:30 -07:00 committed by GitHub
commit bb776c43a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 71 additions and 72 deletions

View file

@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
if ! [ -z $DEBUG ]; then if [ -n "$DEBUG" ]; then
set -x set -x
fi fi
@ -52,24 +52,24 @@ function build_for_arch(){
arch=$2 arch=$2
extension=$3 extension=$3
env GOOS=${os} GOARCH=${arch} go build \ env GOOS="${os}" GOARCH="${arch}" go build \
${GOBUILD_FLAGS} \ "${GOBUILD_FLAGS}" \
-ldflags "-s -w \ -ldflags "-s -w \
-X ${PKG}/version.RELEASE=${TAG} \ -X ${PKG}/version.RELEASE=${TAG} \
-X ${PKG}/version.COMMIT=${GIT_COMMIT} \ -X ${PKG}/version.COMMIT=${GIT_COMMIT} \
-X ${PKG}/version.REPO=${REPO_INFO}" \ -X ${PKG}/version.REPO=${REPO_INFO}" \
-o ${release}/kubectl-ingress_nginx${extension} ${PKG}/cmd/plugin -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} tar -C "${release}" -zcvf "${release}/kubectl-ingress_nginx-${os}-${arch}.tar.gz" "kubectl-ingress_nginx${extension}"
rm ${release}/kubectl-ingress_nginx${extension} rm "${release}/kubectl-ingress_nginx${extension}"
hash=`sha256sum ${release}/kubectl-ingress_nginx-${os}-${arch}.tar.gz | awk '{ print $1 }'` 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 sed -i "s/%%%shasum_${os}_${arch}%%%/${hash}/g" "${release}/ingress-nginx.yaml"
} }
rm -rf ${release} rm -rf "${release}"
mkdir ${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 sed -i "s/%%%tag%%%/${TAG}/g" ${release}/ingress-nginx.yaml

View file

@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
if ! [ -z $DEBUG ]; then if [ -n "$DEBUG" ]; then
set -x set -x
fi fi
@ -46,17 +46,17 @@ fi
export CGO_ENABLED=0 export CGO_ENABLED=0
go build \ go build \
${GOBUILD_FLAGS} \ "${GOBUILD_FLAGS}" \
-ldflags "-s -w \ -ldflags "-s -w \
-X ${PKG}/version.RELEASE=${TAG} \ -X ${PKG}/version.RELEASE=${TAG} \
-X ${PKG}/version.COMMIT=${GIT_COMMIT} \ -X ${PKG}/version.COMMIT=${GIT_COMMIT} \
-X ${PKG}/version.REPO=${REPO_INFO}" \ -X ${PKG}/version.REPO=${REPO_INFO}" \
-o bin/${ARCH}/nginx-ingress-controller ${PKG}/cmd/nginx -o "bin/${ARCH}/nginx-ingress-controller" "${PKG}/cmd/nginx"
go build \ go build \
${GOBUILD_FLAGS} \ "${GOBUILD_FLAGS}" \
-ldflags "-s -w \ -ldflags "-s -w \
-X ${PKG}/version.RELEASE=${TAG} \ -X ${PKG}/version.RELEASE=${TAG} \
-X ${PKG}/version.COMMIT=${GIT_COMMIT} \ -X ${PKG}/version.COMMIT=${GIT_COMMIT} \
-X ${PKG}/version.REPO=${REPO_INFO}" \ -X ${PKG}/version.REPO=${REPO_INFO}" \
-o bin/${ARCH}/dbg ${PKG}/cmd/dbg -o "bin/${ARCH}/dbg" "${PKG}/cmd/dbg"

View file

@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
if ! [ -z $DEBUG ]; then if [ -n "$DEBUG" ]; then
set -x set -x
fi fi
@ -23,17 +23,17 @@ set -o nounset
set -o pipefail set -o pipefail
if [ -z "${PKG}" ]; then if [ -z "${PKG}" ]; then
echo "PKG must be set" echo "PKG must be set"
exit 1 exit 1
fi fi
rm -rf coverage.txt rm -rf coverage.txt
for d in `go list ${PKG}/... | grep -v vendor | grep -v '/test/e2e' | grep -v images`; do for d in $(go list "${PKG}/..." | grep -v vendor | grep -v '/test/e2e' | grep -v images); do
t=$(date +%s); t=$(date +%s);
go test -coverprofile=cover.out -covermode=atomic $d || exit 1; go test -coverprofile=cover.out -covermode=atomic "$d" || exit 1;
echo "Coverage test $d took $(($(date +%s)-$t)) seconds"; echo "Coverage test $d took $(($(date +%s)-$t)) seconds";
if [ -f cover.out ]; then if [ -f cover.out ]; then
cat cover.out >> coverage.txt; cat cover.out >> coverage.txt;
rm cover.out; rm cover.out;
fi; fi;
done done

View file

@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
if ! [ -z $DEBUG ]; then if [ -n "$DEBUG" ]; then
set -x set -x
fi fi
@ -35,7 +35,7 @@ export REGISTRY=${REGISTRY:-ingress-controller}
DEV_IMAGE=${REGISTRY}/nginx-ingress-controller:${TAG} DEV_IMAGE=${REGISTRY}/nginx-ingress-controller:${TAG}
if [ -z "${SKIP_MINIKUBE_START}" ]; then 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=kubelet.sync-frequency=1s \
--extra-config=apiserver.authorization-mode=RBAC --extra-config=apiserver.authorization-mode=RBAC
@ -52,15 +52,15 @@ for tool in kubectl kustomize; do
$tool version || brew install $tool $tool version || brew install $tool
done done
if ! kubectl get namespace $NAMESPACE; then if ! kubectl get namespace "${NAMESPACE}"; then
kubectl create namespace $NAMESPACE kubectl create namespace "${NAMESPACE}"
fi fi
ROOT=./deploy/minikube ROOT=./deploy/minikube
pushd $ROOT pushd $ROOT
kustomize edit set namespace $NAMESPACE kustomize edit set namespace "${NAMESPACE}"
kustomize edit set image quay.io/kubernetes-ingress-controller/nginx-ingress-controller=${DEV_IMAGE} kustomize edit set image "quay.io/kubernetes-ingress-controller/nginx-ingress-controller=${DEV_IMAGE}"
popd popd
echo "[dev-env] deploying NGINX Ingress controller in namespace $NAMESPACE" echo "[dev-env] deploying NGINX Ingress controller in namespace $NAMESPACE"

View file

@ -14,8 +14,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
if ! [ -z $DEBUG ]; then if [ -n "$DEBUG" ]; then
set -x set -x
fi fi
set -o errexit set -o errexit
@ -24,7 +24,7 @@ set -o pipefail
E2E_IMAGE=quay.io/kubernetes-ingress-controller/e2e:v06262019-ecce3fd7b E2E_IMAGE=quay.io/kubernetes-ingress-controller/e2e:v06262019-ecce3fd7b
DOCKER_OPTS=${DOCKER_OPTS:-""} DOCKER_OPTS=${DOCKER_OPTS:-}
FLAGS=$@ FLAGS=$@
@ -33,20 +33,21 @@ ARCH=$(go env GOARCH)
MINIKUBE_PATH=${HOME}/.minikube MINIKUBE_PATH=${HOME}/.minikube
MINIKUBE_VOLUME="-v ${MINIKUBE_PATH}:${MINIKUBE_PATH}" 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." echo "Minikube directory not found! Volume will be excluded from docker build."
MINIKUBE_VOLUME="" MINIKUBE_VOLUME=""
fi fi
docker run \ docker run \
--tty \ --tty \
--rm \ --rm \
${DOCKER_OPTS} \ ${DOCKER_OPTS} \
-v ${HOME}/.kube:/${HOME}/.kube \ -v "${HOME}/.kube:${HOME}/.kube" \
-v ${PWD}:/go/src/${PKG} \ -v "${PWD}:/go/src/${PKG}" \
-v ${PWD}/.gocache:${HOME}/.cache/go-build \ -v "${PWD}/.gocache:${HOME}/.cache/go-build" \
-v ${PWD}/bin/${ARCH}:/go/bin/linux_${ARCH} \ -v "${PWD}/bin/${ARCH}:/go/bin/linux_${ARCH}" \
-v /var/run/docker.sock:/var/run/docker.sock \ -v "/var/run/docker.sock:/var/run/docker.sock" \
${MINIKUBE_VOLUME} \ ${MINIKUBE_VOLUME} \
-w /go/src/${PKG} \ -w "/go/src/${PKG}" \
${E2E_IMAGE} ${FLAGS} -u $(id -u ${USER}):$(id -g ${USER}) \
${E2E_IMAGE} /bin/bash -c "${FLAGS}"

View file

@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
if ! [ -z "$DEBUG" ]; then if [ -n "$DEBUG" ]; then
set -x set -x
fi fi
@ -47,7 +47,7 @@ fi
function cleanup { function cleanup {
echo -e "${BGREEN}Stoping kubectl proxy${NC}" echo -e "${BGREEN}Stoping kubectl proxy${NC}"
rm -rf "${SSL_VOLUME}" rm -rf "${SSL_VOLUME}"
kill $proxy_pid kill "$proxy_pid"
} }
trap cleanup EXIT trap cleanup EXIT
@ -78,7 +78,7 @@ sleep 1
echo -e "\n${BGREEN}kubectl proxy PID: ${BGREEN}$proxy_pid${NC}" 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}" echo -e "${RED}waiting for kubectl proxy${NC}"
sleep 5 sleep 5
done done

View file

@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
if ! [ -z $DEBUG ]; then if [ -n "$DEBUG" ]; then
set -x set -x
fi fi
@ -23,8 +23,8 @@ set -o nounset
set -o pipefail set -o pipefail
if [ -z "${PKG}" ]; then if [ -z "${PKG}" ]; then
echo "PKG must be set" echo "PKG must be set"
exit 1 exit 1
fi fi
hack/verify-all.sh hack/verify-all.sh

View file

@ -15,7 +15,7 @@
# limitations under the License. # limitations under the License.
if ! [ -z $DEBUG ]; then if [ -n "$DEBUG" ]; then
set -x set -x
fi fi
@ -25,8 +25,6 @@ set -o pipefail
resty \ resty \
-I ./rootfs/etc/nginx/lua \ -I ./rootfs/etc/nginx/lua \
-I /usr/local/lib/lua \
-I /usr/lib/lua-platform-path/lua/5.1 \
--shdict "configuration_data 5M" \ --shdict "configuration_data 5M" \
--shdict "certificate_data 16M" \ --shdict "certificate_data 16M" \
--shdict "balancer_ewma 1M" \ --shdict "balancer_ewma 1M" \

View file

@ -15,7 +15,7 @@
# limitations under the License. # limitations under the License.
if ! [ -z $DEBUG ]; then if [ -n "$DEBUG" ]; then
set -x set -x
fi fi
@ -24,9 +24,9 @@ set -o nounset
set -o pipefail set -o pipefail
if [ -z "${PKG}" ]; then if [ -z "${PKG}" ]; then
echo "PKG must be set" echo "PKG must be set"
exit 1 exit 1
fi fi
go test -v -race -tags "cgo" \ 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")