Commit 18b84758 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #51229 from ixdy/always-create-vendor-BUILD

Automatic merge from submit-queue Always create vendor/BUILD in hack/update-bazel.sh **What this PR does / why we need it**: makes sure there's always a `vendor/BUILD` file. When updating `godeps`, the [instructions](https://github.com/kubernetes/community/blob/master/contributors/devel/godep.md) say to recursively remove `vendor/`, which also removes the `vendor/BUILD` file. Unless you manually recreate this file, running `update-bazel.sh` would instead update the `all-srcs` rule in the root `BUILD.bazel` file, which is not desired. `gazelle` and `kazel` won't create `vendor/BUILD` on their own, since there are no go sources directly in `vendor/`. With this PR, we'll make sure that the `vendor/BUILD` file always exists, creating it if necessary. **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #51075 **Release note**: ```release-note NONE ``` /assign @spxtr @mikedanese cc @thockin
parents 41aeccd0 2a869d89
......@@ -28,5 +28,7 @@ rm -f "${KUBE_ROOT}/pkg/generated/openapi/zz_generated.openapi.go"
kube::util::go_install_from_commit github.com/kubernetes/repo-infra/kazel 4eaf9e671bbb549fb4ec292cf251f921d7ef80ac
kube::util::go_install_from_commit github.com/bazelbuild/rules_go/go/tools/gazelle/gazelle 82483596ec203eb9c1849937636f4cbed83733eb
touch "${KUBE_ROOT}/vendor/BUILD"
gazelle fix -build_file_name=BUILD,BUILD.bazel -external=vendored -mode=fix -repo_root="$(kube::realpath ${KUBE_ROOT})"
kazel -root="$(kube::realpath ${KUBE_ROOT})"
......@@ -20,6 +20,13 @@ set -o pipefail
export KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
source "${KUBE_ROOT}/hack/lib/init.sh"
if [[ ! -f "${KUBE_ROOT}/vendor/BUILD" ]]; then
echo "${KUBE_ROOT}/vendor/BUILD does not exist."
echo
echo "Run ./hack/update-bazel.sh"
exit 1
fi
# 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"
......
This diff is collapsed. Click to expand it.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment