From 4330560b6aafc890b7665ec7e78f7b4fcbc13e66 Mon Sep 17 00:00:00 2001 From: Joe Beda Date: Sun, 21 Aug 2016 13:32:06 -0700 Subject: [PATCH] Make update-generated-*.sh not hack around with docker images make-generated-{protobuf,runtime}.sh was doing some really nasty stuff with how the build container was managed in order to copy results out. Since we have more flexibility to grab results out of the build container, we can now avoid all of this. Ideally we wouldn't have `hack` calling `build` at all, but we aren't there yet. --- build/common.sh | 2 ++ .../go-to-protobuf/build-image/Dockerfile | 24 ------------- hack/update-generated-protobuf.sh | 35 +++---------------- hack/update-generated-runtime.sh | 33 +++-------------- 4 files changed, 11 insertions(+), 83 deletions(-) delete mode 100644 cmd/libs/go2idl/go-to-protobuf/build-image/Dockerfile diff --git a/build/common.sh b/build/common.sh index 8834bceb838..cbf51a550ed 100755 --- a/build/common.sh +++ b/build/common.sh @@ -717,6 +717,8 @@ function kube::build::copy_output() { --filter='- /_temp/' \ --filter='+ /_output/dockerized/bin/**' \ --filter='+ zz_generated.*' \ + --filter='+ generated.proto' \ + --filter='+ *.pb.go' \ --filter='+ */' \ --filter='- /**' \ "rsync://k8s@${KUBE_RSYNC_ADDR}/k8s/" "${KUBE_ROOT}" diff --git a/cmd/libs/go2idl/go-to-protobuf/build-image/Dockerfile b/cmd/libs/go2idl/go-to-protobuf/build-image/Dockerfile deleted file mode 100644 index ae7c6fc43da..00000000000 --- a/cmd/libs/go2idl/go-to-protobuf/build-image/Dockerfile +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright 2016 The Kubernetes Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# This file creates a standard build environment for building Kubernetes -FROM gcr.io/google_containers/kube-cross:KUBE_BUILD_IMAGE_CROSS_TAG - -# Mark this as a kube-build container -RUN touch /kube-build-image - -WORKDIR /go/src/k8s.io/kubernetes - -# Install goimports tool -RUN go get golang.org/x/tools/cmd/goimports diff --git a/hack/update-generated-protobuf.sh b/hack/update-generated-protobuf.sh index a5b65b266ab..f2cf01c0f0d 100755 --- a/hack/update-generated-protobuf.sh +++ b/hack/update-generated-protobuf.sh @@ -18,39 +18,12 @@ set -o errexit set -o nounset set -o pipefail - - KUBE_ROOT=$(dirname "${BASH_SOURCE}")/.. -source "${KUBE_ROOT}/build/common.sh" -kube::golang::setup_env +# NOTE: All output from this script needs to be copied back to the calling +# source tree. This is managed in kube::build::copy_output in build/common.sh. +# If the output set is changed update that function. -function prereqs() { - kube::log::status "Verifying Prerequisites...." - kube::build::ensure_docker_in_path || return 1 - if kube::build::is_osx; then - kube::build::docker_available_on_osx || return 1 - fi - kube::build::ensure_docker_daemon_connectivity || return 1 - - KUBE_ROOT_HASH=$(kube::build::short_hash "${HOSTNAME:-}:${REPO_DIR:-${KUBE_ROOT}}") - KUBE_BUILD_IMAGE_TAG="build-${KUBE_ROOT_HASH}" - KUBE_BUILD_IMAGE="${KUBE_BUILD_IMAGE_REPO}:${KUBE_BUILD_IMAGE_TAG}" - KUBE_BUILD_CONTAINER_NAME="kube-build-${KUBE_ROOT_HASH}" - KUBE_DATA_CONTAINER_NAME="kube-build-data-${KUBE_ROOT_HASH}" - DOCKER_MOUNT_ARGS=( - --volume "${REPO_DIR:-${KUBE_ROOT}}:/go/src/${KUBE_GO_PACKAGE}" - --volume /etc/localtime:/etc/localtime:ro - --volumes-from "${KUBE_DATA_CONTAINER_NAME}" - ) - LOCAL_OUTPUT_BUILD_CONTEXT="${LOCAL_OUTPUT_IMAGE_STAGING}/${KUBE_BUILD_IMAGE}" -} - -prereqs -mkdir -p "${LOCAL_OUTPUT_BUILD_CONTEXT}" -cp "${KUBE_ROOT}/cmd/libs/go2idl/go-to-protobuf/build-image/Dockerfile" "${LOCAL_OUTPUT_BUILD_CONTEXT}/Dockerfile" -kube::build::update_dockerfile -kube::build::docker_build "${KUBE_BUILD_IMAGE}" "${LOCAL_OUTPUT_BUILD_CONTEXT}" 'false' -kube::build::run_build_command hack/update-generated-protobuf-dockerized.sh "$@" +"${KUBE_ROOT}/build/run.sh" hack/update-generated-protobuf-dockerized.sh "$@" # ex: ts=2 sw=2 et filetype=sh diff --git a/hack/update-generated-runtime.sh b/hack/update-generated-runtime.sh index 7541be5540a..c347c01a69f 100755 --- a/hack/update-generated-runtime.sh +++ b/hack/update-generated-runtime.sh @@ -19,34 +19,11 @@ set -o nounset set -o pipefail KUBE_ROOT=$(dirname "${BASH_SOURCE}")/.. -source "${KUBE_ROOT}/build/common.sh" -kube::golang::setup_env +# NOTE: All output from this script needs to be copied back to the calling +# source tree. This is managed in kube::build::copy_output in build/common.sh. +# If the output set is changed update that function. -function prereqs() { - kube::log::status "Verifying Prerequisites...." - kube::build::ensure_docker_in_path || return 1 - if kube::build::is_osx; then - kube::build::docker_available_on_osx || return 1 - fi - kube::build::ensure_docker_daemon_connectivity || return 1 +${KUBE_ROOT}/build/run.sh hack/update-generated-runtime-dockerized.sh "$@" - KUBE_ROOT_HASH=$(kube::build::short_hash "${HOSTNAME:-}:${REPO_DIR:-${KUBE_ROOT}}/go-to-protobuf") - KUBE_BUILD_IMAGE_TAG="build-${KUBE_ROOT_HASH}" - KUBE_BUILD_IMAGE="${KUBE_BUILD_IMAGE_REPO}:${KUBE_BUILD_IMAGE_TAG}" - KUBE_BUILD_CONTAINER_NAME="kube-build-${KUBE_ROOT_HASH}" - KUBE_DATA_CONTAINER_NAME="kube-build-data-${KUBE_ROOT_HASH}" - DOCKER_MOUNT_ARGS=( - --volume "${REPO_DIR:-${KUBE_ROOT}}:/go/src/${KUBE_GO_PACKAGE}" - --volume /etc/localtime:/etc/localtime:ro - --volumes-from "${KUBE_DATA_CONTAINER_NAME}" - ) - LOCAL_OUTPUT_BUILD_CONTEXT="${LOCAL_OUTPUT_IMAGE_STAGING}/${KUBE_BUILD_IMAGE}" -} - -prereqs -mkdir -p "${LOCAL_OUTPUT_BUILD_CONTEXT}" -cp "${KUBE_ROOT}/cmd/libs/go2idl/go-to-protobuf/build-image/Dockerfile" "${LOCAL_OUTPUT_BUILD_CONTEXT}/Dockerfile" -kube::build::update_dockerfile -kube::build::docker_build "${KUBE_BUILD_IMAGE}" "${LOCAL_OUTPUT_BUILD_CONTEXT}" 'false' -kube::build::run_build_command hack/update-generated-runtime-dockerized.sh "$@" +# ex: ts=2 sw=2 et filetype=sh