diff --git a/.kazelcfg.json b/.kazelcfg.json new file mode 120000 index 00000000000..cdc4e17bbb8 --- /dev/null +++ b/.kazelcfg.json @@ -0,0 +1 @@ +build/root/.kazelcfg.json \ No newline at end of file diff --git a/.gazelcfg.json b/build/root/.kazelcfg.json similarity index 100% rename from .gazelcfg.json rename to build/root/.kazelcfg.json diff --git a/hack/lib/util.sh b/hack/lib/util.sh index 745a8982cfa..2c486a01680 100755 --- a/hack/lib/util.sh +++ b/hack/lib/util.sh @@ -513,6 +513,23 @@ kube::util::ensure_godep_version() { godep version } +# Installs the specified go package at a particular commit. +kube::util::go_install_from_commit() { + local -r pkg=$1 + local -r commit=$2 + + kube::util::ensure-temp-dir + mkdir -p "${KUBE_TEMP}/go/src" + GOPATH="${KUBE_TEMP}/go" go get -d -u "${pkg}" 2>/dev/null + ( + cd "${KUBE_TEMP}/go/src/${pkg}" + git checkout -q "${commit}" + GOPATH="${KUBE_TEMP}/go" go install "${pkg}" + ) + PATH="${KUBE_TEMP}/go/bin:${PATH}" + hash -r # force bash to clear PATH cache +} + # Checks that the GOPATH is simple, i.e. consists only of one directory, not multiple. kube::util::ensure_single_dir_gopath() { if [[ "${GOPATH}" == *:* ]]; then diff --git a/hack/update-bazel.sh b/hack/update-bazel.sh index 4bcfdf575fd..24b204ca705 100755 --- a/hack/update-bazel.sh +++ b/hack/update-bazel.sh @@ -20,21 +20,10 @@ set -o pipefail export KUBE_ROOT=$(dirname "${BASH_SOURCE}")/.. source "${KUBE_ROOT}/hack/lib/init.sh" -# Remove generated files prior to running gazel. +# Remove generated files prior to running kazel. # TODO(spxtr): Remove this line once Bazel is the only way to build. rm -f "${KUBE_ROOT}/pkg/generated/openapi/zz_generated.openapi.go" -go get -u gopkg.in/mikedanese/gazel.v17/gazel +kube::util::go_install_from_commit github.com/kubernetes/repo-infra/kazel fd3ec969104295f8484a32114ce625955a67365d -for path in ${GOPATH//:/ }; do - if [[ -e "${path}/bin/gazel" ]]; then - gazel="${path}/bin/gazel" - break - fi -done -if [[ -z "${gazel:-}" ]]; then - echo "Couldn't find gazel on the GOPATH." - exit 1 -fi - -"${gazel}" -root="$(kube::realpath ${KUBE_ROOT})" +kazel -root="$(kube::realpath ${KUBE_ROOT})" diff --git a/hack/verify-bazel.sh b/hack/verify-bazel.sh index 7d94d1d935a..979cb4aee59 100755 --- a/hack/verify-bazel.sh +++ b/hack/verify-bazel.sh @@ -20,25 +20,13 @@ set -o pipefail export KUBE_ROOT=$(dirname "${BASH_SOURCE}")/.. source "${KUBE_ROOT}/hack/lib/init.sh" -go get gopkg.in/mikedanese/gazel.v17/gazel - -# Remove generated files prior to running gazel. +# Remove generated files prior to running kazel. # TODO(spxtr): Remove this line once Bazel is the only way to build. rm -f "${KUBE_ROOT}/pkg/generated/openapi/zz_generated.openapi.go" -for path in ${GOPATH//:/ }; do - if [[ -e "${path}/bin/gazel" ]]; then - gazel="${path}/bin/gazel" - break - fi -done -if [[ -z "${gazel:-}" ]]; then - echo "Couldn't find gazel on the GOPATH." - exit 1 -fi +kube::util::go_install_from_commit github.com/kubernetes/repo-infra/kazel fd3ec969104295f8484a32114ce625955a67365d - -if ! "${gazel}" -validate -print-diff -root="$(kube::realpath ${KUBE_ROOT})" ; then +if ! kazel -validate -print-diff -root="$(kube::realpath ${KUBE_ROOT})" ; then echo echo "Run ./hack/update-bazel.sh" exit 1