Skip to content

Commit

Permalink
Make sure all hack scripts use hack/common.sh
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Mohr <[email protected]>
  • Loading branch information
rmohr authored and Travis CI committed Jan 15, 2018
1 parent a579441 commit 9b4b4ee
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 49 deletions.
10 changes: 7 additions & 3 deletions cluster/kubectl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
19 changes: 7 additions & 12 deletions hack/build-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
18 changes: 7 additions & 11 deletions hack/build-go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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
(
Expand All @@ -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
2 changes: 1 addition & 1 deletion hack/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 4 additions & 10 deletions hack/dockerized
Original file line number Diff line number Diff line change
@@ -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}
Expand Down Expand Up @@ -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://[email protected]:${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://[email protected]:${RSYNCD_PORT}/out" $KUBEVIRT_DIR/_out
_rsync --delete "rsync://[email protected]:${RSYNCD_PORT}/out" ${OUT_DIR}
7 changes: 2 additions & 5 deletions hack/functests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
11 changes: 4 additions & 7 deletions hack/gen-swagger-doc/gen-swagger-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -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"

0 comments on commit 9b4b4ee

Please sign in to comment.