diff --git a/hack/update-bazel.sh b/hack/update-bazel.sh index 3539c2cdae6..aad1b4d982a 100755 --- a/hack/update-bazel.sh +++ b/hack/update-bazel.sh @@ -18,7 +18,6 @@ set -o nounset set -o pipefail KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. -export KUBE_ROOT source "${KUBE_ROOT}/hack/lib/init.sh" # Ensure that we find the binaries we build before anything else. @@ -30,14 +29,26 @@ go install k8s.io/kubernetes/vendor/github.com/bazelbuild/bazel-gazelle/cmd/gaze go install k8s.io/kubernetes/vendor/github.com/bazelbuild/buildtools/buildozer go install k8s.io/kubernetes/vendor/k8s.io/repo-infra/kazel -touch "${KUBE_ROOT}/vendor/BUILD" -# Ensure that we use the correct importmap for all vendored dependencies. -# Probably not necessary in gazelle 0.13+ -# (https://github.com/bazelbuild/bazel-gazelle/pull/207). -if ! grep -q "# gazelle:importmap_prefix" "${KUBE_ROOT}/vendor/BUILD"; then - echo "# gazelle:importmap_prefix k8s.io/kubernetes/vendor" >> "${KUBE_ROOT}/vendor/BUILD" -fi +while IFS='' read -r repo; do staging_repos+=("${repo}"); done <\ + <(cd "${KUBE_ROOT}/staging/src" && find k8s.io/ -mindepth 1 -maxdepth 1 -type d | LANG=C sort) +( + cat "${KUBE_ROOT}/hack/boilerplate/boilerplate.generatebzl.txt" + echo "# This file is autogenerated by hack/update-bazel.sh." + # avoid getting caught by the boilerplate checker + rev <<<".TIDE TON OD #" + echo + echo "staging_repos = [" + for repo in "${staging_repos[@]}"; do + echo " \"${repo}\"," + done + echo "]" +) >"${KUBE_ROOT}/staging/repos_generated.bzl" + +touch "${KUBE_ROOT}/vendor/BUILD" +for repo in "${staging_repos[@]}"; do + touch "${KUBE_ROOT}/staging/src/${repo}/BUILD" +done gazelle fix \ -external=vendored \ -mode=fix \ diff --git a/vendor/BUILD b/vendor/BUILD index 23b959ce508..4ebff5c263c 100644 --- a/vendor/BUILD +++ b/vendor/BUILD @@ -1,5 +1,3 @@ -# gazelle:importmap_prefix k8s.io/kubernetes/vendor - filegroup( name = "package-srcs", srcs = glob(["**"]),