blob: e0178c7c6b928f6a8cc8adf3e2809d0acd972d3d [file] [log] [blame]
Tim Windelschmidte5e90a82024-07-17 23:46:22 +02001go_sdk = use_extension("@io_bazel_rules_go//go:extensions.bzl", "go_sdk")
Tim Windelschmidt515f1f32025-02-24 18:51:31 +01002go_sdk.download(version = "1.24.0")
Tim Windelschmidta0684402025-02-25 11:32:40 +01003go_sdk.nogo(
4 includes = ["all"],
5 nogo = "//build/analysis:nogo",
6)
Tim Windelschmidte5e90a82024-07-17 23:46:22 +02007
Tim Windelschmidted9a5832025-02-04 03:02:45 +01008go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
Tim Windelschmidte5e90a82024-07-17 23:46:22 +02009go_deps.from_file(go_mod = "//:go.mod")
10
11# All *direct* Go dependencies of the module have to be listed explicitly.
12# This list can be automatically updated by running "bazel mod tidy".
13use_repo(
14 go_deps,
15 "co_honnef_go_tools",
16 "com_4d63_gocheckcompilerdirectives",
17 "com_github_adrg_xdg",
18 "com_github_cavaliergopher_cpio",
19 "com_github_cenkalti_backoff_v4",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020020 "com_github_container_storage_interface_spec",
Lorenz Brun0ec0c532024-08-29 12:39:47 +000021 "com_github_containerd_containerd_v2",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020022 "com_github_containernetworking_plugins",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020023 "com_github_coreos_go_semver",
24 "com_github_corverroos_commentwrap",
25 "com_github_diskfs_go_diskfs",
Serge Bazanski0d9e1252024-09-03 12:16:47 +020026 "com_github_gdamore_tcell_v2",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020027 "com_github_go_delve_delve",
Tim Windelschmidt7c0bd0b2025-01-10 04:15:37 +010028 "com_github_golangci_gofmt",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020029 "com_github_google_cel_go",
30 "com_github_google_certificate_transparency_go",
31 "com_github_google_go_cmp",
32 "com_github_google_go_tpm",
33 "com_github_google_go_tpm_tools",
34 "com_github_google_gopacket",
35 "com_github_google_nftables",
36 "com_github_google_uuid",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020037 "com_github_insomniacslk_dhcp",
38 "com_github_joho_godotenv",
39 "com_github_kballard_go_shellquote",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020040 "com_github_klauspost_compress",
Jan Schär17ad63f2025-02-27 14:43:56 +010041 "com_github_mattfenwick_cyclonus",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020042 "com_github_mattn_go_shellwords",
43 "com_github_mdlayher_arp",
44 "com_github_mdlayher_ethernet",
45 "com_github_mdlayher_ethtool",
46 "com_github_mdlayher_genetlink",
47 "com_github_mdlayher_kobject",
48 "com_github_mdlayher_netlink",
49 "com_github_mdlayher_packet",
Jan Schär4a180222024-07-29 16:32:54 +020050 "com_github_miekg_dns",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020051 "com_github_mitchellh_go_wordwrap",
52 "com_github_opencontainers_go_digest",
Jan Schärb48174d2025-04-14 10:13:02 +000053 "com_github_opencontainers_image_spec",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020054 "com_github_opencontainers_runc",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020055 "com_github_pkg_errors",
56 "com_github_pkg_sftp",
57 "com_github_prometheus_client_golang",
58 "com_github_prometheus_node_exporter",
Serge Bazanski0d9e1252024-09-03 12:16:47 +020059 "com_github_rivo_uniseg",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020060 "com_github_rmohr_bazeldnf",
61 "com_github_sbezverk_nfproxy",
Tim Windelschmidt7a1b27d2024-02-22 23:54:58 +010062 "com_github_schollz_progressbar_v3",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020063 "com_github_spf13_cobra",
64 "com_github_spf13_pflag",
65 "com_github_sqlc_dev_sqlc",
66 "com_github_stretchr_testify",
67 "com_github_vishvananda_netlink",
68 "com_github_yalue_native_endian",
69 "com_google_cloud_go_storage",
70 "com_zx2c4_golang_wireguard_wgctrl",
71 "dev_gvisor_gvisor",
72 "io_etcd_go_etcd_api_v3",
73 "io_etcd_go_etcd_client_pkg_v3",
74 "io_etcd_go_etcd_client_v3",
75 "io_etcd_go_etcd_server_v3",
76 "io_etcd_go_etcd_tests_v3",
77 "io_k8s_api",
78 "io_k8s_apimachinery",
79 "io_k8s_apiserver",
80 "io_k8s_cli_runtime",
81 "io_k8s_client_go",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020082 "io_k8s_component_base",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020083 "io_k8s_kubectl",
84 "io_k8s_kubelet",
85 "io_k8s_kubernetes",
86 "io_k8s_pod_security_admission",
Jan Schära48bd3c2024-07-29 17:22:18 +020087 "io_k8s_utils",
Lorenz Brun52700ae2025-01-28 15:07:08 +010088 "org_dolansoft_git_dolansoft_k8s_nft_npc",
Lorenz Brun227c5cb2025-01-09 21:39:55 +010089 "org_go4_netipx",
Tim Windelschmidt5178dd72024-12-04 04:38:45 +010090 "org_golang_google_api",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020091 "org_golang_google_genproto_googleapis_api",
92 "org_golang_google_grpc",
93 "org_golang_google_protobuf",
94 "org_golang_x_crypto",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020095 "org_golang_x_net",
96 "org_golang_x_sync",
97 "org_golang_x_sys",
Tim Windelschmidt7a1b27d2024-02-22 23:54:58 +010098 "org_golang_x_term",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020099 "org_golang_x_text",
100 "org_golang_x_time",
101 "org_golang_x_tools",
102 "org_uber_go_multierr",
103 "org_uber_go_zap",
104)
105
106# Instead of defining a gazelle/module override for every dependency, we have a
107# big dict containing all of them.
108OVERRIDES = {
Lorenz Brun0ec0c532024-08-29 12:39:47 +0000109 "github.com/containerd/containerd/v2": {
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200110 "directives": [
111 "gazelle:proto disable",
Tim Windelschmidt25e0d8f2024-12-02 23:46:24 +0100112 "gazelle:build_tags no_aufs,no_btrfs,no_devmapper,no_zfs",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200113 ],
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200114 },
115 "github.com/containerd/cgroups/v3": {
116 "directives": [
117 "gazelle:proto disable",
118 ],
119 },
120 "github.com/containerd/nri": {
121 "directives": [
122 "gazelle:proto disable",
123 ],
124 },
125 "github.com/gogo/protobuf": {
126 "directives": [
127 "gazelle:proto disable",
128 ],
129 },
130 "github.com/google/cel-go": {
131 "build_file_generation": "on",
132 "directives": [
133 "gazelle:go_naming_convention go_default_library",
134 ],
135 },
136 "github.com/google/go-tpm-tools": {
137 "directives": [
138 "gazelle:proto file",
139 ],
140 "pre_patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100141 "//third_party/com_github_google_go_tpm_tools:go-tpm-tools-fix-proto-paths.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200142 ],
143 },
144 "github.com/googleapis/gax-go/v2": {
145 "directives": [
146 "gazelle:proto disable",
147 ],
148 },
149 "github.com/Microsoft/hcsshim": {
150 "directives": [
151 "gazelle:proto disable",
152 ],
153 },
154 "github.com/opencontainers/runc": {
155 "directives": [
156 "gazelle:build_tags seccomp",
Jan Schär7c38e782025-04-29 09:23:37 +0000157 # Make @com_github_opencontainers_runc//:runc_lib visible
158 "gazelle:go_visibility //visibility:public",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200159 ],
160 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100161 "//third_party/com_github_opencontainers_runc:runc-add-cdeps.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200162 ],
163 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200164 "github.com/google/cadvisor": {
165 "directives": [
166 "gazelle:proto disable_global",
167 ],
Lorenz Brun837cb8e2024-12-23 13:52:56 +0100168 "pre_patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100169 "//third_party/com_github_google_cadvisor:cadvisor-errdefs1.patch",
Lorenz Brun837cb8e2024-12-23 13:52:56 +0100170 ],
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200171 },
172 "github.com/sqlc-dev/sqlc": {
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200173 "directives": [
174 "gazelle:proto disable",
Tim Windelschmidt25e0d8f2024-12-02 23:46:24 +0100175 "gazelle:build_tags nowasm",
Jan Schär7c38e782025-04-29 09:23:37 +0000176 # Make @com_github_sqlc_dev_sqlc//cmd/sqlc:sqlc_lib visible
177 "gazelle:go_visibility //visibility:public",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200178 ],
179 },
Tim Windelschmidtd4817492025-06-16 15:03:12 +0200180 "github.com/bytecodealliance/wasmtime-go/v14": {
181 "directives": [
182 "gazelle:go_naming_convention go_default_library",
183 ],
184 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200185 "github.com/containerd/ttrpc": {
186 "directives": [
187 "gazelle:proto disable",
188 ],
189 },
190 "go.etcd.io/etcd/api/v3": {
191 "directives": [
192 "gazelle:proto disable",
193 ],
194 },
195 "go.etcd.io/etcd/raft/v3": {
196 "directives": [
197 "gazelle:proto disable",
198 ],
199 },
200 "go.etcd.io/etcd/server/v3": {
201 "directives": [
202 "gazelle:proto disable",
203 ],
204 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100205 "//third_party/com_go_etcd_io_etcd_server_v3:etcd-fix-embed-close.patch",
206 "//third_party/com_go_etcd_io_etcd_server_v3:etcd-fix-islearner-panic.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200207 ],
208 },
209 "github.com/grpc-ecosystem/grpc-gateway": {
210 # Force generation of new build files for this package, required due to changes in how gazelle handles @go_googleapis.
211 "build_file_generation": "on",
212 "directives": [
213 "gazelle:exclude **/**_test.go",
214 "gazelle:exclude examples",
215 "gazelle:resolve go github.com/grpc-ecosystem/grpc-gateway/internal //internal",
216 "gazelle:resolve go github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options //protoc-gen-swagger/options",
217 "gazelle:proto disable_global",
218 ],
219 },
220 "k8s.io/api": {
221 "directives": [
222 "gazelle:proto disable",
223 ],
224 },
Tim Windelschmidtd4817492025-06-16 15:03:12 +0200225 "k8s.io/kms": {
226 "directives": [
227 "gazelle:proto disable",
228 ],
229 },
230 "k8s.io/externaljwt": {
231 "directives": [
232 "gazelle:proto disable",
233 ],
234 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200235 "k8s.io/apiextensions-apiserver": {
236 "directives": [
237 "gazelle:proto disable",
238 ],
239 },
240 "k8s.io/apiserver": {
241 "directives": [
242 "gazelle:proto disable",
243 ],
244 },
Lorenz Brun95190ce2025-01-28 13:07:00 +0000245 "k8s.io/client-go": {
Jan Schär36f3b6d2025-05-20 09:05:12 +0000246 "patches": [
247 "//third_party/com_k8s_io_client_go:version-stamp.patch",
248 ],
Lorenz Brun95190ce2025-01-28 13:07:00 +0000249 "pre_patches": [
Tim Windelschmidt71718ba2025-02-07 00:04:28 +0100250 "//third_party/com_k8s_io_client_go:k8s-fix-websocket-custom-dialer.patch",
Lorenz Brun95190ce2025-01-28 13:07:00 +0000251 ],
252 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200253 "k8s.io/cri-api": {
254 "directives": [
255 "gazelle:proto disable",
256 ],
257 },
258 "k8s.io/kube-aggregator": {
259 "directives": [
260 "gazelle:proto disable",
261 ],
262 },
263 "k8s.io/kubelet": {
264 "directives": [
265 "gazelle:proto disable",
266 ],
267 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100268 "//third_party/com_k8s_io_kubelet:kubelet-fix-path.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200269 ],
270 },
271 "k8s.io/kubernetes": {
272 "directives": [
273 "gazelle:proto disable",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200274 ],
275 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100276 "//third_party/com_k8s_io_kubernetes:k8s-native-metrics.patch",
277 "//third_party/com_k8s_io_kubernetes:k8s-removed-block-device-pseudo-locks.patch",
278 "//third_party/com_k8s_io_kubernetes:k8s-add-pause-build-file.patch",
279 "//third_party/com_k8s_io_kubernetes:k8s-reserve-metropolis-ports-import.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200280 ],
281 "pre_patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100282 "//third_party/com_k8s_io_kubernetes:k8s-drop-legacy-log-path.patch",
283 "//third_party/com_k8s_io_kubernetes:k8s-reserve-metropolis-ports.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200284 ],
285 },
286 "k8s.io/metrics": {
287 "directives": [
288 "gazelle:proto disable",
289 ],
290 },
291 "google.golang.org/genproto/googleapis/api": {
292 "directives": [
293 "gazelle:proto disable_global",
294 ],
295 },
296 "google.golang.org/genproto/googleapis/rpc": {
297 "directives": [
298 "gazelle:proto disable_global",
299 ],
300 },
301 "google.golang.org/grpc": {
302 "directives": [
303 "gazelle:proto disable",
304 ],
305 },
Tim Windelschmidtd4817492025-06-16 15:03:12 +0200306 "github.com/containers/ocicrypt": {
307 "directives": [
308 "gazelle:proto disable",
309 ],
310 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200311 "github.com/pingcap/tidb/parser": {
312 "build_file_generation": "on",
313 },
314 "golang.org/x/mod": {
315 "build_extra_args": [
316 "-go_naming_convention=import_alias",
317 "-go_naming_convention_external=import_alias",
318 ],
319 },
320 "golang.org/x/sync": {
321 "build_extra_args": [
322 "-go_naming_convention=import_alias",
323 "-go_naming_convention_external=import_alias",
324 ],
325 },
326 "github.com/containernetworking/cni": {
327 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100328 "//third_party/com_github_containernetworking_cni:cni-fix-cachepath.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200329 ],
330 },
Lorenz Brun0dca6c92025-01-28 15:04:13 +0100331 "github.com/containernetworking/plugins": {
332 "patches": [
Tim Windelschmidt71718ba2025-02-07 00:04:28 +0100333 "//third_party/com_github_containernetworking_plugins:cniplugins-add-linkgroup.patch",
Lorenz Brun0dca6c92025-01-28 15:04:13 +0100334 ],
335 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200336 "github.com/corverroos/commentwrap": {
337 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100338 "//third_party/com_github_corverroos_commentwrap:commentwrap-uri.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200339 ],
340 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200341 "github.com/pganalyze/pg_query_go/v4": {
342 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100343 "//third_party/com_github_pganalyze_pg_query_go_v4:pganalyze-add-cdeps.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200344 ],
345 },
346 "github.com/sbezverk/nfproxy": {
347 "pre_patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100348 "//third_party/com_github_sbezverk_nfproxy:nfproxy-adapt-to-k8s-1.28.patch",
349 "//third_party/com_github_sbezverk_nfproxy:nfproxy-adapt-to-nftables-0.2.patch",
Lorenz Brun11bf3d32025-01-07 17:49:27 +0100350 ],
351 },
352 "github.com/google/nftables": {
353 "pre_patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100354 "//third_party/com_github_google_nftables:nftables-dynamic-exprs.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200355 ],
356 },
357 "k8s.io/kubectl": {
358 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100359 "//third_party/com_k8s_io_kubectl:kubectl-fix-embed.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200360 ],
361 },
Tim Windelschmidtd4817492025-06-16 15:03:12 +0200362 "sigs.k8s.io/apiserver-network-proxy/konnectivity-client": {
363 "directives": [
364 "gazelle:proto disable",
365 ],
366 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200367 "github.com/seccomp/libseccomp-golang": {
368 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100369 "//third_party/com_github_seccomp_libseccomp_golang:libseccomp.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200370 ],
371 },
372 "github.com/vishvananda/netlink": {
373 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100374 "//third_party/com_github_vishvananda_netlink:netlink-psample.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200375 ],
376 },
377 "gvisor.dev/gvisor": {
378 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100379 "//third_party/com_gvisor_dev_gvisor:gvisor-fix-syslog.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200380 ],
381 "pre_patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100382 "//third_party/com_gvisor_dev_gvisor:gvisor-containerd-compat.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200383 ],
384 },
385 "go.etcd.io/etcd/tests/v3": {
386 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100387 "//third_party/com_go_etcd_io_etcd_tests_v3:etcd-integration-logging.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200388 ],
389 },
Lorenz Brun5c520622025-01-14 14:14:52 +0100390 "k8s.io/component-base": {
391 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100392 "//third_party/com_k8s_io_component_base:k8s-fix-metrics-data-race.patch",
Jan Schär36f3b6d2025-05-20 09:05:12 +0000393 "//third_party/com_k8s_io_component_base:version-stamp.patch",
Lorenz Brun5c520622025-01-14 14:14:52 +0100394 ],
395 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200396 "k8s.io/mount-utils": {
397 "pre_patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100398 "//third_party/com_k8s_io_mount_utils:k8s-native-mounter.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200399 ],
400 },
401 "golang.org/x/tools": {
402 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100403 "//third_party/com_golang_org_x_tools:goimports-group-merging.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200404 ],
405 },
406}
407
408# MODULE.bazel doesn't support loops, but since we have lots of overrides,
409# this is the more readable approach.
410[
411 [
412 go_deps.gazelle_override(
413 build_extra_args = overrides.get("build_extra_args") or [],
414 build_file_generation = overrides.get("build_file_generation") or "auto",
415 directives = overrides.get("directives") or [],
416 path = path,
417 ),
418 go_deps.module_override(
419 patch_strip = 1,
420 patches = overrides.get("patches") or [],
421 path = path,
422 pre_patches = overrides.get("pre_patches") or [],
423 ),
424 ]
425 for path, overrides in OVERRIDES.items()
426]