blob: eb4aea5469f6fe8cc9e1a3407014ac8466d9fdb3 [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",
Serge Bazanski0d9e1252024-09-03 12:16:47 +020027 "com_github_gdamore_tcell_v2",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020028 "com_github_go_delve_delve",
29 "com_github_golang_migrate_migrate_v4",
Tim Windelschmidt7c0bd0b2025-01-10 04:15:37 +010030 "com_github_golangci_gofmt",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020031 "com_github_google_cel_go",
32 "com_github_google_certificate_transparency_go",
33 "com_github_google_go_cmp",
34 "com_github_google_go_tpm",
35 "com_github_google_go_tpm_tools",
36 "com_github_google_gopacket",
37 "com_github_google_nftables",
38 "com_github_google_uuid",
39 "com_github_iancoleman_strcase",
40 "com_github_improbable_eng_grpc_web",
41 "com_github_insomniacslk_dhcp",
42 "com_github_joho_godotenv",
43 "com_github_kballard_go_shellquote",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020044 "com_github_klauspost_compress",
45 "com_github_lib_pq",
Jan Schär17ad63f2025-02-27 14:43:56 +010046 "com_github_mattfenwick_cyclonus",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020047 "com_github_mattn_go_shellwords",
48 "com_github_mdlayher_arp",
49 "com_github_mdlayher_ethernet",
50 "com_github_mdlayher_ethtool",
51 "com_github_mdlayher_genetlink",
52 "com_github_mdlayher_kobject",
53 "com_github_mdlayher_netlink",
54 "com_github_mdlayher_packet",
Jan Schär4a180222024-07-29 16:32:54 +020055 "com_github_miekg_dns",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020056 "com_github_mitchellh_go_wordwrap",
57 "com_github_opencontainers_go_digest",
Jan Schärb48174d2025-04-14 10:13:02 +000058 "com_github_opencontainers_image_spec",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020059 "com_github_opencontainers_runc",
60 "com_github_packethost_packngo",
61 "com_github_pkg_errors",
62 "com_github_pkg_sftp",
63 "com_github_prometheus_client_golang",
64 "com_github_prometheus_node_exporter",
Serge Bazanski0d9e1252024-09-03 12:16:47 +020065 "com_github_rivo_uniseg",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020066 "com_github_rmohr_bazeldnf",
67 "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",
89 "io_k8s_klog_v2",
90 "io_k8s_kubectl",
91 "io_k8s_kubelet",
92 "io_k8s_kubernetes",
93 "io_k8s_pod_security_admission",
Jan Schära48bd3c2024-07-29 17:22:18 +020094 "io_k8s_utils",
Lorenz Brun52700ae2025-01-28 15:07:08 +010095 "org_dolansoft_git_dolansoft_k8s_nft_npc",
Lorenz Brun227c5cb2025-01-09 21:39:55 +010096 "org_go4_netipx",
Tim Windelschmidt5178dd72024-12-04 04:38:45 +010097 "org_golang_google_api",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020098 "org_golang_google_genproto_googleapis_api",
99 "org_golang_google_grpc",
100 "org_golang_google_protobuf",
101 "org_golang_x_crypto",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200102 "org_golang_x_net",
103 "org_golang_x_sync",
104 "org_golang_x_sys",
Tim Windelschmidt7a1b27d2024-02-22 23:54:58 +0100105 "org_golang_x_term",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200106 "org_golang_x_text",
107 "org_golang_x_time",
108 "org_golang_x_tools",
109 "org_uber_go_multierr",
110 "org_uber_go_zap",
111)
112
113# Instead of defining a gazelle/module override for every dependency, we have a
114# big dict containing all of them.
115OVERRIDES = {
Lorenz Brun0ec0c532024-08-29 12:39:47 +0000116 "github.com/containerd/containerd/v2": {
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200117 "directives": [
118 "gazelle:proto disable",
Tim Windelschmidt25e0d8f2024-12-02 23:46:24 +0100119 "gazelle:build_tags no_aufs,no_btrfs,no_devmapper,no_zfs",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200120 ],
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200121 },
122 "github.com/containerd/cgroups/v3": {
123 "directives": [
124 "gazelle:proto disable",
125 ],
126 },
127 "github.com/containerd/nri": {
128 "directives": [
129 "gazelle:proto disable",
130 ],
131 },
132 "github.com/gogo/protobuf": {
133 "directives": [
134 "gazelle:proto disable",
135 ],
136 },
137 "github.com/google/cel-go": {
138 "build_file_generation": "on",
139 "directives": [
140 "gazelle:go_naming_convention go_default_library",
141 ],
142 },
143 "github.com/google/go-tpm-tools": {
144 "directives": [
145 "gazelle:proto file",
146 ],
147 "pre_patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100148 "//third_party/com_github_google_go_tpm_tools:go-tpm-tools-fix-proto-paths.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200149 ],
150 },
151 "github.com/googleapis/gax-go/v2": {
152 "directives": [
153 "gazelle:proto disable",
154 ],
155 },
156 "github.com/Microsoft/hcsshim": {
157 "directives": [
158 "gazelle:proto disable",
159 ],
160 },
161 "github.com/opencontainers/runc": {
162 "directives": [
163 "gazelle:build_tags seccomp",
Jan Schär7c38e782025-04-29 09:23:37 +0000164 # Make @com_github_opencontainers_runc//:runc_lib visible
165 "gazelle:go_visibility //visibility:public",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200166 ],
167 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100168 "//third_party/com_github_opencontainers_runc:runc-add-cdeps.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200169 ],
170 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200171 "github.com/google/cadvisor": {
172 "directives": [
173 "gazelle:proto disable_global",
174 ],
Lorenz Brun837cb8e2024-12-23 13:52:56 +0100175 "pre_patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100176 "//third_party/com_github_google_cadvisor:cadvisor-errdefs1.patch",
Lorenz Brun837cb8e2024-12-23 13:52:56 +0100177 ],
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200178 },
179 "github.com/sqlc-dev/sqlc": {
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200180 "directives": [
181 "gazelle:proto disable",
Tim Windelschmidt25e0d8f2024-12-02 23:46:24 +0100182 "gazelle:build_tags nowasm",
Jan Schär7c38e782025-04-29 09:23:37 +0000183 # Make @com_github_sqlc_dev_sqlc//cmd/sqlc:sqlc_lib visible
184 "gazelle:go_visibility //visibility:public",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200185 ],
186 },
187 "github.com/containerd/ttrpc": {
188 "directives": [
189 "gazelle:proto disable",
190 ],
191 },
192 "go.etcd.io/etcd/api/v3": {
193 "directives": [
194 "gazelle:proto disable",
195 ],
196 },
197 "go.etcd.io/etcd/raft/v3": {
198 "directives": [
199 "gazelle:proto disable",
200 ],
201 },
202 "go.etcd.io/etcd/server/v3": {
203 "directives": [
204 "gazelle:proto disable",
205 ],
206 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100207 "//third_party/com_go_etcd_io_etcd_server_v3:etcd-fix-embed-close.patch",
208 "//third_party/com_go_etcd_io_etcd_server_v3:etcd-fix-islearner-panic.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200209 ],
210 },
211 "github.com/grpc-ecosystem/grpc-gateway": {
212 # Force generation of new build files for this package, required due to changes in how gazelle handles @go_googleapis.
213 "build_file_generation": "on",
214 "directives": [
215 "gazelle:exclude **/**_test.go",
216 "gazelle:exclude examples",
217 "gazelle:resolve go github.com/grpc-ecosystem/grpc-gateway/internal //internal",
218 "gazelle:resolve go github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options //protoc-gen-swagger/options",
219 "gazelle:proto disable_global",
220 ],
221 },
222 "k8s.io/api": {
223 "directives": [
224 "gazelle:proto disable",
225 ],
226 },
227 "k8s.io/apiextensions-apiserver": {
228 "directives": [
229 "gazelle:proto disable",
230 ],
231 },
232 "k8s.io/apiserver": {
233 "directives": [
234 "gazelle:proto disable",
235 ],
236 },
Lorenz Brun95190ce2025-01-28 13:07:00 +0000237 "k8s.io/client-go": {
238 "pre_patches": [
Tim Windelschmidt71718ba2025-02-07 00:04:28 +0100239 "//third_party/com_k8s_io_client_go:k8s-fix-websocket-custom-dialer.patch",
Lorenz Brun95190ce2025-01-28 13:07:00 +0000240 ],
241 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200242 "k8s.io/cri-api": {
243 "directives": [
244 "gazelle:proto disable",
245 ],
246 },
247 "k8s.io/kube-aggregator": {
248 "directives": [
249 "gazelle:proto disable",
250 ],
251 },
252 "k8s.io/kubelet": {
253 "directives": [
254 "gazelle:proto disable",
255 ],
256 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100257 "//third_party/com_k8s_io_kubelet:kubelet-fix-path.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200258 ],
259 },
260 "k8s.io/kubernetes": {
261 "directives": [
262 "gazelle:proto disable",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200263 ],
264 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100265 "//third_party/com_k8s_io_kubernetes:k8s-native-metrics.patch",
266 "//third_party/com_k8s_io_kubernetes:k8s-removed-block-device-pseudo-locks.patch",
267 "//third_party/com_k8s_io_kubernetes:k8s-add-pause-build-file.patch",
268 "//third_party/com_k8s_io_kubernetes:k8s-reserve-metropolis-ports-import.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200269 ],
270 "pre_patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100271 "//third_party/com_k8s_io_kubernetes:k8s-drop-legacy-log-path.patch",
272 "//third_party/com_k8s_io_kubernetes:k8s-reserve-metropolis-ports.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200273 ],
274 },
275 "k8s.io/metrics": {
276 "directives": [
277 "gazelle:proto disable",
278 ],
279 },
280 "google.golang.org/genproto/googleapis/api": {
281 "directives": [
282 "gazelle:proto disable_global",
283 ],
284 },
285 "google.golang.org/genproto/googleapis/rpc": {
286 "directives": [
287 "gazelle:proto disable_global",
288 ],
289 },
290 "google.golang.org/grpc": {
291 "directives": [
292 "gazelle:proto disable",
293 ],
294 },
295 "github.com/pingcap/tidb/parser": {
296 "build_file_generation": "on",
297 },
298 "golang.org/x/mod": {
299 "build_extra_args": [
300 "-go_naming_convention=import_alias",
301 "-go_naming_convention_external=import_alias",
302 ],
303 },
304 "golang.org/x/sync": {
305 "build_extra_args": [
306 "-go_naming_convention=import_alias",
307 "-go_naming_convention_external=import_alias",
308 ],
309 },
310 "github.com/containernetworking/cni": {
311 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100312 "//third_party/com_github_containernetworking_cni:cni-fix-cachepath.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200313 ],
314 },
Lorenz Brun0dca6c92025-01-28 15:04:13 +0100315 "github.com/containernetworking/plugins": {
316 "patches": [
Tim Windelschmidt71718ba2025-02-07 00:04:28 +0100317 "//third_party/com_github_containernetworking_plugins:cniplugins-add-linkgroup.patch",
Lorenz Brun0dca6c92025-01-28 15:04:13 +0100318 ],
319 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200320 "github.com/corverroos/commentwrap": {
321 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100322 "//third_party/com_github_corverroos_commentwrap:commentwrap-uri.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200323 ],
324 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200325 "github.com/pganalyze/pg_query_go/v4": {
326 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100327 "//third_party/com_github_pganalyze_pg_query_go_v4:pganalyze-add-cdeps.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200328 ],
329 },
330 "github.com/sbezverk/nfproxy": {
331 "pre_patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100332 "//third_party/com_github_sbezverk_nfproxy:nfproxy-adapt-to-k8s-1.28.patch",
333 "//third_party/com_github_sbezverk_nfproxy:nfproxy-adapt-to-nftables-0.2.patch",
Lorenz Brun11bf3d32025-01-07 17:49:27 +0100334 ],
335 },
336 "github.com/google/nftables": {
337 "pre_patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100338 "//third_party/com_github_google_nftables:nftables-dynamic-exprs.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200339 ],
340 },
341 "k8s.io/kubectl": {
342 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100343 "//third_party/com_k8s_io_kubectl:kubectl-fix-embed.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200344 ],
345 },
346 "github.com/seccomp/libseccomp-golang": {
347 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100348 "//third_party/com_github_seccomp_libseccomp_golang:libseccomp.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200349 ],
350 },
351 "github.com/vishvananda/netlink": {
352 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100353 "//third_party/com_github_vishvananda_netlink:netlink-psample.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200354 ],
355 },
356 "gvisor.dev/gvisor": {
357 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100358 "//third_party/com_gvisor_dev_gvisor:gvisor-fix-syslog.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200359 ],
360 "pre_patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100361 "//third_party/com_gvisor_dev_gvisor:gvisor-containerd-compat.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200362 ],
363 },
364 "go.etcd.io/etcd/tests/v3": {
365 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100366 "//third_party/com_go_etcd_io_etcd_tests_v3:etcd-integration-logging.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200367 ],
368 },
Lorenz Brun5c520622025-01-14 14:14:52 +0100369 "k8s.io/component-base": {
370 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100371 "//third_party/com_k8s_io_component_base:k8s-fix-metrics-data-race.patch",
Lorenz Brun5c520622025-01-14 14:14:52 +0100372 ],
373 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200374 "k8s.io/mount-utils": {
375 "pre_patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100376 "//third_party/com_k8s_io_mount_utils:k8s-native-mounter.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200377 ],
378 },
379 "golang.org/x/tools": {
380 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100381 "//third_party/com_golang_org_x_tools:goimports-group-merging.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200382 ],
383 },
384}
385
386# MODULE.bazel doesn't support loops, but since we have lots of overrides,
387# this is the more readable approach.
388[
389 [
390 go_deps.gazelle_override(
391 build_extra_args = overrides.get("build_extra_args") or [],
392 build_file_generation = overrides.get("build_file_generation") or "auto",
393 directives = overrides.get("directives") or [],
394 path = path,
395 ),
396 go_deps.module_override(
397 patch_strip = 1,
398 patches = overrides.get("patches") or [],
399 path = path,
400 pre_patches = overrides.get("pre_patches") or [],
401 ),
402 ]
403 for path, overrides in OVERRIDES.items()
404]