Skip to content

Commit

Permalink
Make building contrib code optional
Browse files Browse the repository at this point in the history
  • Loading branch information
James DeFelice committed Jun 10, 2015
1 parent e10afad commit 91238f8
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 27 deletions.
28 changes: 21 additions & 7 deletions build/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,9 @@ function kube::build::ensure_golang() {
}
}

# Set up the context directory for the kube-build image and build it.
function kube::build::build_image() {
local -r build_context_dir="${LOCAL_OUTPUT_IMAGE_STAGING}/${KUBE_BUILD_IMAGE}"
local -r source=(
# The set of source targets to include in the kube-build image
function kube::build::source_targets() {
local targets=(
api
build
cmd
Expand All @@ -323,11 +322,22 @@ function kube::build::build_image() {
test
third_party
)
if [ -n "${KUBERNETES_CONTRIB:-}" ]; then
for contrib in "${KUBERNETES_CONTRIB}"; do
targets+=($(eval "kube::contrib::${contrib}::source_targets"))
done
fi
echo "${targets[@]}"
}

# Set up the context directory for the kube-build image and build it.
function kube::build::build_image() {
local -r build_context_dir="${LOCAL_OUTPUT_IMAGE_STAGING}/${KUBE_BUILD_IMAGE}"

kube::build::build_image_cross

mkdir -p "${build_context_dir}"
tar czf "${build_context_dir}/kube-source.tar.gz" "${source[@]}"
tar czf "${build_context_dir}/kube-source.tar.gz" $(kube::build::source_targets)

kube::version::get_version_vars
kube::version::save_version_vars "${build_context_dir}/kube-version-defs"
Expand Down Expand Up @@ -412,8 +422,12 @@ function kube::build::run_build_command() {

local -a docker_run_opts=(
"--name=${KUBE_BUILD_CONTAINER_NAME}"
"${DOCKER_MOUNT_ARGS[@]}"
)
"${DOCKER_MOUNT_ARGS[@]}"
)

if [ -n "${KUBERNETES_CONTRIB:-}" ]; then
docker_run_opts+=(-e "KUBERNETES_CONTRIB=${KUBERNETES_CONTRIB}")
fi

# If we have stdin we can run interactive. This allows things like 'shell.sh'
# to work. However, if we run this way and don't have stdin, then it ends up
Expand Down
65 changes: 45 additions & 20 deletions hack/lib/golang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,32 @@
readonly KUBE_GO_PACKAGE=github.com/GoogleCloudPlatform/kubernetes
readonly KUBE_GOPATH="${KUBE_OUTPUT}/go"

# Load contrib target functions
if [ -n "${KUBERNETES_CONTRIB:-}" ]; then
for contrib in "${KUBERNETES_CONTRIB}"; do
source "${KUBE_ROOT}/contrib/${contrib}/target.sh"
done
fi

# The set of server targets that we are only building for Linux
readonly KUBE_SERVER_TARGETS=(
cmd/kube-proxy
cmd/kube-apiserver
cmd/kube-controller-manager
cmd/kubelet
cmd/hyperkube
cmd/kubernetes
plugin/cmd/kube-scheduler
)
kube::golang::server_targets() {
local targets=(
cmd/kube-proxy
cmd/kube-apiserver
cmd/kube-controller-manager
cmd/kubelet
cmd/hyperkube
cmd/kubernetes
plugin/cmd/kube-scheduler
)
if [ -n "${KUBERNETES_CONTRIB:-}" ]; then
for contrib in "${KUBERNETES_CONTRIB}"; do
targets+=($(eval "kube::contrib::${contrib}::server_targets"))
done
fi
echo "${targets[@]}"
}
readonly KUBE_SERVER_TARGETS=($(kube::golang::server_targets))
readonly KUBE_SERVER_BINARIES=("${KUBE_SERVER_TARGETS[@]##*/}")

# The server platform we are building on.
Expand All @@ -43,17 +59,26 @@ readonly KUBE_CLIENT_BINARIES=("${KUBE_CLIENT_TARGETS[@]##*/}")
readonly KUBE_CLIENT_BINARIES_WIN=("${KUBE_CLIENT_BINARIES[@]/%/.exe}")

# The set of test targets that we are building for all platforms
readonly KUBE_TEST_TARGETS=(
cmd/integration
cmd/gendocs
cmd/genman
cmd/genbashcomp
cmd/genconversion
cmd/gendeepcopy
examples/k8petstore/web-server
github.com/onsi/ginkgo/ginkgo
test/e2e/e2e.test
)
kube::golang::test_targets() {
local targets=(
cmd/integration
cmd/gendocs
cmd/genman
cmd/genbashcomp
cmd/genconversion
cmd/gendeepcopy
examples/k8petstore/web-server
github.com/onsi/ginkgo/ginkgo
test/e2e/e2e.test
)
if [ -n "${KUBERNETES_CONTRIB:-}" ]; then
for contrib in "${KUBERNETES_CONTRIB}"; do
targets+=($(eval "kube::contrib::${contrib}::test_targets"))
done
fi
echo "${targets[@]}"
}
readonly KUBE_TEST_TARGETS=($(kube::golang::test_targets))
readonly KUBE_TEST_BINARIES=("${KUBE_TEST_TARGETS[@]##*/}")
readonly KUBE_TEST_BINARIES_WIN=("${KUBE_TEST_BINARIES[@]/%/.exe}")
readonly KUBE_TEST_PORTABLE=(
Expand Down

0 comments on commit 91238f8

Please sign in to comment.