blob: 969693ad9addd81294a6b1ac2d21a701358ac486 [file] [log] [blame]
Tim Windelschmidte5e90a82024-07-17 23:46:22 +02001go_sdk = use_extension("@io_bazel_rules_go//go:extensions.bzl", "go_sdk")
2go_sdk.download(version = "1.22.5")
3go_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",
85 "io_k8s_code_generator",
86 "io_k8s_component_base",
87 "io_k8s_klog_v2",
88 "io_k8s_kubectl",
89 "io_k8s_kubelet",
90 "io_k8s_kubernetes",
91 "io_k8s_pod_security_admission",
Jan Schära48bd3c2024-07-29 17:22:18 +020092 "io_k8s_utils",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020093 "net_starlark_go",
94 "org_golang_google_genproto_googleapis_api",
95 "org_golang_google_grpc",
96 "org_golang_google_protobuf",
97 "org_golang_x_crypto",
98 "org_golang_x_mod",
99 "org_golang_x_net",
100 "org_golang_x_sync",
101 "org_golang_x_sys",
Tim Windelschmidt7a1b27d2024-02-22 23:54:58 +0100102 "org_golang_x_term",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200103 "org_golang_x_text",
104 "org_golang_x_time",
105 "org_golang_x_tools",
106 "org_uber_go_multierr",
107 "org_uber_go_zap",
108)
109
110# Instead of defining a gazelle/module override for every dependency, we have a
111# big dict containing all of them.
112OVERRIDES = {
113 "github.com/containerd/cgroups": {
114 "directives": [
115 "gazelle:proto disable",
116 ],
117 },
118 "github.com/containerd/containerd": {
119 "directives": [
120 "gazelle:proto disable",
121 "gazelle:build_tags no_btrfs,no_zfs",
122 ],
123 "pre_patches": [
124 # We build with newer CRI API definitions.
125 "//third_party/go/patches:containerd-grpc-inherit-unimplemented.patch",
126 ],
127 },
128 "github.com/containerd/cgroups/v3": {
129 "directives": [
130 "gazelle:proto disable",
131 ],
132 },
133 "github.com/containerd/nri": {
134 "directives": [
135 "gazelle:proto disable",
136 ],
137 },
138 "github.com/gogo/protobuf": {
139 "directives": [
140 "gazelle:proto disable",
141 ],
142 },
143 "github.com/google/cel-go": {
144 "build_file_generation": "on",
145 "directives": [
146 "gazelle:go_naming_convention go_default_library",
147 ],
148 },
149 "github.com/google/go-tpm-tools": {
150 "directives": [
151 "gazelle:proto file",
152 ],
153 "pre_patches": [
154 "//third_party/go/patches:go-tpm-tools-fix-proto-paths.patch",
155 ],
156 },
157 "github.com/googleapis/gax-go/v2": {
158 "directives": [
159 "gazelle:proto disable",
160 ],
161 },
162 "github.com/Microsoft/hcsshim": {
163 "directives": [
164 "gazelle:proto disable",
165 ],
166 },
167 "github.com/opencontainers/runc": {
168 "directives": [
169 "gazelle:build_tags seccomp",
170 ],
171 "patches": [
172 "//third_party/go/patches:runc-add-cdeps.patch",
173 ],
174 },
175 "github.com/prometheus/node_exporter": {
176 "directives": [
177 "gazelle:build_tags nobtrfs,nozfs,notapestats,norapl",
178 ],
179 },
180 "github.com/pseudomuto/protoc-gen-doc": {
181 "directives": [
182 "gazelle:resolve go github.com/mwitkow/go-proto-validators @com_github_mwitkow_go_proto_validators//:validators_golang",
183 ],
184 "pre_patches": [
185 "//third_party/go/patches:protoc-gen-doc-no-gogo.patch",
186 ],
187 },
188 "github.com/pseudomuto/protokit": {
189 "directives": [
190 "gazelle:proto disable",
191 ],
192 },
193 "github.com/google/cadvisor": {
194 "directives": [
195 "gazelle:proto disable_global",
196 ],
197 },
198 "github.com/sqlc-dev/sqlc": {
199 "build_extra_args": [
200 "-exclude=internal/ext/wasm/wasm.go",
201 ],
202 "directives": [
203 "gazelle:proto disable",
204 ],
205 },
206 "github.com/containerd/ttrpc": {
207 "directives": [
208 "gazelle:proto disable",
209 ],
210 },
211 "go.etcd.io/etcd/api/v3": {
212 "directives": [
213 "gazelle:proto disable",
214 ],
215 },
216 "go.etcd.io/etcd/raft/v3": {
217 "directives": [
218 "gazelle:proto disable",
219 ],
220 },
221 "go.etcd.io/etcd/server/v3": {
222 "directives": [
223 "gazelle:proto disable",
224 ],
225 "patches": [
226 "//third_party/go/patches:etcd-fix-embed-close.patch",
Jan Schäre551d312024-09-17 12:38:54 +0200227 "//third_party/go/patches:etcd-fix-islearner-panic.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200228 ],
229 },
230 "github.com/grpc-ecosystem/grpc-gateway": {
231 # Force generation of new build files for this package, required due to changes in how gazelle handles @go_googleapis.
232 "build_file_generation": "on",
233 "directives": [
234 "gazelle:exclude **/**_test.go",
235 "gazelle:exclude examples",
236 "gazelle:resolve go github.com/grpc-ecosystem/grpc-gateway/internal //internal",
237 "gazelle:resolve go github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options //protoc-gen-swagger/options",
238 "gazelle:proto disable_global",
239 ],
240 },
241 "k8s.io/api": {
242 "directives": [
243 "gazelle:proto disable",
244 ],
245 },
246 "k8s.io/apiextensions-apiserver": {
247 "directives": [
248 "gazelle:proto disable",
249 ],
250 },
251 "k8s.io/apiserver": {
252 "directives": [
253 "gazelle:proto disable",
254 ],
255 },
256 "k8s.io/cri-api": {
257 "directives": [
258 "gazelle:proto disable",
259 ],
260 },
261 "k8s.io/kube-aggregator": {
262 "directives": [
263 "gazelle:proto disable",
264 ],
265 },
266 "k8s.io/kubelet": {
267 "directives": [
268 "gazelle:proto disable",
269 ],
270 "patches": [
271 "//third_party/go/patches:kubelet-fix-path.patch",
272 ],
273 },
274 "k8s.io/kubernetes": {
275 "directives": [
276 "gazelle:proto disable",
277 "gazelle:build_tags providerless,dockerless",
278 ],
279 "patches": [
280 "//third_party/go/patches:k8s-native-metrics.patch",
281 "//third_party/go/patches:k8s-removed-block-device-pseudo-locks.patch",
282 "//third_party/go/patches:k8s-add-pause-build-file.patch",
283 "//third_party/go/patches:k8s-reserve-metropolis-ports-import.patch",
284 ],
285 "pre_patches": [
286 "//third_party/go/patches:k8s-drop-legacy-log-path.patch",
287 "//third_party/go/patches:k8s-reserve-metropolis-ports.patch",
288 ],
289 },
290 "k8s.io/metrics": {
291 "directives": [
292 "gazelle:proto disable",
293 ],
294 },
295 "google.golang.org/genproto/googleapis/api": {
296 "directives": [
297 "gazelle:proto disable_global",
298 ],
299 },
300 "google.golang.org/genproto/googleapis/rpc": {
301 "directives": [
302 "gazelle:proto disable_global",
303 ],
304 },
305 "google.golang.org/grpc": {
306 "directives": [
307 "gazelle:proto disable",
308 ],
309 },
310 "github.com/pingcap/tidb/parser": {
311 "build_file_generation": "on",
312 },
313 "golang.org/x/mod": {
314 "build_extra_args": [
315 "-go_naming_convention=import_alias",
316 "-go_naming_convention_external=import_alias",
317 ],
318 },
319 "golang.org/x/sync": {
320 "build_extra_args": [
321 "-go_naming_convention=import_alias",
322 "-go_naming_convention_external=import_alias",
323 ],
324 },
325 "github.com/containernetworking/cni": {
326 "patches": [
327 "//third_party/go/patches:cni-fix-cachepath.patch",
328 ],
329 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200330 "github.com/corverroos/commentwrap": {
331 "patches": [
332 "//third_party/go/patches:commentwrap-uri.patch",
333 ],
334 },
335 "github.com/go-delve/delve": {
336 "patches": [
337 "//third_party/go/patches:delve-fix-cgo.patch",
338 ],
339 },
340 "github.com/pganalyze/pg_query_go/v4": {
341 "patches": [
342 "//third_party/go/patches:pganalyze-add-cdeps.patch",
343 ],
344 },
345 "github.com/sbezverk/nfproxy": {
346 "pre_patches": [
347 "//third_party/go/patches:nfproxy-adapt-to-k8s-1.28.patch",
348 ],
349 },
350 "k8s.io/kubectl": {
351 "patches": [
352 "//third_party/go/patches:kubectl-fix-embed.patch",
353 ],
354 },
355 "github.com/seccomp/libseccomp-golang": {
356 "patches": [
357 "//third_party/go/patches:libseccomp.patch",
358 ],
359 },
360 "github.com/vishvananda/netlink": {
361 "patches": [
362 "//third_party/go/patches:netlink-permhwaddr.patch",
363 "//third_party/go/patches:netlink-use-rtm_setlink.patch",
364 ],
365 },
366 "gvisor.dev/gvisor": {
367 "patches": [
368 "//third_party/go/patches:gvisor-fix-syslog.patch",
369 # Gazelle doesn't understand conditional build files.
370 # https://github.com/bazelbuild/bazel-gazelle/issues/1262
371 "//third_party/go/patches:gvisor-fix-gazelle-debug-builds.patch",
372 ],
373 "pre_patches": [
374 "//third_party/go/patches:gvisor-containerd-compat.patch",
375 # Modified patch for the go branch.
376 # Upstream issue https://github.com/google/gvisor/issues/9039
377 # Upstream patch https://github.com/google/gvisor/commit/62afa160fe8ad17302d43f7c6016061de57c7f4d
378 "//third_party/go/patches:gvisor-fix-debug-builds.patch",
Lorenz Brun732a8842024-08-26 23:25:37 +0200379 "//third_party/go/patches:gvisor-unix-0.20.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200380 ],
381 },
382 "go.etcd.io/etcd/tests/v3": {
383 "patches": [
384 "//third_party/go/patches:etcd-integration-logging.patch",
385 ],
386 },
387 "k8s.io/mount-utils": {
388 "pre_patches": [
389 "//third_party/go/patches:k8s-native-mounter.patch",
390 ],
391 },
392 "golang.org/x/tools": {
393 "patches": [
394 "//third_party/go/patches:goimports-group-merging.patch",
395 ],
396 },
397}
398
399# MODULE.bazel doesn't support loops, but since we have lots of overrides,
400# this is the more readable approach.
401[
402 [
403 go_deps.gazelle_override(
404 build_extra_args = overrides.get("build_extra_args") or [],
405 build_file_generation = overrides.get("build_file_generation") or "auto",
406 directives = overrides.get("directives") or [],
407 path = path,
408 ),
409 go_deps.module_override(
410 patch_strip = 1,
411 patches = overrides.get("patches") or [],
412 path = path,
413 pre_patches = overrides.get("pre_patches") or [],
414 ),
415 ]
416 for path, overrides in OVERRIDES.items()
417]