Skip to content

Commit

Permalink
Lint shell scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
aledbf committed Jun 28, 2019
1 parent 2586542 commit e2d276f
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 72 deletions.
28 changes: 14 additions & 14 deletions build/build-plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
26 changes: 13 additions & 13 deletions build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"
22 changes: 11 additions & 11 deletions build/cover.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
12 changes: 6 additions & 6 deletions build/dev-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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"
Expand Down
31 changes: 16 additions & 15 deletions build/run-in-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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=$@

Expand All @@ -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}"
6 changes: 3 additions & 3 deletions build/run-ingress-controller.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions build/static-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
4 changes: 1 addition & 3 deletions build/test-lua.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.


if ! [ -z $DEBUG ]; then
if [ -n "$DEBUG" ]; then
set -x
fi

Expand All @@ -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" \
Expand Down
8 changes: 4 additions & 4 deletions build/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.


if ! [ -z $DEBUG ]; then
if [ -n "$DEBUG" ]; then
set -x
fi

Expand All @@ -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")

0 comments on commit e2d276f

Please sign in to comment.