diff --git a/hack/after-build/update-generated-protobuf.sh b/hack/after-build/update-generated-protobuf.sh index 978e6b5983b..ce3ffc46c8f 100755 --- a/hack/after-build/update-generated-protobuf.sh +++ b/hack/after-build/update-generated-protobuf.sh @@ -32,7 +32,7 @@ if [[ -z "$(which protoc)" || "$(protoc --version)" != "libprotoc 3.0."* ]]; the echo " https://github.com/google/protobuf/releases" echo echo "WARNING: Protobuf changes are not being validated" - exit 0 + exit 1 fi gotoprotobuf=$(kube::util::find-binary "go-to-protobuf") diff --git a/hack/after-build/verify-generated-protobuf.sh b/hack/after-build/verify-generated-protobuf.sh index 0239d480b14..0582c155c9c 100755 --- a/hack/after-build/verify-generated-protobuf.sh +++ b/hack/after-build/verify-generated-protobuf.sh @@ -21,19 +21,7 @@ set -o pipefail KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../.. source "${KUBE_ROOT}/hack/lib/init.sh" -# TODO: preinstall protobuf -if [[ -z "$(which protoc)" || "$(protoc --version)" != "libprotoc 3.0."* ]]; then - echo "Generating protobuf requires protoc 3.0.0-beta1 or newer. Please download and" - echo "install the platform appropriate Protobuf package for your OS: " - echo - echo " https://github.com/google/protobuf/releases" - echo - echo "WARNING: Protobuf changes are not being validated" - # TODO: make error when protobuf is installed - exit 0 -fi - -APIROOTS=${APIROOTS:-pkg/api pkg/apis/extensions pkg/apis/metrics pkg/runtime pkg/util/intstr} +APIROOTS=${APIROOTS:-pkg/api pkg/apis pkg/runtime pkg/util/intstr pkg/watch} _tmp="${KUBE_ROOT}/_tmp" cleanup() { @@ -42,18 +30,24 @@ cleanup() { trap "cleanup" EXIT SIGINT +cleanup for APIROOT in ${APIROOTS}; do mkdir -p "${_tmp}/${APIROOT%/*}" cp -a "${KUBE_ROOT}/${APIROOT}" "${_tmp}/${APIROOT}" done -"${KUBE_ROOT}/hack/after-build/update-generated-protobuf.sh" +# We would like to use "sudo" when running on Travis and +# not use "sudo" when running on Jenkins. +SUDO="sudo" +sudo -h > /dev/null || SUDO="" + +"${KUBE_ROOT}/hack/update-generated-protobuf.sh" for APIROOT in ${APIROOTS}; do TMP_APIROOT="${_tmp}/${APIROOT}" echo "diffing ${APIROOT} against freshly generated protobuf" ret=0 diff -Naupr -I 'Auto generated by' "${KUBE_ROOT}/${APIROOT}" "${TMP_APIROOT}" || ret=$? - cp -a "${TMP_APIROOT}" "${KUBE_ROOT}/${APIROOT%/*}" + ${SUDO} cp -a "${TMP_APIROOT}" "${KUBE_ROOT}/${APIROOT%/*}" if [[ $ret -eq 0 ]]; then echo "${APIROOT} up to date." else diff --git a/hack/update-generated-protobuf.sh b/hack/update-generated-protobuf.sh index 7ca88048998..2f34af74521 100755 --- a/hack/update-generated-protobuf.sh +++ b/hack/update-generated-protobuf.sh @@ -37,7 +37,12 @@ function prereqs() { KUBE_BUILD_CONTAINER_NAME="kube-build-${KUBE_ROOT_HASH}" KUBE_BUILD_DATA_CONTAINER_NAME="kube-build-data-${KUBE_ROOT_HASH}" DOCKER_MOUNT_ARGS=( - --volume "${KUBE_ROOT}:/go/src/${KUBE_GO_PACKAGE}" + --volume "${REPO_DIR:-${KUBE_ROOT}}/cluster:/go/src/${KUBE_GO_PACKAGE}/cluster" + --volume "${REPO_DIR:-${KUBE_ROOT}}/cmd:/go/src/${KUBE_GO_PACKAGE}/cmd" + --volume "${REPO_DIR:-${KUBE_ROOT}}/Godeps/_workspace/src:/go/src/${KUBE_GO_PACKAGE}/Godeps/_workspace/src" + --volume "${REPO_DIR:-${KUBE_ROOT}}/hack:/go/src/${KUBE_GO_PACKAGE}/hack" + --volume "${REPO_DIR:-${KUBE_ROOT}}/pkg:/go/src/${KUBE_GO_PACKAGE}/pkg" + --volume "${REPO_DIR:-${KUBE_ROOT}}/third_party:/go/src/${KUBE_GO_PACKAGE}/third_party" --volume /etc/localtime:/etc/localtime:ro --volumes-from "${KUBE_BUILD_DATA_CONTAINER_NAME}" ) diff --git a/hack/verify-generated-protobuf.sh b/hack/verify-generated-protobuf.sh index 043aa42bd8e..c43bd1b9bcf 100755 --- a/hack/verify-generated-protobuf.sh +++ b/hack/verify-generated-protobuf.sh @@ -23,8 +23,6 @@ source "${KUBE_ROOT}/hack/lib/init.sh" kube::golang::setup_env -"${KUBE_ROOT}/hack/build-go.sh" cmd/libs/go2idl/go-to-protobuf cmd/libs/go2idl/go-to-protobuf/protoc-gen-gogo - "${KUBE_ROOT}/hack/after-build/verify-generated-protobuf.sh" "$@" # ex: ts=2 sw=2 et filetype=sh