From 0d9d623f04e07923e3ca1e3c70e3985b8ed62236 Mon Sep 17 00:00:00 2001 From: Jeff Grafton Date: Wed, 16 Nov 2016 17:36:35 -0800 Subject: [PATCH] Build vendored copy of go-bindata and use that in go generate step Additionally remove all instances of `go get`ing go-bindata --- build-tools/build-image/cross/Dockerfile | 5 ++-- build-tools/build-image/cross/VERSION | 2 +- ...{update-bindata.sh => generate-bindata.sh} | 8 +++-- hack/jenkins/test-dockerized.sh | 1 - hack/jenkins/verify-dockerized.sh | 1 - hack/lib/golang.sh | 29 ++++++++++--------- test/e2e/framework/gobindata_util.go | 2 +- test/e2e_node/jenkins/e2e-node-jenkins.sh | 3 +- 8 files changed, 26 insertions(+), 25 deletions(-) rename hack/{update-bindata.sh => generate-bindata.sh} (90%) diff --git a/build-tools/build-image/cross/Dockerfile b/build-tools/build-image/cross/Dockerfile index 04b437c7d1..5e803de83d 100644 --- a/build-tools/build-image/cross/Dockerfile +++ b/build-tools/build-image/cross/Dockerfile @@ -62,14 +62,13 @@ RUN echo "deb http://emdebian.org/tools/debian/ jessie main" > /etc/apt/sources. # work around 64MB tmpfs size in Docker 1.6 ENV TMPDIR /tmp.k8s -# Get the code coverage tool, godep, and go-bindata +# Get the code coverage tool, goimports, and godep RUN mkdir $TMPDIR \ && chmod a+rwx $TMPDIR \ && chmod o+t $TMPDIR \ && go get golang.org/x/tools/cmd/cover \ golang.org/x/tools/cmd/goimports \ - github.com/tools/godep \ - github.com/jteeuwen/go-bindata/go-bindata + github.com/tools/godep # Download and symlink etcd. We need this for our integration tests. RUN export ETCD_VERSION=v3.0.14; \ diff --git a/build-tools/build-image/cross/VERSION b/build-tools/build-image/cross/VERSION index 0d3e2ad5b5..663f07ff88 100644 --- a/build-tools/build-image/cross/VERSION +++ b/build-tools/build-image/cross/VERSION @@ -1 +1 @@ -v1.7.3-0 +v1.7.3-1 diff --git a/hack/update-bindata.sh b/hack/generate-bindata.sh similarity index 90% rename from hack/update-bindata.sh rename to hack/generate-bindata.sh index 9714cd8f17..6855aa9550 100755 --- a/hack/update-bindata.sh +++ b/hack/generate-bindata.sh @@ -29,10 +29,12 @@ if [[ ! -d "${KUBE_ROOT}/examples" ]]; then exit 1 fi +# kube::golang::build_kube_toolchain installs the vendored go-bindata in +# $GOPATH/bin, so make sure that's explicitly part of our $PATH. +export PATH="${GOPATH}/bin:${PATH}" + if ! which go-bindata &>/dev/null ; then - echo "Cannot find go-bindata. Install with" - echo " go get -u github.com/jteeuwen/go-bindata/go-bindata" - echo " and make sure GOBIN is in the system PATH" + echo "Cannot find go-bindata." exit 5 fi diff --git a/hack/jenkins/test-dockerized.sh b/hack/jenkins/test-dockerized.sh index 68e17985e2..9b8f44f26a 100755 --- a/hack/jenkins/test-dockerized.sh +++ b/hack/jenkins/test-dockerized.sh @@ -34,7 +34,6 @@ retry() { export PATH=${GOPATH}/bin:${PWD}/third_party/etcd:/usr/local/go/bin:${PATH} retry go get github.com/tools/godep && godep version -retry go get github.com/jteeuwen/go-bindata/go-bindata retry go get github.com/jstemmer/go-junit-report # Enable the Go race detector. diff --git a/hack/jenkins/verify-dockerized.sh b/hack/jenkins/verify-dockerized.sh index 31ebfcf224..7b0f259c66 100755 --- a/hack/jenkins/verify-dockerized.sh +++ b/hack/jenkins/verify-dockerized.sh @@ -32,7 +32,6 @@ retry() { export PATH=${GOPATH}/bin:${PWD}/third_party/etcd:/usr/local/go/bin:${PATH} retry go get github.com/tools/godep && godep version -retry go get github.com/jteeuwen/go-bindata/go-bindata export LOG_LEVEL=4 diff --git a/hack/lib/golang.sh b/hack/lib/golang.sh index 3417764020..a7f68c7677 100755 --- a/hack/lib/golang.sh +++ b/hack/lib/golang.sh @@ -166,6 +166,11 @@ readonly KUBE_STATIC_LIBRARIES=( kubectl ) +# Add any files with those //generate annotations in the array below. +readonly KUBE_BINDATAS=( + test/e2e/framework/gobindata_util.go +) + kube::golang::is_statically_linked_library() { local e for e in "${KUBE_STATIC_LIBRARIES[@]}"; do [[ "$1" == *"/$e" ]] && return 0; done; @@ -414,12 +419,12 @@ kube::golang::fallback_if_stdlib_not_installable() { # Builds the toolchain necessary for building kube. This needs to be # built only on the host platform. -# TODO: This builds only the `teststale` binary right now. As we expand -# this function's capabilities we need to find this a right home. +# TODO: Find this a proper home. # Ideally, not a shell script because testing shell scripts is painful. kube::golang::build_kube_toolchain() { local targets=( hack/cmd/teststale + vendor/github.com/jteeuwen/go-bindata/go-bindata ) local binaries @@ -610,17 +615,6 @@ kube::golang::build_binaries() { local -a targets=() local arg - # Add any files with those //generate annotations in the array below. - readonly BINDATAS=( "${KUBE_ROOT}/test/e2e/framework/gobindata_util.go" ) - kube::log::status "Generating bindata:" "${BINDATAS[@]}" - for bindata in ${BINDATAS[@]}; do - # Only try to generate bindata if the file exists, since in some cases - # one-off builds of individual directories may exclude some files. - if [[ -f $bindata ]]; then - go generate "${bindata}" - fi - done - for arg; do if [[ "${arg}" == "--use_go_build" ]]; then use_go_build=true @@ -661,6 +655,15 @@ kube::golang::build_binaries() { # First build the toolchain before building any other targets kube::golang::build_kube_toolchain + kube::log::status "Generating bindata:" "${KUBE_BINDATAS[@]}" + for bindata in ${KUBE_BINDATAS[@]}; do + # Only try to generate bindata if the file exists, since in some cases + # one-off builds of individual directories may exclude some files. + if [[ -f "${KUBE_ROOT}/${bindata}" ]]; then + go "${goflags[@]:+${goflags[@]}}" generate "${KUBE_ROOT}/${bindata}" + fi + done + if [[ "${parallel}" == "true" ]]; then kube::log::status "Building go targets for {${platforms[*]}} in parallel (output will appear in a burst when complete):" "${targets[@]}" local platform diff --git a/test/e2e/framework/gobindata_util.go b/test/e2e/framework/gobindata_util.go index c7b07bf8a3..e6335a2bf0 100644 --- a/test/e2e/framework/gobindata_util.go +++ b/test/e2e/framework/gobindata_util.go @@ -16,7 +16,7 @@ limitations under the License. package framework -//go:generate ../../../hack/update-bindata.sh +//go:generate ../../../hack/generate-bindata.sh // See https://github.com/kubernetes/kubernetes/issues/23987 import "k8s.io/kubernetes/test/e2e/generated" diff --git a/test/e2e_node/jenkins/e2e-node-jenkins.sh b/test/e2e_node/jenkins/e2e-node-jenkins.sh index d892a15501..7e035f9dbb 100755 --- a/test/e2e_node/jenkins/e2e-node-jenkins.sh +++ b/test/e2e_node/jenkins/e2e-node-jenkins.sh @@ -28,11 +28,10 @@ set -x . $1 -go get -u github.com/jteeuwen/go-bindata/go-bindata +# indirectly generates test/e2e/generated/bindata.go too make generated_files # TODO converge build steps with hack/build-go some day if possible. -go generate test/e2e/framework/gobindata_util.go go build test/e2e_node/environment/conformance.go PARALLELISM=${PARALLELISM:-8}