blob: c3ccadcdc93321b73a12a7cf190a594d26d42601 [file] [log] [blame]
Tim Windelschmidte5e90a82024-07-17 23:46:22 +02001go_sdk = use_extension("@io_bazel_rules_go//go:extensions.bzl", "go_sdk")
Tim Windelschmidt677de972024-09-25 05:30:04 +02002go_sdk.download(version = "1.23.1")
Tim Windelschmidte5e90a82024-07-17 23:46:22 +02003go_sdk.nogo(nogo = "//build/analysis:nogo")
4
5go_deps = use_extension("@bazel_gazelle//:extensions.bzl", "go_deps")
6go_deps.from_file(go_mod = "//:go.mod")
7
8# All *direct* Go dependencies of the module have to be listed explicitly.
9# This list can be automatically updated by running "bazel mod tidy".
10use_repo(
11 go_deps,
12 "co_honnef_go_tools",
13 "com_4d63_gocheckcompilerdirectives",
14 "com_github_adrg_xdg",
15 "com_github_cavaliergopher_cpio",
16 "com_github_cenkalti_backoff_v4",
17 "com_github_cockroachdb_cockroach_go_v2",
18 "com_github_container_storage_interface_spec",
19 "com_github_containerd_containerd",
20 "com_github_containernetworking_plugins",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020021 "com_github_coreos_go_semver",
22 "com_github_corverroos_commentwrap",
23 "com_github_diskfs_go_diskfs",
24 "com_github_docker_distribution",
Serge Bazanski0d9e1252024-09-03 12:16:47 +020025 "com_github_gdamore_tcell_v2",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020026 "com_github_go_delve_delve",
27 "com_github_golang_migrate_migrate_v4",
28 "com_github_google_cel_go",
29 "com_github_google_certificate_transparency_go",
30 "com_github_google_go_cmp",
31 "com_github_google_go_tpm",
32 "com_github_google_go_tpm_tools",
33 "com_github_google_gopacket",
34 "com_github_google_nftables",
35 "com_github_google_uuid",
36 "com_github_iancoleman_strcase",
37 "com_github_improbable_eng_grpc_web",
38 "com_github_insomniacslk_dhcp",
39 "com_github_joho_godotenv",
40 "com_github_kballard_go_shellquote",
41 "com_github_kevinburke_go_bindata",
42 "com_github_klauspost_compress",
43 "com_github_lib_pq",
44 "com_github_mattn_go_shellwords",
45 "com_github_mdlayher_arp",
46 "com_github_mdlayher_ethernet",
47 "com_github_mdlayher_ethtool",
48 "com_github_mdlayher_genetlink",
49 "com_github_mdlayher_kobject",
50 "com_github_mdlayher_netlink",
51 "com_github_mdlayher_packet",
Jan Schär4a180222024-07-29 16:32:54 +020052 "com_github_miekg_dns",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020053 "com_github_mitchellh_go_wordwrap",
54 "com_github_opencontainers_go_digest",
55 "com_github_opencontainers_runc",
56 "com_github_packethost_packngo",
57 "com_github_pkg_errors",
58 "com_github_pkg_sftp",
59 "com_github_prometheus_client_golang",
60 "com_github_prometheus_node_exporter",
61 "com_github_pseudomuto_protoc_gen_doc",
Serge Bazanski0d9e1252024-09-03 12:16:47 +020062 "com_github_rivo_uniseg",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020063 "com_github_rmohr_bazeldnf",
64 "com_github_sbezverk_nfproxy",
Tim Windelschmidt7a1b27d2024-02-22 23:54:58 +010065 "com_github_schollz_progressbar_v3",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020066 "com_github_spf13_cobra",
67 "com_github_spf13_pflag",
68 "com_github_sqlc_dev_sqlc",
69 "com_github_stretchr_testify",
70 "com_github_vishvananda_netlink",
71 "com_github_yalue_native_endian",
72 "com_google_cloud_go_storage",
73 "com_zx2c4_golang_wireguard_wgctrl",
74 "dev_gvisor_gvisor",
75 "io_etcd_go_etcd_api_v3",
76 "io_etcd_go_etcd_client_pkg_v3",
77 "io_etcd_go_etcd_client_v3",
78 "io_etcd_go_etcd_server_v3",
79 "io_etcd_go_etcd_tests_v3",
80 "io_k8s_api",
81 "io_k8s_apimachinery",
82 "io_k8s_apiserver",
83 "io_k8s_cli_runtime",
84 "io_k8s_client_go",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020085 "io_k8s_component_base",
86 "io_k8s_klog_v2",
87 "io_k8s_kubectl",
88 "io_k8s_kubelet",
89 "io_k8s_kubernetes",
90 "io_k8s_pod_security_admission",
Jan Schära48bd3c2024-07-29 17:22:18 +020091 "io_k8s_utils",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020092 "net_starlark_go",
93 "org_golang_google_genproto_googleapis_api",
94 "org_golang_google_grpc",
95 "org_golang_google_protobuf",
96 "org_golang_x_crypto",
97 "org_golang_x_mod",
98 "org_golang_x_net",
99 "org_golang_x_sync",
100 "org_golang_x_sys",
Tim Windelschmidt7a1b27d2024-02-22 23:54:58 +0100101 "org_golang_x_term",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200102 "org_golang_x_text",
103 "org_golang_x_time",
104 "org_golang_x_tools",
105 "org_uber_go_multierr",
106 "org_uber_go_zap",
107)
108
109# Instead of defining a gazelle/module override for every dependency, we have a
110# big dict containing all of them.
111OVERRIDES = {
112 "github.com/containerd/cgroups": {
113 "directives": [
114 "gazelle:proto disable",
115 ],
116 },
117 "github.com/containerd/containerd": {
118 "directives": [
119 "gazelle:proto disable",
120 "gazelle:build_tags no_btrfs,no_zfs",
121 ],
122 "pre_patches": [
123 # We build with newer CRI API definitions.
124 "//third_party/go/patches:containerd-grpc-inherit-unimplemented.patch",
125 ],
126 },
127 "github.com/containerd/cgroups/v3": {
128 "directives": [
129 "gazelle:proto disable",
130 ],
131 },
132 "github.com/containerd/nri": {
133 "directives": [
134 "gazelle:proto disable",
135 ],
136 },
137 "github.com/gogo/protobuf": {
138 "directives": [
139 "gazelle:proto disable",
140 ],
141 },
142 "github.com/google/cel-go": {
143 "build_file_generation": "on",
144 "directives": [
145 "gazelle:go_naming_convention go_default_library",
146 ],
147 },
148 "github.com/google/go-tpm-tools": {
149 "directives": [
150 "gazelle:proto file",
151 ],
152 "pre_patches": [
153 "//third_party/go/patches:go-tpm-tools-fix-proto-paths.patch",
154 ],
155 },
156 "github.com/googleapis/gax-go/v2": {
157 "directives": [
158 "gazelle:proto disable",
159 ],
160 },
161 "github.com/Microsoft/hcsshim": {
162 "directives": [
163 "gazelle:proto disable",
164 ],
165 },
166 "github.com/opencontainers/runc": {
167 "directives": [
168 "gazelle:build_tags seccomp",
169 ],
170 "patches": [
171 "//third_party/go/patches:runc-add-cdeps.patch",
172 ],
173 },
174 "github.com/prometheus/node_exporter": {
175 "directives": [
176 "gazelle:build_tags nobtrfs,nozfs,notapestats,norapl",
177 ],
178 },
179 "github.com/pseudomuto/protoc-gen-doc": {
180 "directives": [
181 "gazelle:resolve go github.com/mwitkow/go-proto-validators @com_github_mwitkow_go_proto_validators//:validators_golang",
182 ],
183 "pre_patches": [
184 "//third_party/go/patches:protoc-gen-doc-no-gogo.patch",
185 ],
186 },
187 "github.com/pseudomuto/protokit": {
188 "directives": [
189 "gazelle:proto disable",
190 ],
191 },
192 "github.com/google/cadvisor": {
193 "directives": [
194 "gazelle:proto disable_global",
195 ],
196 },
197 "github.com/sqlc-dev/sqlc": {
198 "build_extra_args": [
199 "-exclude=internal/ext/wasm/wasm.go",
200 ],
201 "directives": [
202 "gazelle:proto disable",
203 ],
204 },
205 "github.com/containerd/ttrpc": {
206 "directives": [
207 "gazelle:proto disable",
208 ],
209 },
210 "go.etcd.io/etcd/api/v3": {
211 "directives": [
212 "gazelle:proto disable",
213 ],
214 },
215 "go.etcd.io/etcd/raft/v3": {
216 "directives": [
217 "gazelle:proto disable",
218 ],
219 },
220 "go.etcd.io/etcd/server/v3": {
221 "directives": [
222 "gazelle:proto disable",
223 ],
224 "patches": [
225 "//third_party/go/patches:etcd-fix-embed-close.patch",
Jan Schäre551d312024-09-17 12:38:54 +0200226 "//third_party/go/patches:etcd-fix-islearner-panic.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200227 ],
228 },
229 "github.com/grpc-ecosystem/grpc-gateway": {
230 # Force generation of new build files for this package, required due to changes in how gazelle handles @go_googleapis.
231 "build_file_generation": "on",
232 "directives": [
233 "gazelle:exclude **/**_test.go",
234 "gazelle:exclude examples",
235 "gazelle:resolve go github.com/grpc-ecosystem/grpc-gateway/internal //internal",
236 "gazelle:resolve go github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options //protoc-gen-swagger/options",
237 "gazelle:proto disable_global",
238 ],
239 },
240 "k8s.io/api": {
241 "directives": [
242 "gazelle:proto disable",
243 ],
244 },
245 "k8s.io/apiextensions-apiserver": {
246 "directives": [
247 "gazelle:proto disable",
248 ],
249 },
250 "k8s.io/apiserver": {
251 "directives": [
252 "gazelle:proto disable",
253 ],
254 },
255 "k8s.io/cri-api": {
256 "directives": [
257 "gazelle:proto disable",
258 ],
259 },
260 "k8s.io/kube-aggregator": {
261 "directives": [
262 "gazelle:proto disable",
263 ],
264 },
265 "k8s.io/kubelet": {
266 "directives": [
267 "gazelle:proto disable",
268 ],
269 "patches": [
270 "//third_party/go/patches:kubelet-fix-path.patch",
271 ],
272 },
273 "k8s.io/kubernetes": {
274 "directives": [
275 "gazelle:proto disable",
276 "gazelle:build_tags providerless,dockerless",
277 ],
278 "patches": [
279 "//third_party/go/patches:k8s-native-metrics.patch",
280 "//third_party/go/patches:k8s-removed-block-device-pseudo-locks.patch",
281 "//third_party/go/patches:k8s-add-pause-build-file.patch",
282 "//third_party/go/patches:k8s-reserve-metropolis-ports-import.patch",
283 ],
284 "pre_patches": [
285 "//third_party/go/patches:k8s-drop-legacy-log-path.patch",
286 "//third_party/go/patches:k8s-reserve-metropolis-ports.patch",
287 ],
288 },
289 "k8s.io/metrics": {
290 "directives": [
291 "gazelle:proto disable",
292 ],
293 },
294 "google.golang.org/genproto/googleapis/api": {
295 "directives": [
296 "gazelle:proto disable_global",
297 ],
298 },
299 "google.golang.org/genproto/googleapis/rpc": {
300 "directives": [
301 "gazelle:proto disable_global",
302 ],
303 },
304 "google.golang.org/grpc": {
305 "directives": [
306 "gazelle:proto disable",
307 ],
308 },
309 "github.com/pingcap/tidb/parser": {
310 "build_file_generation": "on",
311 },
312 "golang.org/x/mod": {
313 "build_extra_args": [
314 "-go_naming_convention=import_alias",
315 "-go_naming_convention_external=import_alias",
316 ],
317 },
318 "golang.org/x/sync": {
319 "build_extra_args": [
320 "-go_naming_convention=import_alias",
321 "-go_naming_convention_external=import_alias",
322 ],
323 },
324 "github.com/containernetworking/cni": {
325 "patches": [
326 "//third_party/go/patches:cni-fix-cachepath.patch",
327 ],
328 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200329 "github.com/corverroos/commentwrap": {
330 "patches": [
331 "//third_party/go/patches:commentwrap-uri.patch",
332 ],
333 },
334 "github.com/go-delve/delve": {
335 "patches": [
336 "//third_party/go/patches:delve-fix-cgo.patch",
337 ],
338 },
339 "github.com/pganalyze/pg_query_go/v4": {
340 "patches": [
341 "//third_party/go/patches:pganalyze-add-cdeps.patch",
342 ],
343 },
344 "github.com/sbezverk/nfproxy": {
345 "pre_patches": [
346 "//third_party/go/patches:nfproxy-adapt-to-k8s-1.28.patch",
347 ],
348 },
349 "k8s.io/kubectl": {
350 "patches": [
351 "//third_party/go/patches:kubectl-fix-embed.patch",
352 ],
353 },
354 "github.com/seccomp/libseccomp-golang": {
355 "patches": [
356 "//third_party/go/patches:libseccomp.patch",
357 ],
358 },
359 "github.com/vishvananda/netlink": {
360 "patches": [
361 "//third_party/go/patches:netlink-permhwaddr.patch",
362 "//third_party/go/patches:netlink-use-rtm_setlink.patch",
363 ],
364 },
365 "gvisor.dev/gvisor": {
366 "patches": [
367 "//third_party/go/patches:gvisor-fix-syslog.patch",
368 # Gazelle doesn't understand conditional build files.
369 # https://github.com/bazelbuild/bazel-gazelle/issues/1262
370 "//third_party/go/patches:gvisor-fix-gazelle-debug-builds.patch",
371 ],
372 "pre_patches": [
373 "//third_party/go/patches:gvisor-containerd-compat.patch",
374 # Modified patch for the go branch.
375 # Upstream issue https://github.com/google/gvisor/issues/9039
376 # Upstream patch https://github.com/google/gvisor/commit/62afa160fe8ad17302d43f7c6016061de57c7f4d
377 "//third_party/go/patches:gvisor-fix-debug-builds.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200378 ],
379 },
380 "go.etcd.io/etcd/tests/v3": {
381 "patches": [
382 "//third_party/go/patches:etcd-integration-logging.patch",
383 ],
384 },
385 "k8s.io/mount-utils": {
386 "pre_patches": [
387 "//third_party/go/patches:k8s-native-mounter.patch",
388 ],
389 },
390 "golang.org/x/tools": {
391 "patches": [
392 "//third_party/go/patches:goimports-group-merging.patch",
393 ],
394 },
395}
396
397# MODULE.bazel doesn't support loops, but since we have lots of overrides,
398# this is the more readable approach.
399[
400 [
401 go_deps.gazelle_override(
402 build_extra_args = overrides.get("build_extra_args") or [],
403 build_file_generation = overrides.get("build_file_generation") or "auto",
404 directives = overrides.get("directives") or [],
405 path = path,
406 ),
407 go_deps.module_override(
408 patch_strip = 1,
409 patches = overrides.get("patches") or [],
410 path = path,
411 pre_patches = overrides.get("pre_patches") or [],
412 ),
413 ]
414 for path, overrides in OVERRIDES.items()
415]