From 9b4b4eeedc60cc07bc6d7c5199e865cd41588a78 Mon Sep 17 00:00:00 2001 From: Roman Mohr Date: Fri, 12 Jan 2018 08:02:37 +0100 Subject: [PATCH] Make sure all hack scripts use hack/common.sh Signed-off-by: Roman Mohr --- cluster/kubectl.sh | 10 +++++++--- hack/build-docker.sh | 19 +++++++------------ hack/build-go.sh | 18 +++++++----------- hack/common.sh | 2 +- hack/dockerized | 14 ++++---------- hack/functests.sh | 7 ++----- hack/gen-swagger-doc/gen-swagger-docs.sh | 11 ++++------- 7 files changed, 32 insertions(+), 49 deletions(-) diff --git a/cluster/kubectl.sh b/cluster/kubectl.sh index 7c0672b9f141..52cc01c4eb33 100755 --- a/cluster/kubectl.sh +++ b/cluster/kubectl.sh @@ -17,12 +17,16 @@ # Copyright 2017 Red Hat, Inc. # +set -e + +source $(dirname "$0")/../hack/common.sh + PROVIDER=${PROVIDER:-vagrant} -source ${KUBEVIRT_PATH}cluster/$PROVIDER/provider.sh -source ${KUBEVIRT_PATH}hack/config.sh +source ${KUBEVIRT_DIR}/cluster/$PROVIDER/provider.sh +source ${KUBEVIRT_DIR}/hack/config.sh if [ "$1" == "console" ] || [ "$1" == "vnc" ]; then - cmd/virtctl/virtctl "$@" --kubeconfig=${kubeconfig} + ${KUBEVIRT_DIR}/_out/cmd/virtctl/virtctl "$@" --kubeconfig=${kubeconfig} else _kubectl "$@" fi diff --git a/hack/build-docker.sh b/hack/build-docker.sh index 65b079fba5bf..2ddfc5e57a9e 100755 --- a/hack/build-docker.sh +++ b/hack/build-docker.sh @@ -19,12 +19,8 @@ set -e +source hack/common.sh source hack/config.sh -KUBEVIRT_DIR="$( - cd "$(dirname "$0")/../" - pwd -)" -OUT_DIR=$KUBEVIRT_DIR/_out/cmd/ if [ -z "$1" ]; then target="build" @@ -42,24 +38,23 @@ else fi for arg in $args; do + BIN_NAME=$(basename $arg) if [ "${target}" = "build" ]; then - BIN_NAME=$(basename $arg) - rsync -avz --exclude "**/*.md" --exclude "**/*.go" --exclude "**/.*" $arg/ ${OUT_DIR}/${BIN_NAME}/ + rsync -avz --exclude "**/*.md" --exclude "**/*.go" --exclude "**/.*" $arg/ ${CMD_OUT_DIR}/${BIN_NAME}/ # TODO the version of docker we're using in our vagrant dev environment # does not support using ARGS in FROM field. # https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact # Because of this we have to manipulate the Dockerfile for kubevirt containers # that depend on other kubevirt containers. - cat $arg/Dockerfile | sed s/registry-disk-v1alpha/registry-disk-v1alpha\:$docker_tag/g >${OUT_DIR}/${BIN_NAME}/Dockerfile + cat $arg/Dockerfile | sed s/registry-disk-v1alpha/registry-disk-v1alpha\:$docker_tag/g >${CMD_OUT_DIR}/${BIN_NAME}/Dockerfile ( - cd ${OUT_DIR}/${BIN_NAME}/ + cd ${CMD_OUT_DIR}/${BIN_NAME}/ docker $target -t ${docker_prefix}/${BIN_NAME}:${docker_tag} . ) elif [ "${target}" = "push" ]; then ( - BIN_NAME=$(basename $arg) - cd ${OUT_DIR}/${BIN_NAME}/ - docker push ${docker_prefix}/${BIN_NAME}:${docker_tag} + cd ${CMD_OUT_DIR}/${BIN_NAME}/ + docker $target ${docker_prefix}/${BIN_NAME}:${docker_tag} ) fi done diff --git a/hack/build-go.sh b/hack/build-go.sh index 5d49322c591e..a4525be28523 100755 --- a/hack/build-go.sh +++ b/hack/build-go.sh @@ -19,12 +19,8 @@ set -e +source hack/common.sh source hack/config.sh -KUBEVIRT_DIR="$( - cd "$(dirname "$0")/../" - pwd -)" -OUT_DIR=$KUBEVIRT_DIR/_out/cmd if [ -z "$1" ]; then target="install" @@ -63,7 +59,7 @@ fi # handle binaries if [ "${target}" = "install" ]; then - rm -rf ${OUT_DIR} + rm -rf ${CMD_OUT_DIR} fi for arg in $args; do @@ -76,11 +72,11 @@ for arg in $args; do eval "$(go env)" BIN_NAME=$(basename $arg) ARCHBIN=${BIN_NAME}-$(git describe --always)-${GOHOSTOS}-${GOHOSTARCH} - mkdir -p ${OUT_DIR}/${BIN_NAME} + mkdir -p ${CMD_OUT_DIR}/${BIN_NAME} ( cd $arg - go build -o ${OUT_DIR}/${BIN_NAME}/${ARCHBIN} - (cd ${OUT_DIR}/${BIN_NAME} && ln -sf ${ARCHBIN} ${BIN_NAME}) + go build -o ${CMD_OUT_DIR}/${BIN_NAME}/${ARCHBIN} + (cd ${CMD_OUT_DIR}/${BIN_NAME} && ln -sf ${ARCHBIN} ${BIN_NAME}) ) else ( @@ -91,7 +87,7 @@ for arg in $args; do done if [[ "${target}" == "install" && "${build_tests}" == "true" ]]; then - mkdir -p ${KUBEVIRT_DIR}/_out/tests/ + mkdir -p ${TESTS_OUT_DIR}/ ginkgo build ${KUBEVIRT_DIR}/tests - mv ${KUBEVIRT_DIR}/tests/tests.test ${KUBEVIRT_DIR}/_out/tests/ + mv ${KUBEVIRT_DIR}/tests/tests.test ${TESTS_OUT_DIR}/ fi diff --git a/hack/common.sh b/hack/common.sh index ed5864b56af9..f9f55a5192f5 100644 --- a/hack/common.sh +++ b/hack/common.sh @@ -6,6 +6,6 @@ KUBEVIRT_DIR="$( )" OUT_DIR=$KUBEVIRT_DIR/_out/ CMD_OUT_DIR=$KUBEVIRT_DIR/_out/cmd/ -TESTS_OUT_DIR=$KUBEVIRT_DIR/_out/cmd/ +TESTS_OUT_DIR=$KUBEVIRT_DIR/_out/tests/ APIDOCS_OUT_DIR=$KUBEVIRT_DIR/_out/apidocs MANIFESTS_OUT_DIR=$KUBEVIRT_DIR/_out/manifests diff --git a/hack/dockerized b/hack/dockerized index f27c0928897d..e3f2df45c7c8 100755 --- a/hack/dockerized +++ b/hack/dockerized @@ -1,15 +1,9 @@ #!/bin/bash set -e -DIR="$( - cd "$(dirname "$0")" - pwd -)" -DOCKER_DIR=${DIR}/docker-builder -KUBEVIRT_DIR="$( - cd "$DIR/../" - pwd -)" +source $(dirname "$0")/common.sh + +DOCKER_DIR=${KUBEVIRT_DIR}/hack/docker-builder BUILDER=${BUILDER_NAME:-kubevirtbuilder} RSYNCD_PORT=${RSYNCD_PORT:-10873} @@ -53,4 +47,4 @@ docker run --rm -v "${BUILDER}:/root:rw,z" -w "/root/go/src/kubevirt.io/kubevirt # Copy the whole kubevirt data out to get generated sources and formatting changes _rsync --exclude '.glide*' --exclude "vendor" --exclude "_out" --exclude ".vagrant" --exclude ".git" "rsync://root@127.0.0.1:${RSYNCD_PORT}/build" ${KUBEVIRT_DIR}/ # Copy the build output out of the container, make sure that _out exactly matches the build result -_rsync --delete "rsync://root@127.0.0.1:${RSYNCD_PORT}/out" $KUBEVIRT_DIR/_out +_rsync --delete "rsync://root@127.0.0.1:${RSYNCD_PORT}/out" ${OUT_DIR} diff --git a/hack/functests.sh b/hack/functests.sh index 2637d5282c61..0782a81f8c06 100755 --- a/hack/functests.sh +++ b/hack/functests.sh @@ -19,10 +19,7 @@ set -e +source hack/common.sh source hack/config.sh -KUBEVIRT_DIR="$( - cd "$(dirname "$0")/../" - pwd -)" -${KUBEVIRT_DIR}/_out/tests/tests.test -kubeconfig=${kubeconfig} -test.timeout 30m ${FUNC_TEST_ARGS} +${TESTS_OUT_DIR}/tests.test -kubeconfig=${kubeconfig} -test.timeout 30m ${FUNC_TEST_ARGS} diff --git a/hack/gen-swagger-doc/gen-swagger-docs.sh b/hack/gen-swagger-doc/gen-swagger-docs.sh index e69b5cf62c45..9326de38087d 100755 --- a/hack/gen-swagger-doc/gen-swagger-docs.sh +++ b/hack/gen-swagger-doc/gen-swagger-docs.sh @@ -8,10 +8,7 @@ set -o errexit set -o nounset set -o pipefail -KUBEVIRT_DIR="$( - cd "$(dirname "$0")/../../" - pwd -)" +source $(dirname "$0")/../../hack/common.sh VERSION="${1:-v1}" OUTPUT_FORMAT="${2:-html}" @@ -98,7 +95,7 @@ elif [ "$OUTPUT_FORMAT" = "markdown" ]; then cd - fi -mkdir -p ${KUBEVIRT_DIR}/_out/apidocs/html -mv ${WORKDIR}/html5/content/* ${KUBEVIRT_DIR}/_out/apidocs/html -mv ${WORKDIR}/*.adoc ${KUBEVIRT_DIR}/_out/apidocs/ +mkdir -p ${APIDOCS_OUT_DIR}/html +mv ${WORKDIR}/html5/content/* ${APIDOCS_OUT_DIR}/html +mv ${WORKDIR}/*.adoc ${APIDOCS_OUT_DIR}/ echo "SUCCESS"