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/third_party/go/patches/k8s-infra-bzl4-compat.patch b/third_party/go/patches/k8s-infra-bzl4-compat.patch
new file mode 100644
index 0000000..4be0fe8
--- /dev/null
+++ b/third_party/go/patches/k8s-infra-bzl4-compat.patch
@@ -0,0 +1,82 @@
+Copyright 2020 The Monogon Project Authors.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+
+From 6313aef65ed37aa971737058af391f5be1ae976c Mon Sep 17 00:00:00 2001
+From: Lorenz Brun <lorenz@nexantic.com>
+Date: Wed, 3 Feb 2021 18:11:03 +0100
+Subject: [PATCH] Don't use run_shell with list as cmd
+
+Going upstream at https://github.com/kubernetes/repo-infra/pull/225
+---
+ defs/go.bzl | 26 ++++++++++++++------------
+ 1 file changed, 14 insertions(+), 12 deletions(-)
+
+diff --git a/defs/go.bzl b/defs/go.bzl
+index 21cffdd..f4617e1 100644
+--- a/defs/go.bzl
++++ b/defs/go.bzl
+@@ -63,16 +63,7 @@ def _go_genrule_impl(ctx):
+ 
+     srcs = [src for srcs in ctx.attr.srcs for src in srcs.files.to_list()]
+ 
+-    deps = depset(
+-        gopath_files + srcs,
+-        transitive =
+-            # tools
+-            [dep.files for dep in ctx.attr.tools] +
+-            # go toolchain
+-            [depset(go.sdk.libs + go.sdk.srcs + go.sdk.tools + [go.sdk.go])],
+-    )
+-
+-    _, cmd, _ = ctx.resolve_command(
++    inputs, cmd, input_manifests = ctx.resolve_command(
+         command = ctx.attr.cmd,
+         attribute = "cmd",
+         expand_locations = True,
+@@ -83,6 +74,15 @@ def _go_genrule_impl(ctx):
+         tools = ctx.attr.tools,
+     )
+ 
++    deps = depset(
++        gopath_files + srcs + inputs,
++        transitive =
++            # tools
++            [dep.files for dep in ctx.attr.tools] +
++            # go toolchain
++            [depset(go.sdk.libs + go.sdk.srcs + go.sdk.tools + [go.sdk.go])],
++    )
++
+     env = dict()
+     env.update(ctx.configuration.default_shell_env)
+     env.update(go.env)
+@@ -92,11 +92,13 @@ def _go_genrule_impl(ctx):
+         "GOROOT": paths.dirname(go.sdk.root_file.path),
+     })
+ 
+-    ctx.actions.run_shell(
++    ctx.actions.run(
+         inputs = deps,
+         outputs = ctx.outputs.outs,
+         env = env,
+-        command = cmd,
++        executable = cmd[0],
++        arguments = cmd[1:],
++        input_manifests = input_manifests,
+         progress_message = "%s %s" % (ctx.attr.message, ctx),
+         mnemonic = "GoGenrule",
+     )
+-- 
+2.25.1
+
diff --git a/third_party/go/repositories.bzl b/third_party/go/repositories.bzl
index bb58f51..e2b258a 100644
--- a/third_party/go/repositories.bzl
+++ b/third_party/go/repositories.bzl
@@ -2612,6 +2612,10 @@
         importpath = "k8s.io/repo-infra",
         version = "v0.1.4-0.20210105022653-a3483874bd37",
         sum = "h1:0GPavEcPKBA0rYl7f6dO0mXYmx7t9RaXD3be2g23Ps4=",
+        pre_patches = [
+            "//third_party/go/patches:k8s-infra-bzl4-compat.patch",
+        ],
+        patch_args = ["-p1"],
         build_extra_args = [
             "-go_naming_convention=go_default_library",
             "-go_naming_convention_external=go_default_library",