blob: dfa5b9108c0cf1533d0dbcb93ae76c876f5c4943 [file] [log] [blame]
Tim Windelschmidte5e90a82024-07-17 23:46:22 +02001go_sdk = use_extension("@io_bazel_rules_go//go:extensions.bzl", "go_sdk")
Tim Windelschmidt2b480f62025-07-15 14:45:05 +02002go_sdk.from_file(go_mod = "//:go.mod")
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
Tim Windelschmidt8fd51cd2025-06-29 02:20:17 +020011inject_repo(
12 go_deps,
13 "libpg_query",
14 "seccomp",
15)
16
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020017# All *direct* Go dependencies of the module have to be listed explicitly.
18# This list can be automatically updated by running "bazel mod tidy".
19use_repo(
20 go_deps,
21 "co_honnef_go_tools",
22 "com_4d63_gocheckcompilerdirectives",
23 "com_github_adrg_xdg",
24 "com_github_cavaliergopher_cpio",
25 "com_github_cenkalti_backoff_v4",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020026 "com_github_container_storage_interface_spec",
Lorenz Brun0ec0c532024-08-29 12:39:47 +000027 "com_github_containerd_containerd_v2",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020028 "com_github_containernetworking_plugins",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020029 "com_github_coreos_go_semver",
30 "com_github_corverroos_commentwrap",
31 "com_github_diskfs_go_diskfs",
Serge Bazanski0d9e1252024-09-03 12:16:47 +020032 "com_github_gdamore_tcell_v2",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020033 "com_github_go_delve_delve",
Tim Windelschmidt7c0bd0b2025-01-10 04:15:37 +010034 "com_github_golangci_gofmt",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020035 "com_github_google_cel_go",
36 "com_github_google_certificate_transparency_go",
37 "com_github_google_go_cmp",
38 "com_github_google_go_tpm",
39 "com_github_google_go_tpm_tools",
40 "com_github_google_gopacket",
41 "com_github_google_nftables",
42 "com_github_google_uuid",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020043 "com_github_insomniacslk_dhcp",
44 "com_github_joho_godotenv",
45 "com_github_kballard_go_shellquote",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020046 "com_github_klauspost_compress",
Jan Schär17ad63f2025-02-27 14:43:56 +010047 "com_github_mattfenwick_cyclonus",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020048 "com_github_mattn_go_shellwords",
49 "com_github_mdlayher_arp",
50 "com_github_mdlayher_ethernet",
51 "com_github_mdlayher_ethtool",
52 "com_github_mdlayher_genetlink",
53 "com_github_mdlayher_kobject",
Lorenz Brune08c1602025-06-17 19:19:33 +020054 "com_github_mdlayher_lldp",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020055 "com_github_mdlayher_netlink",
56 "com_github_mdlayher_packet",
Jan Schär4a180222024-07-29 16:32:54 +020057 "com_github_miekg_dns",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020058 "com_github_mitchellh_go_wordwrap",
59 "com_github_opencontainers_go_digest",
Jan Schärb48174d2025-04-14 10:13:02 +000060 "com_github_opencontainers_image_spec",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020061 "com_github_opencontainers_runc",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020062 "com_github_pkg_errors",
63 "com_github_pkg_sftp",
64 "com_github_prometheus_client_golang",
65 "com_github_prometheus_node_exporter",
Serge Bazanski0d9e1252024-09-03 12:16:47 +020066 "com_github_rivo_uniseg",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020067 "com_github_sbezverk_nfproxy",
Tim Windelschmidt7a1b27d2024-02-22 23:54:58 +010068 "com_github_schollz_progressbar_v3",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020069 "com_github_spf13_cobra",
70 "com_github_spf13_pflag",
71 "com_github_sqlc_dev_sqlc",
72 "com_github_stretchr_testify",
73 "com_github_vishvananda_netlink",
74 "com_github_yalue_native_endian",
75 "com_google_cloud_go_storage",
76 "com_zx2c4_golang_wireguard_wgctrl",
77 "dev_gvisor_gvisor",
78 "io_etcd_go_etcd_api_v3",
79 "io_etcd_go_etcd_client_pkg_v3",
80 "io_etcd_go_etcd_client_v3",
81 "io_etcd_go_etcd_server_v3",
82 "io_etcd_go_etcd_tests_v3",
83 "io_k8s_api",
84 "io_k8s_apimachinery",
85 "io_k8s_apiserver",
86 "io_k8s_cli_runtime",
87 "io_k8s_client_go",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020088 "io_k8s_component_base",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020089 "io_k8s_kubectl",
90 "io_k8s_kubelet",
91 "io_k8s_kubernetes",
92 "io_k8s_pod_security_admission",
Jan Schära48bd3c2024-07-29 17:22:18 +020093 "io_k8s_utils",
Lorenz Brun52700ae2025-01-28 15:07:08 +010094 "org_dolansoft_git_dolansoft_k8s_nft_npc",
Lorenz Brun227c5cb2025-01-09 21:39:55 +010095 "org_go4_netipx",
Tim Windelschmidt5178dd72024-12-04 04:38:45 +010096 "org_golang_google_api",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020097 "org_golang_google_genproto_googleapis_api",
98 "org_golang_google_grpc",
99 "org_golang_google_protobuf",
100 "org_golang_x_crypto",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200101 "org_golang_x_net",
102 "org_golang_x_sync",
103 "org_golang_x_sys",
Tim Windelschmidt7a1b27d2024-02-22 23:54:58 +0100104 "org_golang_x_term",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200105 "org_golang_x_text",
106 "org_golang_x_time",
107 "org_golang_x_tools",
108 "org_uber_go_multierr",
109 "org_uber_go_zap",
110)
111
112# Instead of defining a gazelle/module override for every dependency, we have a
113# big dict containing all of them.
114OVERRIDES = {
Lorenz Brun0ec0c532024-08-29 12:39:47 +0000115 "github.com/containerd/containerd/v2": {
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200116 "directives": [
117 "gazelle:proto disable",
Tim Windelschmidt25e0d8f2024-12-02 23:46:24 +0100118 "gazelle:build_tags no_aufs,no_btrfs,no_devmapper,no_zfs",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200119 ],
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200120 },
121 "github.com/containerd/cgroups/v3": {
122 "directives": [
123 "gazelle:proto disable",
124 ],
125 },
126 "github.com/containerd/nri": {
127 "directives": [
128 "gazelle:proto disable",
129 ],
130 },
131 "github.com/gogo/protobuf": {
132 "directives": [
133 "gazelle:proto disable",
134 ],
135 },
136 "github.com/google/cel-go": {
137 "build_file_generation": "on",
138 "directives": [
139 "gazelle:go_naming_convention go_default_library",
140 ],
141 },
142 "github.com/google/go-tpm-tools": {
143 "directives": [
144 "gazelle:proto file",
145 ],
146 "pre_patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100147 "//third_party/com_github_google_go_tpm_tools:go-tpm-tools-fix-proto-paths.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200148 ],
149 },
150 "github.com/googleapis/gax-go/v2": {
151 "directives": [
152 "gazelle:proto disable",
153 ],
154 },
155 "github.com/Microsoft/hcsshim": {
156 "directives": [
157 "gazelle:proto disable",
158 ],
159 },
160 "github.com/opencontainers/runc": {
161 "directives": [
162 "gazelle:build_tags seccomp",
Jan Schär7c38e782025-04-29 09:23:37 +0000163 # Make @com_github_opencontainers_runc//:runc_lib visible
164 "gazelle:go_visibility //visibility:public",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200165 ],
166 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100167 "//third_party/com_github_opencontainers_runc:runc-add-cdeps.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200168 ],
169 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200170 "github.com/google/cadvisor": {
171 "directives": [
172 "gazelle:proto disable_global",
173 ],
Lorenz Brun837cb8e2024-12-23 13:52:56 +0100174 "pre_patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100175 "//third_party/com_github_google_cadvisor:cadvisor-errdefs1.patch",
Lorenz Brun837cb8e2024-12-23 13:52:56 +0100176 ],
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200177 },
178 "github.com/sqlc-dev/sqlc": {
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200179 "directives": [
180 "gazelle:proto disable",
Tim Windelschmidt25e0d8f2024-12-02 23:46:24 +0100181 "gazelle:build_tags nowasm",
Jan Schär7c38e782025-04-29 09:23:37 +0000182 # Make @com_github_sqlc_dev_sqlc//cmd/sqlc:sqlc_lib visible
183 "gazelle:go_visibility //visibility:public",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200184 ],
185 },
Tim Windelschmidtd4817492025-06-16 15:03:12 +0200186 "github.com/bytecodealliance/wasmtime-go/v14": {
Tim Windelschmidt5d357d82025-07-10 18:47:15 +0200187 # wasmtime brings its own BUILD files and for some reason,
188 # Bazel regenerates them in the nixos/nix container but not on
189 # NixOS. We disable replacing the existing directives to fix this.
190 "build_file_generation": "off",
Tim Windelschmidtd4817492025-06-16 15:03:12 +0200191 "directives": [
192 "gazelle:go_naming_convention go_default_library",
193 ],
194 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200195 "github.com/containerd/ttrpc": {
196 "directives": [
197 "gazelle:proto disable",
198 ],
199 },
200 "go.etcd.io/etcd/api/v3": {
201 "directives": [
202 "gazelle:proto disable",
203 ],
204 },
Lorenz Brun62229cf2025-07-07 12:47:31 +0200205 "go.etcd.io/raft/v3": {
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200206 "directives": [
207 "gazelle:proto disable",
208 ],
209 },
210 "go.etcd.io/etcd/server/v3": {
211 "directives": [
212 "gazelle:proto disable",
213 ],
214 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100215 "//third_party/com_go_etcd_io_etcd_server_v3:etcd-fix-embed-close.patch",
Lorenz Brun62229cf2025-07-07 12:47:31 +0200216 "//third_party/com_go_etcd_io_etcd_server_v3:fix-def-warn-threshold.patch",
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100217 "//third_party/com_go_etcd_io_etcd_server_v3:etcd-fix-islearner-panic.patch",
Lorenz Brun62229cf2025-07-07 12:47:31 +0200218 "//third_party/com_go_etcd_io_etcd_server_v3:shutdown-safety.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200219 ],
220 },
Lorenz Brun62229cf2025-07-07 12:47:31 +0200221 "github.com/grpc-ecosystem/grpc-gateway/v2": {
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200222 # Force generation of new build files for this package, required due to changes in how gazelle handles @go_googleapis.
223 "build_file_generation": "on",
224 "directives": [
225 "gazelle:exclude **/**_test.go",
226 "gazelle:exclude examples",
227 "gazelle:resolve go github.com/grpc-ecosystem/grpc-gateway/internal //internal",
228 "gazelle:resolve go github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options //protoc-gen-swagger/options",
229 "gazelle:proto disable_global",
230 ],
231 },
232 "k8s.io/api": {
233 "directives": [
234 "gazelle:proto disable",
235 ],
236 },
Tim Windelschmidtd4817492025-06-16 15:03:12 +0200237 "k8s.io/kms": {
238 "directives": [
239 "gazelle:proto disable",
240 ],
241 },
242 "k8s.io/externaljwt": {
243 "directives": [
244 "gazelle:proto disable",
245 ],
246 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200247 "k8s.io/apiextensions-apiserver": {
248 "directives": [
249 "gazelle:proto disable",
250 ],
251 },
252 "k8s.io/apiserver": {
253 "directives": [
254 "gazelle:proto disable",
255 ],
256 },
Lorenz Brun95190ce2025-01-28 13:07:00 +0000257 "k8s.io/client-go": {
Jan Schär36f3b6d2025-05-20 09:05:12 +0000258 "patches": [
259 "//third_party/com_k8s_io_client_go:version-stamp.patch",
260 ],
Lorenz Brun95190ce2025-01-28 13:07:00 +0000261 "pre_patches": [
Tim Windelschmidt71718ba2025-02-07 00:04:28 +0100262 "//third_party/com_k8s_io_client_go:k8s-fix-websocket-custom-dialer.patch",
Lorenz Brun95190ce2025-01-28 13:07:00 +0000263 ],
264 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200265 "k8s.io/cri-api": {
266 "directives": [
267 "gazelle:proto disable",
268 ],
269 },
270 "k8s.io/kube-aggregator": {
271 "directives": [
272 "gazelle:proto disable",
273 ],
274 },
275 "k8s.io/kubelet": {
276 "directives": [
277 "gazelle:proto disable",
278 ],
279 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100280 "//third_party/com_k8s_io_kubelet:kubelet-fix-path.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200281 ],
282 },
283 "k8s.io/kubernetes": {
284 "directives": [
285 "gazelle:proto disable",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200286 ],
287 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100288 "//third_party/com_k8s_io_kubernetes:k8s-native-metrics.patch",
289 "//third_party/com_k8s_io_kubernetes:k8s-removed-block-device-pseudo-locks.patch",
290 "//third_party/com_k8s_io_kubernetes:k8s-add-pause-build-file.patch",
291 "//third_party/com_k8s_io_kubernetes:k8s-reserve-metropolis-ports-import.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200292 ],
293 "pre_patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100294 "//third_party/com_k8s_io_kubernetes:k8s-drop-legacy-log-path.patch",
295 "//third_party/com_k8s_io_kubernetes:k8s-reserve-metropolis-ports.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200296 ],
297 },
298 "k8s.io/metrics": {
299 "directives": [
300 "gazelle:proto disable",
301 ],
302 },
303 "google.golang.org/genproto/googleapis/api": {
304 "directives": [
305 "gazelle:proto disable_global",
306 ],
307 },
308 "google.golang.org/genproto/googleapis/rpc": {
309 "directives": [
310 "gazelle:proto disable_global",
311 ],
312 },
313 "google.golang.org/grpc": {
314 "directives": [
315 "gazelle:proto disable",
316 ],
317 },
Tim Windelschmidtd4817492025-06-16 15:03:12 +0200318 "github.com/containers/ocicrypt": {
319 "directives": [
320 "gazelle:proto disable",
321 ],
322 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200323 "github.com/pingcap/tidb/parser": {
324 "build_file_generation": "on",
325 },
326 "golang.org/x/mod": {
327 "build_extra_args": [
328 "-go_naming_convention=import_alias",
329 "-go_naming_convention_external=import_alias",
330 ],
331 },
332 "golang.org/x/sync": {
333 "build_extra_args": [
334 "-go_naming_convention=import_alias",
335 "-go_naming_convention_external=import_alias",
336 ],
337 },
338 "github.com/containernetworking/cni": {
339 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100340 "//third_party/com_github_containernetworking_cni:cni-fix-cachepath.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200341 ],
342 },
Lorenz Brun0dca6c92025-01-28 15:04:13 +0100343 "github.com/containernetworking/plugins": {
344 "patches": [
Tim Windelschmidt71718ba2025-02-07 00:04:28 +0100345 "//third_party/com_github_containernetworking_plugins:cniplugins-add-linkgroup.patch",
Lorenz Brun0dca6c92025-01-28 15:04:13 +0100346 ],
347 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200348 "github.com/corverroos/commentwrap": {
349 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100350 "//third_party/com_github_corverroos_commentwrap:commentwrap-uri.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200351 ],
352 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200353 "github.com/pganalyze/pg_query_go/v4": {
354 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100355 "//third_party/com_github_pganalyze_pg_query_go_v4:pganalyze-add-cdeps.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200356 ],
357 },
358 "github.com/sbezverk/nfproxy": {
359 "pre_patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100360 "//third_party/com_github_sbezverk_nfproxy:nfproxy-adapt-to-k8s-1.28.patch",
361 "//third_party/com_github_sbezverk_nfproxy:nfproxy-adapt-to-nftables-0.2.patch",
Lorenz Brun11bf3d32025-01-07 17:49:27 +0100362 ],
363 },
364 "github.com/google/nftables": {
365 "pre_patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100366 "//third_party/com_github_google_nftables:nftables-dynamic-exprs.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200367 ],
368 },
369 "k8s.io/kubectl": {
370 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100371 "//third_party/com_k8s_io_kubectl:kubectl-fix-embed.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200372 ],
373 },
Tim Windelschmidtd4817492025-06-16 15:03:12 +0200374 "sigs.k8s.io/apiserver-network-proxy/konnectivity-client": {
375 "directives": [
376 "gazelle:proto disable",
377 ],
378 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200379 "github.com/seccomp/libseccomp-golang": {
380 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100381 "//third_party/com_github_seccomp_libseccomp_golang:libseccomp.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200382 ],
383 },
384 "github.com/vishvananda/netlink": {
385 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100386 "//third_party/com_github_vishvananda_netlink:netlink-psample.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200387 ],
388 },
389 "gvisor.dev/gvisor": {
390 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100391 "//third_party/com_gvisor_dev_gvisor:gvisor-fix-syslog.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200392 ],
393 "pre_patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100394 "//third_party/com_gvisor_dev_gvisor:gvisor-containerd-compat.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200395 ],
396 },
397 "go.etcd.io/etcd/tests/v3": {
398 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100399 "//third_party/com_go_etcd_io_etcd_tests_v3:etcd-integration-logging.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200400 ],
401 },
Lorenz Brun5c520622025-01-14 14:14:52 +0100402 "k8s.io/component-base": {
403 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100404 "//third_party/com_k8s_io_component_base:k8s-fix-metrics-data-race.patch",
Jan Schär36f3b6d2025-05-20 09:05:12 +0000405 "//third_party/com_k8s_io_component_base:version-stamp.patch",
Lorenz Brun5c520622025-01-14 14:14:52 +0100406 ],
407 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200408 "k8s.io/mount-utils": {
409 "pre_patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100410 "//third_party/com_k8s_io_mount_utils:k8s-native-mounter.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200411 ],
412 },
413 "golang.org/x/tools": {
414 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100415 "//third_party/com_golang_org_x_tools:goimports-group-merging.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200416 ],
417 },
418}
419
420# MODULE.bazel doesn't support loops, but since we have lots of overrides,
421# this is the more readable approach.
422[
423 [
424 go_deps.gazelle_override(
425 build_extra_args = overrides.get("build_extra_args") or [],
426 build_file_generation = overrides.get("build_file_generation") or "auto",
427 directives = overrides.get("directives") or [],
428 path = path,
429 ),
430 go_deps.module_override(
431 patch_strip = 1,
432 patches = overrides.get("patches") or [],
433 path = path,
434 pre_patches = overrides.get("pre_patches") or [],
435 ),
436 ]
437 for path, overrides in OVERRIDES.items()
438]