forked from kubevirt/kubevirt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.sh
72 lines (61 loc) · 2.27 KB
/
common.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env bash
if [ -f cluster-up/hack/common.sh ]; then
source cluster-up/hack/common.sh
fi
export GOFLAGS=-mod=vendor
KUBEVIRT_DIR="$(
cd "$(dirname "$BASH_SOURCE[0]")/../"
pwd
)"
OUT_DIR=$KUBEVIRT_DIR/_out
VENDOR_DIR=$KUBEVIRT_DIR/vendor
CMD_OUT_DIR=$OUT_DIR/cmd
TESTS_OUT_DIR=$OUT_DIR/tests
APIDOCS_OUT_DIR=$OUT_DIR/apidocs
MANIFESTS_OUT_DIR=$OUT_DIR/manifests
MANIFEST_TEMPLATES_OUT_DIR=$OUT_DIR/templates/manifests
PYTHON_CLIENT_OUT_DIR=$OUT_DIR/client-python
ARCHITECTURE=$(uname -m)
function build_func_tests() {
mkdir -p "${TESTS_OUT_DIR}/"
GOPROXY=off GOFLAGS=-mod=vendor \
go test -c "${KUBEVIRT_DIR}/tests" -o "${TESTS_OUT_DIR}/tests.test"
}
function build_func_tests_image() {
local bin_name=tests
cp ${KUBEVIRT_DIR}/tests/{Dockerfile,entrypoint.sh} \
${KUBEVIRT_DIR}/tools/manifest-templator/manifest-templator \
${TESTS_OUT_DIR}/
rsync -ar ${KUBEVIRT_DIR}/manifests/ ${TESTS_OUT_DIR}/manifests
cd ${TESTS_OUT_DIR}
docker build \
-t ${docker_prefix}/${bin_name}:${docker_tag} \
--label ${job_prefix} \
--label ${bin_name} .
}
# Use this environment variable to set a custom pkgdir path
# Useful for cross-compilation where the default -pkdir for cross-builds may not be writable
#KUBEVIRT_GO_BASE_PKGDIR="${GOPATH}/crossbuild-cache-root/"
# Populate an environment variable with the version info needed.
# It should be used for everything which needs a version when building (not generating)
# IMPORTANT:
# RIGHT NOW ONLY RELEVANT FOR BUILDING, GENERATING CODE OUTSIDE OF GIT
# IS NOT NEEDED NOR RECOMMENDED AT THIS STAGE.
function kubevirt_version() {
if [ -n "${KUBEVIRT_VERSION}" ]; then
echo ${KUBEVIRT_VERSION}
elif [ -d ${KUBEVIRT_DIR}/.git ]; then
echo "$(git describe --always --tags)"
else
echo "undefined"
fi
}
KUBEVIRT_VERSION="$(kubevirt_version)"
function go_build() {
GOPROXY=off GOFLAGS=-mod=vendor go build "$@"
}
# Use this environment variable to set a local path to a custom CA certificate for
# a private HTTPS docker registry. The intention is that this will be merged with the trust
# store in the build environment.
DOCKER_CA_CERT_FILE="${DOCKER_CA_CERT_FILE:-}"
DOCKERIZED_CUSTOM_CA_PATH="/etc/pki/ca-trust/source/anchors/custom-ca.crt"