blob: 471c8b985476e772539e42a62d24c6884fd52eef [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",
Tim Windelschmidte4264a32025-07-23 07:16:22 +020015 "monogon",
Tim Windelschmidt8fd51cd2025-06-29 02:20:17 +020016)
17
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020018# All *direct* Go dependencies of the module have to be listed explicitly.
19# This list can be automatically updated by running "bazel mod tidy".
20use_repo(
21 go_deps,
22 "co_honnef_go_tools",
23 "com_4d63_gocheckcompilerdirectives",
24 "com_github_adrg_xdg",
25 "com_github_cavaliergopher_cpio",
26 "com_github_cenkalti_backoff_v4",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020027 "com_github_container_storage_interface_spec",
Lorenz Brun0ec0c532024-08-29 12:39:47 +000028 "com_github_containerd_containerd_v2",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020029 "com_github_containernetworking_plugins",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020030 "com_github_coreos_go_semver",
31 "com_github_corverroos_commentwrap",
32 "com_github_diskfs_go_diskfs",
Serge Bazanski0d9e1252024-09-03 12:16:47 +020033 "com_github_gdamore_tcell_v2",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020034 "com_github_go_delve_delve",
Tim Windelschmidt7c0bd0b2025-01-10 04:15:37 +010035 "com_github_golangci_gofmt",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020036 "com_github_google_cel_go",
37 "com_github_google_certificate_transparency_go",
38 "com_github_google_go_cmp",
39 "com_github_google_go_tpm",
40 "com_github_google_go_tpm_tools",
41 "com_github_google_gopacket",
42 "com_github_google_nftables",
43 "com_github_google_uuid",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020044 "com_github_insomniacslk_dhcp",
45 "com_github_joho_godotenv",
46 "com_github_kballard_go_shellquote",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020047 "com_github_klauspost_compress",
Jan Schär17ad63f2025-02-27 14:43:56 +010048 "com_github_mattfenwick_cyclonus",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020049 "com_github_mattn_go_shellwords",
50 "com_github_mdlayher_arp",
51 "com_github_mdlayher_ethernet",
52 "com_github_mdlayher_ethtool",
53 "com_github_mdlayher_genetlink",
54 "com_github_mdlayher_kobject",
Lorenz Brune08c1602025-06-17 19:19:33 +020055 "com_github_mdlayher_lldp",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020056 "com_github_mdlayher_netlink",
57 "com_github_mdlayher_packet",
Jan Schär4a180222024-07-29 16:32:54 +020058 "com_github_miekg_dns",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020059 "com_github_mitchellh_go_wordwrap",
60 "com_github_opencontainers_go_digest",
Jan Schärb48174d2025-04-14 10:13:02 +000061 "com_github_opencontainers_image_spec",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020062 "com_github_opencontainers_runc",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020063 "com_github_pkg_errors",
64 "com_github_pkg_sftp",
65 "com_github_prometheus_client_golang",
66 "com_github_prometheus_node_exporter",
Serge Bazanski0d9e1252024-09-03 12:16:47 +020067 "com_github_rivo_uniseg",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020068 "com_github_sbezverk_nfproxy",
Tim Windelschmidt7a1b27d2024-02-22 23:54:58 +010069 "com_github_schollz_progressbar_v3",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020070 "com_github_spf13_cobra",
71 "com_github_spf13_pflag",
72 "com_github_sqlc_dev_sqlc",
73 "com_github_stretchr_testify",
74 "com_github_vishvananda_netlink",
75 "com_github_yalue_native_endian",
76 "com_google_cloud_go_storage",
77 "com_zx2c4_golang_wireguard_wgctrl",
78 "dev_gvisor_gvisor",
79 "io_etcd_go_etcd_api_v3",
80 "io_etcd_go_etcd_client_pkg_v3",
81 "io_etcd_go_etcd_client_v3",
82 "io_etcd_go_etcd_server_v3",
83 "io_etcd_go_etcd_tests_v3",
84 "io_k8s_api",
85 "io_k8s_apimachinery",
86 "io_k8s_apiserver",
87 "io_k8s_cli_runtime",
88 "io_k8s_client_go",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020089 "io_k8s_component_base",
Tim Windelschmidtcfbc9032025-07-15 14:18:45 +020090 "io_k8s_klog_v2",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020091 "io_k8s_kubectl",
92 "io_k8s_kubelet",
93 "io_k8s_kubernetes",
94 "io_k8s_pod_security_admission",
Jan Schära48bd3c2024-07-29 17:22:18 +020095 "io_k8s_utils",
Lorenz Brun52700ae2025-01-28 15:07:08 +010096 "org_dolansoft_git_dolansoft_k8s_nft_npc",
Lorenz Brun227c5cb2025-01-09 21:39:55 +010097 "org_go4_netipx",
Tim Windelschmidt5178dd72024-12-04 04:38:45 +010098 "org_golang_google_api",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020099 "org_golang_google_genproto_googleapis_api",
100 "org_golang_google_grpc",
101 "org_golang_google_protobuf",
102 "org_golang_x_crypto",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200103 "org_golang_x_net",
104 "org_golang_x_sync",
105 "org_golang_x_sys",
Tim Windelschmidt7a1b27d2024-02-22 23:54:58 +0100106 "org_golang_x_term",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200107 "org_golang_x_text",
108 "org_golang_x_time",
109 "org_golang_x_tools",
110 "org_uber_go_multierr",
111 "org_uber_go_zap",
112)
113
114# Instead of defining a gazelle/module override for every dependency, we have a
115# big dict containing all of them.
116OVERRIDES = {
Lorenz Brun0ec0c532024-08-29 12:39:47 +0000117 "github.com/containerd/containerd/v2": {
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200118 "directives": [
119 "gazelle:proto disable",
Tim Windelschmidt25e0d8f2024-12-02 23:46:24 +0100120 "gazelle:build_tags no_aufs,no_btrfs,no_devmapper,no_zfs",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200121 ],
Tim Windelschmidtcfbc9032025-07-15 14:18:45 +0200122 "pre_patches": [
123 "//third_party/com_github_containerd_containerd_v2:add-unimplemented-functions.patch",
124 ],
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200125 },
126 "github.com/containerd/cgroups/v3": {
127 "directives": [
128 "gazelle:proto disable",
129 ],
130 },
131 "github.com/containerd/nri": {
132 "directives": [
133 "gazelle:proto disable",
134 ],
135 },
136 "github.com/gogo/protobuf": {
137 "directives": [
138 "gazelle:proto disable",
139 ],
140 },
141 "github.com/google/cel-go": {
142 "build_file_generation": "on",
143 "directives": [
144 "gazelle:go_naming_convention go_default_library",
145 ],
146 },
147 "github.com/google/go-tpm-tools": {
148 "directives": [
149 "gazelle:proto file",
150 ],
151 "pre_patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100152 "//third_party/com_github_google_go_tpm_tools:go-tpm-tools-fix-proto-paths.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200153 ],
154 },
155 "github.com/googleapis/gax-go/v2": {
156 "directives": [
157 "gazelle:proto disable",
158 ],
159 },
160 "github.com/Microsoft/hcsshim": {
161 "directives": [
162 "gazelle:proto disable",
163 ],
164 },
165 "github.com/opencontainers/runc": {
166 "directives": [
167 "gazelle:build_tags seccomp",
Jan Schär7c38e782025-04-29 09:23:37 +0000168 # Make @com_github_opencontainers_runc//:runc_lib visible
169 "gazelle:go_visibility //visibility:public",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200170 ],
171 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100172 "//third_party/com_github_opencontainers_runc:runc-add-cdeps.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200173 ],
174 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200175 "github.com/google/cadvisor": {
176 "directives": [
177 "gazelle:proto disable_global",
178 ],
179 },
180 "github.com/sqlc-dev/sqlc": {
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200181 "directives": [
182 "gazelle:proto disable",
Tim Windelschmidt25e0d8f2024-12-02 23:46:24 +0100183 "gazelle:build_tags nowasm",
Jan Schär7c38e782025-04-29 09:23:37 +0000184 # Make @com_github_sqlc_dev_sqlc//cmd/sqlc:sqlc_lib visible
185 "gazelle:go_visibility //visibility:public",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200186 ],
187 },
Tim Windelschmidtd4817492025-06-16 15:03:12 +0200188 "github.com/bytecodealliance/wasmtime-go/v14": {
Tim Windelschmidt5d357d82025-07-10 18:47:15 +0200189 # wasmtime brings its own BUILD files and for some reason,
190 # Bazel regenerates them in the nixos/nix container but not on
191 # NixOS. We disable replacing the existing directives to fix this.
192 "build_file_generation": "off",
Tim Windelschmidtd4817492025-06-16 15:03:12 +0200193 "directives": [
194 "gazelle:go_naming_convention go_default_library",
195 ],
196 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200197 "github.com/containerd/ttrpc": {
198 "directives": [
199 "gazelle:proto disable",
200 ],
201 },
202 "go.etcd.io/etcd/api/v3": {
203 "directives": [
204 "gazelle:proto disable",
205 ],
206 },
Lorenz Brun62229cf2025-07-07 12:47:31 +0200207 "go.etcd.io/raft/v3": {
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200208 "directives": [
209 "gazelle:proto disable",
210 ],
211 },
212 "go.etcd.io/etcd/server/v3": {
213 "directives": [
214 "gazelle:proto disable",
215 ],
216 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100217 "//third_party/com_go_etcd_io_etcd_server_v3:etcd-fix-embed-close.patch",
Lorenz Brun62229cf2025-07-07 12:47:31 +0200218 "//third_party/com_go_etcd_io_etcd_server_v3:fix-def-warn-threshold.patch",
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100219 "//third_party/com_go_etcd_io_etcd_server_v3:etcd-fix-islearner-panic.patch",
Lorenz Brun62229cf2025-07-07 12:47:31 +0200220 "//third_party/com_go_etcd_io_etcd_server_v3:shutdown-safety.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200221 ],
222 },
Lorenz Brun62229cf2025-07-07 12:47:31 +0200223 "github.com/grpc-ecosystem/grpc-gateway/v2": {
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200224 # Force generation of new build files for this package, required due to changes in how gazelle handles @go_googleapis.
225 "build_file_generation": "on",
226 "directives": [
227 "gazelle:exclude **/**_test.go",
228 "gazelle:exclude examples",
229 "gazelle:resolve go github.com/grpc-ecosystem/grpc-gateway/internal //internal",
230 "gazelle:resolve go github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options //protoc-gen-swagger/options",
231 "gazelle:proto disable_global",
232 ],
233 },
234 "k8s.io/api": {
235 "directives": [
236 "gazelle:proto disable",
237 ],
238 },
Tim Windelschmidtd4817492025-06-16 15:03:12 +0200239 "k8s.io/kms": {
240 "directives": [
241 "gazelle:proto disable",
242 ],
243 },
244 "k8s.io/externaljwt": {
245 "directives": [
246 "gazelle:proto disable",
247 ],
248 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200249 "k8s.io/apiextensions-apiserver": {
250 "directives": [
251 "gazelle:proto disable",
252 ],
253 },
254 "k8s.io/apiserver": {
255 "directives": [
256 "gazelle:proto disable",
257 ],
258 },
Lorenz Brun95190ce2025-01-28 13:07:00 +0000259 "k8s.io/client-go": {
Jan Schär36f3b6d2025-05-20 09:05:12 +0000260 "patches": [
261 "//third_party/com_k8s_io_client_go:version-stamp.patch",
262 ],
Lorenz Brun95190ce2025-01-28 13:07:00 +0000263 "pre_patches": [
Tim Windelschmidt71718ba2025-02-07 00:04:28 +0100264 "//third_party/com_k8s_io_client_go:k8s-fix-websocket-custom-dialer.patch",
Lorenz Brun95190ce2025-01-28 13:07:00 +0000265 ],
266 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200267 "k8s.io/cri-api": {
268 "directives": [
269 "gazelle:proto disable",
270 ],
271 },
272 "k8s.io/kube-aggregator": {
273 "directives": [
274 "gazelle:proto disable",
275 ],
276 },
277 "k8s.io/kubelet": {
278 "directives": [
279 "gazelle:proto disable",
280 ],
281 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100282 "//third_party/com_k8s_io_kubelet:kubelet-fix-path.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200283 ],
284 },
285 "k8s.io/kubernetes": {
286 "directives": [
287 "gazelle:proto disable",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200288 ],
289 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100290 "//third_party/com_k8s_io_kubernetes:k8s-native-metrics.patch",
291 "//third_party/com_k8s_io_kubernetes:k8s-removed-block-device-pseudo-locks.patch",
292 "//third_party/com_k8s_io_kubernetes:k8s-add-pause-build-file.patch",
293 "//third_party/com_k8s_io_kubernetes:k8s-reserve-metropolis-ports-import.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200294 ],
295 "pre_patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100296 "//third_party/com_k8s_io_kubernetes:k8s-drop-legacy-log-path.patch",
297 "//third_party/com_k8s_io_kubernetes:k8s-reserve-metropolis-ports.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200298 ],
299 },
300 "k8s.io/metrics": {
301 "directives": [
302 "gazelle:proto disable",
303 ],
304 },
305 "google.golang.org/genproto/googleapis/api": {
306 "directives": [
307 "gazelle:proto disable_global",
308 ],
309 },
310 "google.golang.org/genproto/googleapis/rpc": {
311 "directives": [
312 "gazelle:proto disable_global",
313 ],
314 },
315 "google.golang.org/grpc": {
316 "directives": [
317 "gazelle:proto disable",
318 ],
319 },
Tim Windelschmidtd4817492025-06-16 15:03:12 +0200320 "github.com/containers/ocicrypt": {
321 "directives": [
322 "gazelle:proto disable",
323 ],
324 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200325 "github.com/pingcap/tidb/parser": {
326 "build_file_generation": "on",
327 },
328 "golang.org/x/mod": {
329 "build_extra_args": [
330 "-go_naming_convention=import_alias",
331 "-go_naming_convention_external=import_alias",
332 ],
333 },
334 "golang.org/x/sync": {
335 "build_extra_args": [
336 "-go_naming_convention=import_alias",
337 "-go_naming_convention_external=import_alias",
338 ],
339 },
340 "github.com/containernetworking/cni": {
341 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100342 "//third_party/com_github_containernetworking_cni:cni-fix-cachepath.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200343 ],
344 },
Lorenz Brun0dca6c92025-01-28 15:04:13 +0100345 "github.com/containernetworking/plugins": {
346 "patches": [
Tim Windelschmidt71718ba2025-02-07 00:04:28 +0100347 "//third_party/com_github_containernetworking_plugins:cniplugins-add-linkgroup.patch",
Lorenz Brun0dca6c92025-01-28 15:04:13 +0100348 ],
349 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200350 "github.com/corverroos/commentwrap": {
351 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100352 "//third_party/com_github_corverroos_commentwrap:commentwrap-uri.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200353 ],
354 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200355 "github.com/pganalyze/pg_query_go/v4": {
356 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100357 "//third_party/com_github_pganalyze_pg_query_go_v4:pganalyze-add-cdeps.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200358 ],
359 },
360 "github.com/sbezverk/nfproxy": {
361 "pre_patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100362 "//third_party/com_github_sbezverk_nfproxy:nfproxy-adapt-to-k8s-1.28.patch",
363 "//third_party/com_github_sbezverk_nfproxy:nfproxy-adapt-to-nftables-0.2.patch",
Lorenz Brun11bf3d32025-01-07 17:49:27 +0100364 ],
365 },
366 "github.com/google/nftables": {
367 "pre_patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100368 "//third_party/com_github_google_nftables:nftables-dynamic-exprs.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200369 ],
370 },
371 "k8s.io/kubectl": {
372 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100373 "//third_party/com_k8s_io_kubectl:kubectl-fix-embed.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200374 ],
375 },
Tim Windelschmidtd4817492025-06-16 15:03:12 +0200376 "sigs.k8s.io/apiserver-network-proxy/konnectivity-client": {
377 "directives": [
378 "gazelle:proto disable",
379 ],
380 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200381 "github.com/seccomp/libseccomp-golang": {
382 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100383 "//third_party/com_github_seccomp_libseccomp_golang:libseccomp.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200384 ],
385 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200386 "gvisor.dev/gvisor": {
387 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100388 "//third_party/com_gvisor_dev_gvisor:gvisor-fix-syslog.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200389 ],
390 "pre_patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100391 "//third_party/com_gvisor_dev_gvisor:gvisor-containerd-compat.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200392 ],
393 },
394 "go.etcd.io/etcd/tests/v3": {
395 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100396 "//third_party/com_go_etcd_io_etcd_tests_v3:etcd-integration-logging.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200397 ],
398 },
Lorenz Brun5c520622025-01-14 14:14:52 +0100399 "k8s.io/component-base": {
400 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100401 "//third_party/com_k8s_io_component_base:k8s-fix-metrics-data-race.patch",
Jan Schär36f3b6d2025-05-20 09:05:12 +0000402 "//third_party/com_k8s_io_component_base:version-stamp.patch",
Lorenz Brun5c520622025-01-14 14:14:52 +0100403 ],
404 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200405 "k8s.io/mount-utils": {
406 "pre_patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100407 "//third_party/com_k8s_io_mount_utils:k8s-native-mounter.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200408 ],
409 },
410 "golang.org/x/tools": {
411 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100412 "//third_party/com_golang_org_x_tools:goimports-group-merging.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200413 ],
414 },
415}
416
417# MODULE.bazel doesn't support loops, but since we have lots of overrides,
418# this is the more readable approach.
419[
420 [
421 go_deps.gazelle_override(
422 build_extra_args = overrides.get("build_extra_args") or [],
423 build_file_generation = overrides.get("build_file_generation") or "auto",
424 directives = overrides.get("directives") or [],
425 path = path,
426 ),
427 go_deps.module_override(
428 patch_strip = 1,
429 patches = overrides.get("patches") or [],
430 path = path,
431 pre_patches = overrides.get("pre_patches") or [],
432 ),
433 ]
434 for path, overrides in OVERRIDES.items()
435]