Bump Bazel to 4.0.0
This bumps Bazel to 4.0.0 because we want to use ProtoModule. The update was relatively painless,
no incompat-flags needed to be switched back off. `bazel_gazelle` is pinned on a master version
since they haven't released a Bazel 4-comaptible version yet and I have one patch against Kubernetes's
infra repo which is going upstream.
Test Plan: Build system change, should be covered by existing tests
X-Origin-Diff: phab/D701
GitOrigin-RevId: 24f675e6ba33efb9f46191eccca95088d7d2d1f1
diff --git a/build/Dockerfile b/build/Dockerfile
index b893eec..8935d1f 100644
--- a/build/Dockerfile
+++ b/build/Dockerfile
@@ -37,8 +37,8 @@
# Install Bazel binary
RUN curl -o /usr/local/bin/bazel \
- https://releases.bazel.build/3.7.2/release/bazel-3.7.2-linux-x86_64 && \
- echo '70dc0bee198a4c3d332925a32d464d9036a831977501f66d4996854ad4e4fc0d /usr/local/bin/bazel' | sha256sum --check && \
+ https://releases.bazel.build/4.0.0/release/bazel-4.0.0-linux-x86_64 && \
+ echo '7bee349a626281fc8b8d04a7a0b0358492712377400ab12533aeb39c2eb2b901 /usr/local/bin/bazel' | sha256sum --check && \
chmod +x /usr/local/bin/bazel
# Use a shared Go module cache for gazelle
diff --git a/build/fietsje/deps_kubernetes.go b/build/fietsje/deps_kubernetes.go
index baa7d15..77343cd 100644
--- a/build/fietsje/deps_kubernetes.go
+++ b/build/fietsje/deps_kubernetes.go
@@ -38,6 +38,7 @@
).inject(
// repo infra, not requested by k8s, but used with bazel
"k8s.io/repo-infra", "a3483874bd37251c629c92df6d82a226b0e6ad92",
+ prePatches("k8s-infra-bzl4-compat.patch"),
).with(prePatches("k8s-client-go.patch")).use(
"k8s.io/client-go",
).with(patches("k8s-native-mounter.patch")).use(
diff --git a/build/fietsje/planner.go b/build/fietsje/planner.go
index a609884..d006039 100644
--- a/build/fietsje/planner.go
+++ b/build/fietsje/planner.go
@@ -142,11 +142,14 @@
// inject adds a dependency to a collection as if requested by the high-level dependency of the collection. This should
// be used sparingly, for instance when high-level dependencies contain bazel code that uses some external workspaces
// from Go modules, and those workspaces are not defined in parsed transitive dependency definitions like go.mod/sum.
-func (c *collection) inject(importpath, version string) *collection {
+func (c *collection) inject(importpath, version string, opts ...buildOpt) *collection {
d := c.highlevel.child(importpath, version)
c.transitive[importpath] = d
c.p.available[importpath] = d
c.p.enabled[importpath] = true
+ for _, o := range opts {
+ o(c.transitive[importpath])
+ }
return c
}