blob: 5afba0fbc76831fd7ab071dd1854dbc22773288d [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 Windelschmidte5e90a82024-07-17 23:46:22 +02003go_sdk.nogo(nogo = "//build/analysis:nogo")
4
Tim Windelschmidted9a5832025-02-04 03:02:45 +01005go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
Tim Windelschmidte5e90a82024-07-17 23:46:22 +02006go_deps.from_file(go_mod = "//:go.mod")
7
8# All *direct* Go dependencies of the module have to be listed explicitly.
9# This list can be automatically updated by running "bazel mod tidy".
10use_repo(
11 go_deps,
12 "co_honnef_go_tools",
13 "com_4d63_gocheckcompilerdirectives",
14 "com_github_adrg_xdg",
15 "com_github_cavaliergopher_cpio",
16 "com_github_cenkalti_backoff_v4",
17 "com_github_cockroachdb_cockroach_go_v2",
18 "com_github_container_storage_interface_spec",
Lorenz Brun0ec0c532024-08-29 12:39:47 +000019 "com_github_containerd_containerd_v2",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020020 "com_github_containernetworking_plugins",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020021 "com_github_coreos_go_semver",
22 "com_github_corverroos_commentwrap",
23 "com_github_diskfs_go_diskfs",
24 "com_github_docker_distribution",
Serge Bazanski0d9e1252024-09-03 12:16:47 +020025 "com_github_gdamore_tcell_v2",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020026 "com_github_go_delve_delve",
27 "com_github_golang_migrate_migrate_v4",
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",
37 "com_github_iancoleman_strcase",
38 "com_github_improbable_eng_grpc_web",
39 "com_github_insomniacslk_dhcp",
40 "com_github_joho_godotenv",
41 "com_github_kballard_go_shellquote",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020042 "com_github_klauspost_compress",
43 "com_github_lib_pq",
Jan Schär17ad63f2025-02-27 14:43:56 +010044 "com_github_mattfenwick_cyclonus",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020045 "com_github_mattn_go_shellwords",
46 "com_github_mdlayher_arp",
47 "com_github_mdlayher_ethernet",
48 "com_github_mdlayher_ethtool",
49 "com_github_mdlayher_genetlink",
50 "com_github_mdlayher_kobject",
51 "com_github_mdlayher_netlink",
52 "com_github_mdlayher_packet",
Jan Schär4a180222024-07-29 16:32:54 +020053 "com_github_miekg_dns",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020054 "com_github_mitchellh_go_wordwrap",
55 "com_github_opencontainers_go_digest",
56 "com_github_opencontainers_runc",
57 "com_github_packethost_packngo",
58 "com_github_pkg_errors",
59 "com_github_pkg_sftp",
60 "com_github_prometheus_client_golang",
61 "com_github_prometheus_node_exporter",
Serge Bazanski0d9e1252024-09-03 12:16:47 +020062 "com_github_rivo_uniseg",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020063 "com_github_rmohr_bazeldnf",
64 "com_github_sbezverk_nfproxy",
Tim Windelschmidt7a1b27d2024-02-22 23:54:58 +010065 "com_github_schollz_progressbar_v3",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020066 "com_github_spf13_cobra",
67 "com_github_spf13_pflag",
68 "com_github_sqlc_dev_sqlc",
69 "com_github_stretchr_testify",
70 "com_github_vishvananda_netlink",
71 "com_github_yalue_native_endian",
72 "com_google_cloud_go_storage",
73 "com_zx2c4_golang_wireguard_wgctrl",
74 "dev_gvisor_gvisor",
75 "io_etcd_go_etcd_api_v3",
76 "io_etcd_go_etcd_client_pkg_v3",
77 "io_etcd_go_etcd_client_v3",
78 "io_etcd_go_etcd_server_v3",
79 "io_etcd_go_etcd_tests_v3",
80 "io_k8s_api",
81 "io_k8s_apimachinery",
82 "io_k8s_apiserver",
83 "io_k8s_cli_runtime",
84 "io_k8s_client_go",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020085 "io_k8s_component_base",
86 "io_k8s_klog_v2",
87 "io_k8s_kubectl",
88 "io_k8s_kubelet",
89 "io_k8s_kubernetes",
90 "io_k8s_pod_security_admission",
Jan Schära48bd3c2024-07-29 17:22:18 +020091 "io_k8s_utils",
Lorenz Brun52700ae2025-01-28 15:07:08 +010092 "org_dolansoft_git_dolansoft_k8s_nft_npc",
Lorenz Brun227c5cb2025-01-09 21:39:55 +010093 "org_go4_netipx",
Tim Windelschmidt5178dd72024-12-04 04:38:45 +010094 "org_golang_google_api",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020095 "org_golang_google_genproto_googleapis_api",
96 "org_golang_google_grpc",
97 "org_golang_google_protobuf",
98 "org_golang_x_crypto",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020099 "org_golang_x_net",
100 "org_golang_x_sync",
101 "org_golang_x_sys",
Tim Windelschmidt7a1b27d2024-02-22 23:54:58 +0100102 "org_golang_x_term",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200103 "org_golang_x_text",
104 "org_golang_x_time",
105 "org_golang_x_tools",
106 "org_uber_go_multierr",
107 "org_uber_go_zap",
108)
109
110# Instead of defining a gazelle/module override for every dependency, we have a
111# big dict containing all of them.
112OVERRIDES = {
Lorenz Brun0ec0c532024-08-29 12:39:47 +0000113 "github.com/containerd/containerd/v2": {
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200114 "directives": [
115 "gazelle:proto disable",
Tim Windelschmidt25e0d8f2024-12-02 23:46:24 +0100116 "gazelle:build_tags no_aufs,no_btrfs,no_devmapper,no_zfs",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200117 ],
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200118 },
119 "github.com/containerd/cgroups/v3": {
120 "directives": [
121 "gazelle:proto disable",
122 ],
123 },
124 "github.com/containerd/nri": {
125 "directives": [
126 "gazelle:proto disable",
127 ],
128 },
129 "github.com/gogo/protobuf": {
130 "directives": [
131 "gazelle:proto disable",
132 ],
133 },
134 "github.com/google/cel-go": {
135 "build_file_generation": "on",
136 "directives": [
137 "gazelle:go_naming_convention go_default_library",
138 ],
139 },
140 "github.com/google/go-tpm-tools": {
141 "directives": [
142 "gazelle:proto file",
143 ],
144 "pre_patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100145 "//third_party/com_github_google_go_tpm_tools:go-tpm-tools-fix-proto-paths.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200146 ],
147 },
148 "github.com/googleapis/gax-go/v2": {
149 "directives": [
150 "gazelle:proto disable",
151 ],
152 },
153 "github.com/Microsoft/hcsshim": {
154 "directives": [
155 "gazelle:proto disable",
156 ],
157 },
158 "github.com/opencontainers/runc": {
159 "directives": [
160 "gazelle:build_tags seccomp",
161 ],
162 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100163 "//third_party/com_github_opencontainers_runc:runc-add-cdeps.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200164 ],
165 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200166 "github.com/google/cadvisor": {
167 "directives": [
168 "gazelle:proto disable_global",
169 ],
Lorenz Brun837cb8e2024-12-23 13:52:56 +0100170 "pre_patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100171 "//third_party/com_github_google_cadvisor:cadvisor-errdefs1.patch",
Lorenz Brun837cb8e2024-12-23 13:52:56 +0100172 ],
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200173 },
174 "github.com/sqlc-dev/sqlc": {
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200175 "directives": [
176 "gazelle:proto disable",
Tim Windelschmidt25e0d8f2024-12-02 23:46:24 +0100177 "gazelle:build_tags nowasm",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200178 ],
179 },
180 "github.com/containerd/ttrpc": {
181 "directives": [
182 "gazelle:proto disable",
183 ],
184 },
185 "go.etcd.io/etcd/api/v3": {
186 "directives": [
187 "gazelle:proto disable",
188 ],
189 },
190 "go.etcd.io/etcd/raft/v3": {
191 "directives": [
192 "gazelle:proto disable",
193 ],
194 },
195 "go.etcd.io/etcd/server/v3": {
196 "directives": [
197 "gazelle:proto disable",
198 ],
199 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100200 "//third_party/com_go_etcd_io_etcd_server_v3:etcd-fix-embed-close.patch",
201 "//third_party/com_go_etcd_io_etcd_server_v3:etcd-fix-islearner-panic.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200202 ],
203 },
204 "github.com/grpc-ecosystem/grpc-gateway": {
205 # Force generation of new build files for this package, required due to changes in how gazelle handles @go_googleapis.
206 "build_file_generation": "on",
207 "directives": [
208 "gazelle:exclude **/**_test.go",
209 "gazelle:exclude examples",
210 "gazelle:resolve go github.com/grpc-ecosystem/grpc-gateway/internal //internal",
211 "gazelle:resolve go github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options //protoc-gen-swagger/options",
212 "gazelle:proto disable_global",
213 ],
214 },
215 "k8s.io/api": {
216 "directives": [
217 "gazelle:proto disable",
218 ],
219 },
220 "k8s.io/apiextensions-apiserver": {
221 "directives": [
222 "gazelle:proto disable",
223 ],
224 },
225 "k8s.io/apiserver": {
226 "directives": [
227 "gazelle:proto disable",
228 ],
229 },
Lorenz Brun95190ce2025-01-28 13:07:00 +0000230 "k8s.io/client-go": {
231 "pre_patches": [
Tim Windelschmidt71718ba2025-02-07 00:04:28 +0100232 "//third_party/com_k8s_io_client_go:k8s-fix-websocket-custom-dialer.patch",
Lorenz Brun95190ce2025-01-28 13:07:00 +0000233 ],
234 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200235 "k8s.io/cri-api": {
236 "directives": [
237 "gazelle:proto disable",
238 ],
239 },
240 "k8s.io/kube-aggregator": {
241 "directives": [
242 "gazelle:proto disable",
243 ],
244 },
245 "k8s.io/kubelet": {
246 "directives": [
247 "gazelle:proto disable",
248 ],
249 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100250 "//third_party/com_k8s_io_kubelet:kubelet-fix-path.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200251 ],
252 },
253 "k8s.io/kubernetes": {
254 "directives": [
255 "gazelle:proto disable",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200256 ],
257 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100258 "//third_party/com_k8s_io_kubernetes:k8s-native-metrics.patch",
259 "//third_party/com_k8s_io_kubernetes:k8s-removed-block-device-pseudo-locks.patch",
260 "//third_party/com_k8s_io_kubernetes:k8s-add-pause-build-file.patch",
261 "//third_party/com_k8s_io_kubernetes:k8s-reserve-metropolis-ports-import.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200262 ],
263 "pre_patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100264 "//third_party/com_k8s_io_kubernetes:k8s-drop-legacy-log-path.patch",
265 "//third_party/com_k8s_io_kubernetes:k8s-reserve-metropolis-ports.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200266 ],
267 },
268 "k8s.io/metrics": {
269 "directives": [
270 "gazelle:proto disable",
271 ],
272 },
273 "google.golang.org/genproto/googleapis/api": {
274 "directives": [
275 "gazelle:proto disable_global",
276 ],
277 },
278 "google.golang.org/genproto/googleapis/rpc": {
279 "directives": [
280 "gazelle:proto disable_global",
281 ],
282 },
283 "google.golang.org/grpc": {
284 "directives": [
285 "gazelle:proto disable",
286 ],
287 },
288 "github.com/pingcap/tidb/parser": {
289 "build_file_generation": "on",
290 },
291 "golang.org/x/mod": {
292 "build_extra_args": [
293 "-go_naming_convention=import_alias",
294 "-go_naming_convention_external=import_alias",
295 ],
296 },
297 "golang.org/x/sync": {
298 "build_extra_args": [
299 "-go_naming_convention=import_alias",
300 "-go_naming_convention_external=import_alias",
301 ],
302 },
303 "github.com/containernetworking/cni": {
304 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100305 "//third_party/com_github_containernetworking_cni:cni-fix-cachepath.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200306 ],
307 },
Lorenz Brun0dca6c92025-01-28 15:04:13 +0100308 "github.com/containernetworking/plugins": {
309 "patches": [
Tim Windelschmidt71718ba2025-02-07 00:04:28 +0100310 "//third_party/com_github_containernetworking_plugins:cniplugins-add-linkgroup.patch",
Lorenz Brun0dca6c92025-01-28 15:04:13 +0100311 ],
312 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200313 "github.com/corverroos/commentwrap": {
314 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100315 "//third_party/com_github_corverroos_commentwrap:commentwrap-uri.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200316 ],
317 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200318 "github.com/pganalyze/pg_query_go/v4": {
319 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100320 "//third_party/com_github_pganalyze_pg_query_go_v4:pganalyze-add-cdeps.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200321 ],
322 },
323 "github.com/sbezverk/nfproxy": {
324 "pre_patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100325 "//third_party/com_github_sbezverk_nfproxy:nfproxy-adapt-to-k8s-1.28.patch",
326 "//third_party/com_github_sbezverk_nfproxy:nfproxy-adapt-to-nftables-0.2.patch",
Lorenz Brun11bf3d32025-01-07 17:49:27 +0100327 ],
328 },
329 "github.com/google/nftables": {
330 "pre_patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100331 "//third_party/com_github_google_nftables:nftables-dynamic-exprs.patch",
Jan Schärec03df42025-02-27 14:30:45 +0100332 "//third_party/com_github_google_nftables:nftables-rule-handle.patch",
333 "//third_party/com_github_google_nftables:nftables-element-batching.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200334 ],
335 },
336 "k8s.io/kubectl": {
337 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100338 "//third_party/com_k8s_io_kubectl:kubectl-fix-embed.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200339 ],
340 },
341 "github.com/seccomp/libseccomp-golang": {
342 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100343 "//third_party/com_github_seccomp_libseccomp_golang:libseccomp.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200344 ],
345 },
346 "github.com/vishvananda/netlink": {
347 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100348 "//third_party/com_github_vishvananda_netlink:netlink-psample.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200349 ],
350 },
351 "gvisor.dev/gvisor": {
352 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100353 "//third_party/com_gvisor_dev_gvisor:gvisor-fix-syslog.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200354 ],
355 "pre_patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100356 "//third_party/com_gvisor_dev_gvisor:gvisor-containerd-compat.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200357 ],
358 },
359 "go.etcd.io/etcd/tests/v3": {
360 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100361 "//third_party/com_go_etcd_io_etcd_tests_v3:etcd-integration-logging.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200362 ],
363 },
Lorenz Brun5c520622025-01-14 14:14:52 +0100364 "k8s.io/component-base": {
365 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100366 "//third_party/com_k8s_io_component_base:k8s-fix-metrics-data-race.patch",
Lorenz Brun5c520622025-01-14 14:14:52 +0100367 ],
368 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200369 "k8s.io/mount-utils": {
370 "pre_patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100371 "//third_party/com_k8s_io_mount_utils:k8s-native-mounter.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200372 ],
373 },
374 "golang.org/x/tools": {
375 "patches": [
Tim Windelschmidt7887f752025-02-04 03:06:56 +0100376 "//third_party/com_golang_org_x_tools:goimports-group-merging.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200377 ],
378 },
379}
380
381# MODULE.bazel doesn't support loops, but since we have lots of overrides,
382# this is the more readable approach.
383[
384 [
385 go_deps.gazelle_override(
386 build_extra_args = overrides.get("build_extra_args") or [],
387 build_file_generation = overrides.get("build_file_generation") or "auto",
388 directives = overrides.get("directives") or [],
389 path = path,
390 ),
391 go_deps.module_override(
392 patch_strip = 1,
393 patches = overrides.get("patches") or [],
394 path = path,
395 pre_patches = overrides.get("pre_patches") or [],
396 ),
397 ]
398 for path, overrides in OVERRIDES.items()
399]