blob: 1756ef77a2517439511031a99ed88ed7454d49fe [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",
20 "com_github_cockroachdb_cockroach_go_v2",
21 "com_github_container_storage_interface_spec",
Lorenz Brun0ec0c532024-08-29 12:39:47 +000022 "com_github_containerd_containerd_v2",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020023 "com_github_containernetworking_plugins",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020024 "com_github_coreos_go_semver",
25 "com_github_corverroos_commentwrap",
26 "com_github_diskfs_go_diskfs",
27 "com_github_docker_distribution",
Serge Bazanski0d9e1252024-09-03 12:16:47 +020028 "com_github_gdamore_tcell_v2",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020029 "com_github_go_delve_delve",
30 "com_github_golang_migrate_migrate_v4",
Tim Windelschmidt7c0bd0b2025-01-10 04:15:37 +010031 "com_github_golangci_gofmt",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020032 "com_github_google_cel_go",
33 "com_github_google_certificate_transparency_go",
34 "com_github_google_go_cmp",
35 "com_github_google_go_tpm",
36 "com_github_google_go_tpm_tools",
37 "com_github_google_gopacket",
38 "com_github_google_nftables",
39 "com_github_google_uuid",
40 "com_github_iancoleman_strcase",
41 "com_github_improbable_eng_grpc_web",
42 "com_github_insomniacslk_dhcp",
43 "com_github_joho_godotenv",
44 "com_github_kballard_go_shellquote",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020045 "com_github_klauspost_compress",
46 "com_github_lib_pq",
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",
54 "com_github_mdlayher_netlink",
55 "com_github_mdlayher_packet",
Jan Schär4a180222024-07-29 16:32:54 +020056 "com_github_miekg_dns",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020057 "com_github_mitchellh_go_wordwrap",
58 "com_github_opencontainers_go_digest",
Jan Schärb48174d2025-04-14 10:13:02 +000059 "com_github_opencontainers_image_spec",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020060 "com_github_opencontainers_runc",
61 "com_github_packethost_packngo",
62 "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_rmohr_bazeldnf",
68 "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",
90 "io_k8s_klog_v2",
91 "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 Windelschmidte5e90a82024-07-17 23:46:22 +0200122 },
123 "github.com/containerd/cgroups/v3": {
124 "directives": [
125 "gazelle:proto disable",
126 ],
127 },
128 "github.com/containerd/nri": {
129 "directives": [
130 "gazelle:proto disable",
131 ],
132 },
133 "github.com/gogo/protobuf": {
134 "directives": [
135 "gazelle:proto disable",
136 ],
137 },
138 "github.com/google/cel-go": {
139 "build_file_generation": "on",
140 "directives": [
141 "gazelle:go_naming_convention go_default_library",
142 ],
143 },
144 "github.com/google/go-tpm-tools": {
145 "directives": [
146 "gazelle:proto file",
147 ],
148 "pre_patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100149 "//third_party/com_github_google_go_tpm_tools:go-tpm-tools-fix-proto-paths.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200150 ],
151 },
152 "github.com/googleapis/gax-go/v2": {
153 "directives": [
154 "gazelle:proto disable",
155 ],
156 },
157 "github.com/Microsoft/hcsshim": {
158 "directives": [
159 "gazelle:proto disable",
160 ],
161 },
162 "github.com/opencontainers/runc": {
163 "directives": [
164 "gazelle:build_tags seccomp",
165 ],
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",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200182 ],
183 },
184 "github.com/containerd/ttrpc": {
185 "directives": [
186 "gazelle:proto disable",
187 ],
188 },
189 "go.etcd.io/etcd/api/v3": {
190 "directives": [
191 "gazelle:proto disable",
192 ],
193 },
194 "go.etcd.io/etcd/raft/v3": {
195 "directives": [
196 "gazelle:proto disable",
197 ],
198 },
199 "go.etcd.io/etcd/server/v3": {
200 "directives": [
201 "gazelle:proto disable",
202 ],
203 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100204 "//third_party/com_go_etcd_io_etcd_server_v3:etcd-fix-embed-close.patch",
205 "//third_party/com_go_etcd_io_etcd_server_v3:etcd-fix-islearner-panic.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200206 ],
207 },
208 "github.com/grpc-ecosystem/grpc-gateway": {
209 # Force generation of new build files for this package, required due to changes in how gazelle handles @go_googleapis.
210 "build_file_generation": "on",
211 "directives": [
212 "gazelle:exclude **/**_test.go",
213 "gazelle:exclude examples",
214 "gazelle:resolve go github.com/grpc-ecosystem/grpc-gateway/internal //internal",
215 "gazelle:resolve go github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options //protoc-gen-swagger/options",
216 "gazelle:proto disable_global",
217 ],
218 },
219 "k8s.io/api": {
220 "directives": [
221 "gazelle:proto disable",
222 ],
223 },
224 "k8s.io/apiextensions-apiserver": {
225 "directives": [
226 "gazelle:proto disable",
227 ],
228 },
229 "k8s.io/apiserver": {
230 "directives": [
231 "gazelle:proto disable",
232 ],
233 },
Lorenz Brun95190ce2025-01-28 13:07:00 +0000234 "k8s.io/client-go": {
235 "pre_patches": [
Tim Windelschmidt71718ba2025-02-07 00:04:28 +0100236 "//third_party/com_k8s_io_client_go:k8s-fix-websocket-custom-dialer.patch",
Lorenz Brun95190ce2025-01-28 13:07:00 +0000237 ],
238 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200239 "k8s.io/cri-api": {
240 "directives": [
241 "gazelle:proto disable",
242 ],
243 },
244 "k8s.io/kube-aggregator": {
245 "directives": [
246 "gazelle:proto disable",
247 ],
248 },
249 "k8s.io/kubelet": {
250 "directives": [
251 "gazelle:proto disable",
252 ],
253 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100254 "//third_party/com_k8s_io_kubelet:kubelet-fix-path.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200255 ],
256 },
257 "k8s.io/kubernetes": {
258 "directives": [
259 "gazelle:proto disable",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200260 ],
261 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100262 "//third_party/com_k8s_io_kubernetes:k8s-native-metrics.patch",
263 "//third_party/com_k8s_io_kubernetes:k8s-removed-block-device-pseudo-locks.patch",
264 "//third_party/com_k8s_io_kubernetes:k8s-add-pause-build-file.patch",
265 "//third_party/com_k8s_io_kubernetes:k8s-reserve-metropolis-ports-import.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200266 ],
267 "pre_patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100268 "//third_party/com_k8s_io_kubernetes:k8s-drop-legacy-log-path.patch",
269 "//third_party/com_k8s_io_kubernetes:k8s-reserve-metropolis-ports.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200270 ],
271 },
272 "k8s.io/metrics": {
273 "directives": [
274 "gazelle:proto disable",
275 ],
276 },
277 "google.golang.org/genproto/googleapis/api": {
278 "directives": [
279 "gazelle:proto disable_global",
280 ],
281 },
282 "google.golang.org/genproto/googleapis/rpc": {
283 "directives": [
284 "gazelle:proto disable_global",
285 ],
286 },
287 "google.golang.org/grpc": {
288 "directives": [
289 "gazelle:proto disable",
290 ],
291 },
292 "github.com/pingcap/tidb/parser": {
293 "build_file_generation": "on",
294 },
295 "golang.org/x/mod": {
296 "build_extra_args": [
297 "-go_naming_convention=import_alias",
298 "-go_naming_convention_external=import_alias",
299 ],
300 },
301 "golang.org/x/sync": {
302 "build_extra_args": [
303 "-go_naming_convention=import_alias",
304 "-go_naming_convention_external=import_alias",
305 ],
306 },
307 "github.com/containernetworking/cni": {
308 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100309 "//third_party/com_github_containernetworking_cni:cni-fix-cachepath.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200310 ],
311 },
Lorenz Brun0dca6c92025-01-28 15:04:13 +0100312 "github.com/containernetworking/plugins": {
313 "patches": [
Tim Windelschmidt71718ba2025-02-07 00:04:28 +0100314 "//third_party/com_github_containernetworking_plugins:cniplugins-add-linkgroup.patch",
Lorenz Brun0dca6c92025-01-28 15:04:13 +0100315 ],
316 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200317 "github.com/corverroos/commentwrap": {
318 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100319 "//third_party/com_github_corverroos_commentwrap:commentwrap-uri.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200320 ],
321 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200322 "github.com/pganalyze/pg_query_go/v4": {
323 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100324 "//third_party/com_github_pganalyze_pg_query_go_v4:pganalyze-add-cdeps.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200325 ],
326 },
327 "github.com/sbezverk/nfproxy": {
328 "pre_patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100329 "//third_party/com_github_sbezverk_nfproxy:nfproxy-adapt-to-k8s-1.28.patch",
330 "//third_party/com_github_sbezverk_nfproxy:nfproxy-adapt-to-nftables-0.2.patch",
Lorenz Brun11bf3d32025-01-07 17:49:27 +0100331 ],
332 },
333 "github.com/google/nftables": {
334 "pre_patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100335 "//third_party/com_github_google_nftables:nftables-dynamic-exprs.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200336 ],
337 },
338 "k8s.io/kubectl": {
339 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100340 "//third_party/com_k8s_io_kubectl:kubectl-fix-embed.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200341 ],
342 },
343 "github.com/seccomp/libseccomp-golang": {
344 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100345 "//third_party/com_github_seccomp_libseccomp_golang:libseccomp.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200346 ],
347 },
348 "github.com/vishvananda/netlink": {
349 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100350 "//third_party/com_github_vishvananda_netlink:netlink-psample.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200351 ],
352 },
353 "gvisor.dev/gvisor": {
354 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100355 "//third_party/com_gvisor_dev_gvisor:gvisor-fix-syslog.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200356 ],
357 "pre_patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100358 "//third_party/com_gvisor_dev_gvisor:gvisor-containerd-compat.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200359 ],
360 },
361 "go.etcd.io/etcd/tests/v3": {
362 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100363 "//third_party/com_go_etcd_io_etcd_tests_v3:etcd-integration-logging.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200364 ],
365 },
Lorenz Brun5c520622025-01-14 14:14:52 +0100366 "k8s.io/component-base": {
367 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100368 "//third_party/com_k8s_io_component_base:k8s-fix-metrics-data-race.patch",
Lorenz Brun5c520622025-01-14 14:14:52 +0100369 ],
370 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200371 "k8s.io/mount-utils": {
372 "pre_patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100373 "//third_party/com_k8s_io_mount_utils:k8s-native-mounter.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200374 ],
375 },
376 "golang.org/x/tools": {
377 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100378 "//third_party/com_golang_org_x_tools:goimports-group-merging.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200379 ],
380 },
381}
382
383# MODULE.bazel doesn't support loops, but since we have lots of overrides,
384# this is the more readable approach.
385[
386 [
387 go_deps.gazelle_override(
388 build_extra_args = overrides.get("build_extra_args") or [],
389 build_file_generation = overrides.get("build_file_generation") or "auto",
390 directives = overrides.get("directives") or [],
391 path = path,
392 ),
393 go_deps.module_override(
394 patch_strip = 1,
395 patches = overrides.get("patches") or [],
396 path = path,
397 pre_patches = overrides.get("pre_patches") or [],
398 ),
399 ]
400 for path, overrides in OVERRIDES.items()
401]