blob: 1a9285fd3451df1e43cbc7ea81e8e4f7e440c45a [file] [log] [blame]
Tim Windelschmidte5e90a82024-07-17 23:46:22 +02001go_sdk = use_extension("@io_bazel_rules_go//go:extensions.bzl", "go_sdk")
Tim Windelschmidt677de972024-09-25 05:30:04 +02002go_sdk.download(version = "1.23.1")
Tim Windelschmidte5e90a82024-07-17 23:46:22 +02003go_sdk.nogo(nogo = "//build/analysis:nogo")
4
5go_deps = use_extension("@bazel_gazelle//:extensions.bzl", "go_deps")
6go_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",
28 "com_github_google_cel_go",
29 "com_github_google_certificate_transparency_go",
30 "com_github_google_go_cmp",
31 "com_github_google_go_tpm",
32 "com_github_google_go_tpm_tools",
33 "com_github_google_gopacket",
34 "com_github_google_nftables",
35 "com_github_google_uuid",
36 "com_github_iancoleman_strcase",
37 "com_github_improbable_eng_grpc_web",
38 "com_github_insomniacslk_dhcp",
39 "com_github_joho_godotenv",
40 "com_github_kballard_go_shellquote",
41 "com_github_kevinburke_go_bindata",
42 "com_github_klauspost_compress",
43 "com_github_lib_pq",
44 "com_github_mattn_go_shellwords",
45 "com_github_mdlayher_arp",
46 "com_github_mdlayher_ethernet",
47 "com_github_mdlayher_ethtool",
48 "com_github_mdlayher_genetlink",
49 "com_github_mdlayher_kobject",
50 "com_github_mdlayher_netlink",
51 "com_github_mdlayher_packet",
Jan Schär4a180222024-07-29 16:32:54 +020052 "com_github_miekg_dns",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020053 "com_github_mitchellh_go_wordwrap",
54 "com_github_opencontainers_go_digest",
55 "com_github_opencontainers_runc",
56 "com_github_packethost_packngo",
57 "com_github_pkg_errors",
58 "com_github_pkg_sftp",
59 "com_github_prometheus_client_golang",
60 "com_github_prometheus_node_exporter",
Serge Bazanski0d9e1252024-09-03 12:16:47 +020061 "com_github_rivo_uniseg",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020062 "com_github_rmohr_bazeldnf",
63 "com_github_sbezverk_nfproxy",
Tim Windelschmidt7a1b27d2024-02-22 23:54:58 +010064 "com_github_schollz_progressbar_v3",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020065 "com_github_spf13_cobra",
66 "com_github_spf13_pflag",
67 "com_github_sqlc_dev_sqlc",
68 "com_github_stretchr_testify",
69 "com_github_vishvananda_netlink",
70 "com_github_yalue_native_endian",
71 "com_google_cloud_go_storage",
72 "com_zx2c4_golang_wireguard_wgctrl",
73 "dev_gvisor_gvisor",
74 "io_etcd_go_etcd_api_v3",
75 "io_etcd_go_etcd_client_pkg_v3",
76 "io_etcd_go_etcd_client_v3",
77 "io_etcd_go_etcd_server_v3",
78 "io_etcd_go_etcd_tests_v3",
79 "io_k8s_api",
80 "io_k8s_apimachinery",
81 "io_k8s_apiserver",
82 "io_k8s_cli_runtime",
83 "io_k8s_client_go",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020084 "io_k8s_component_base",
85 "io_k8s_klog_v2",
86 "io_k8s_kubectl",
87 "io_k8s_kubelet",
88 "io_k8s_kubernetes",
89 "io_k8s_pod_security_admission",
Jan Schära48bd3c2024-07-29 17:22:18 +020090 "io_k8s_utils",
Lorenz Brun227c5cb2025-01-09 21:39:55 +010091 "org_go4_netipx",
Tim Windelschmidt5178dd72024-12-04 04:38:45 +010092 "org_golang_google_api",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020093 "org_golang_google_genproto_googleapis_api",
94 "org_golang_google_grpc",
95 "org_golang_google_protobuf",
96 "org_golang_x_crypto",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020097 "org_golang_x_net",
98 "org_golang_x_sync",
99 "org_golang_x_sys",
Tim Windelschmidt7a1b27d2024-02-22 23:54:58 +0100100 "org_golang_x_term",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200101 "org_golang_x_text",
102 "org_golang_x_time",
103 "org_golang_x_tools",
104 "org_uber_go_multierr",
105 "org_uber_go_zap",
106)
107
108# Instead of defining a gazelle/module override for every dependency, we have a
109# big dict containing all of them.
110OVERRIDES = {
Lorenz Brun0ec0c532024-08-29 12:39:47 +0000111 "github.com/containerd/containerd/v2": {
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200112 "directives": [
113 "gazelle:proto disable",
114 "gazelle:build_tags no_btrfs,no_zfs",
115 ],
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200116 },
117 "github.com/containerd/cgroups/v3": {
118 "directives": [
119 "gazelle:proto disable",
120 ],
121 },
122 "github.com/containerd/nri": {
123 "directives": [
124 "gazelle:proto disable",
125 ],
126 },
127 "github.com/gogo/protobuf": {
128 "directives": [
129 "gazelle:proto disable",
130 ],
131 },
132 "github.com/google/cel-go": {
133 "build_file_generation": "on",
134 "directives": [
135 "gazelle:go_naming_convention go_default_library",
136 ],
137 },
138 "github.com/google/go-tpm-tools": {
139 "directives": [
140 "gazelle:proto file",
141 ],
142 "pre_patches": [
143 "//third_party/go/patches:go-tpm-tools-fix-proto-paths.patch",
144 ],
145 },
146 "github.com/googleapis/gax-go/v2": {
147 "directives": [
148 "gazelle:proto disable",
149 ],
150 },
151 "github.com/Microsoft/hcsshim": {
152 "directives": [
153 "gazelle:proto disable",
154 ],
155 },
156 "github.com/opencontainers/runc": {
157 "directives": [
158 "gazelle:build_tags seccomp",
159 ],
160 "patches": [
161 "//third_party/go/patches:runc-add-cdeps.patch",
162 ],
163 },
164 "github.com/prometheus/node_exporter": {
165 "directives": [
166 "gazelle:build_tags nobtrfs,nozfs,notapestats,norapl",
167 ],
168 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200169 "github.com/google/cadvisor": {
170 "directives": [
171 "gazelle:proto disable_global",
172 ],
Lorenz Brun837cb8e2024-12-23 13:52:56 +0100173 "pre_patches": [
174 "//third_party/go/patches:cadvisor-errdefs1.patch",
175 ],
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200176 },
177 "github.com/sqlc-dev/sqlc": {
178 "build_extra_args": [
179 "-exclude=internal/ext/wasm/wasm.go",
180 ],
181 "directives": [
182 "gazelle:proto disable",
183 ],
184 },
185 "github.com/containerd/ttrpc": {
186 "directives": [
187 "gazelle:proto disable",
188 ],
189 },
190 "go.etcd.io/etcd/api/v3": {
191 "directives": [
192 "gazelle:proto disable",
193 ],
194 },
195 "go.etcd.io/etcd/raft/v3": {
196 "directives": [
197 "gazelle:proto disable",
198 ],
199 },
200 "go.etcd.io/etcd/server/v3": {
201 "directives": [
202 "gazelle:proto disable",
203 ],
204 "patches": [
205 "//third_party/go/patches:etcd-fix-embed-close.patch",
Jan Schäre551d312024-09-17 12:38:54 +0200206 "//third_party/go/patches:etcd-fix-islearner-panic.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200207 ],
208 },
209 "github.com/grpc-ecosystem/grpc-gateway": {
210 # Force generation of new build files for this package, required due to changes in how gazelle handles @go_googleapis.
211 "build_file_generation": "on",
212 "directives": [
213 "gazelle:exclude **/**_test.go",
214 "gazelle:exclude examples",
215 "gazelle:resolve go github.com/grpc-ecosystem/grpc-gateway/internal //internal",
216 "gazelle:resolve go github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options //protoc-gen-swagger/options",
217 "gazelle:proto disable_global",
218 ],
219 },
220 "k8s.io/api": {
221 "directives": [
222 "gazelle:proto disable",
223 ],
224 },
225 "k8s.io/apiextensions-apiserver": {
226 "directives": [
227 "gazelle:proto disable",
228 ],
229 },
230 "k8s.io/apiserver": {
231 "directives": [
232 "gazelle:proto disable",
233 ],
234 },
235 "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": [
250 "//third_party/go/patches:kubelet-fix-path.patch",
251 ],
252 },
253 "k8s.io/kubernetes": {
254 "directives": [
255 "gazelle:proto disable",
256 "gazelle:build_tags providerless,dockerless",
257 ],
258 "patches": [
259 "//third_party/go/patches:k8s-native-metrics.patch",
260 "//third_party/go/patches:k8s-removed-block-device-pseudo-locks.patch",
261 "//third_party/go/patches:k8s-add-pause-build-file.patch",
262 "//third_party/go/patches:k8s-reserve-metropolis-ports-import.patch",
263 ],
264 "pre_patches": [
265 "//third_party/go/patches:k8s-drop-legacy-log-path.patch",
266 "//third_party/go/patches:k8s-reserve-metropolis-ports.patch",
267 ],
268 },
269 "k8s.io/metrics": {
270 "directives": [
271 "gazelle:proto disable",
272 ],
273 },
274 "google.golang.org/genproto/googleapis/api": {
275 "directives": [
276 "gazelle:proto disable_global",
277 ],
278 },
279 "google.golang.org/genproto/googleapis/rpc": {
280 "directives": [
281 "gazelle:proto disable_global",
282 ],
283 },
284 "google.golang.org/grpc": {
285 "directives": [
286 "gazelle:proto disable",
287 ],
288 },
289 "github.com/pingcap/tidb/parser": {
290 "build_file_generation": "on",
291 },
292 "golang.org/x/mod": {
293 "build_extra_args": [
294 "-go_naming_convention=import_alias",
295 "-go_naming_convention_external=import_alias",
296 ],
297 },
298 "golang.org/x/sync": {
299 "build_extra_args": [
300 "-go_naming_convention=import_alias",
301 "-go_naming_convention_external=import_alias",
302 ],
303 },
304 "github.com/containernetworking/cni": {
305 "patches": [
306 "//third_party/go/patches:cni-fix-cachepath.patch",
307 ],
308 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200309 "github.com/corverroos/commentwrap": {
310 "patches": [
311 "//third_party/go/patches:commentwrap-uri.patch",
312 ],
313 },
314 "github.com/go-delve/delve": {
315 "patches": [
316 "//third_party/go/patches:delve-fix-cgo.patch",
317 ],
318 },
319 "github.com/pganalyze/pg_query_go/v4": {
320 "patches": [
321 "//third_party/go/patches:pganalyze-add-cdeps.patch",
322 ],
323 },
324 "github.com/sbezverk/nfproxy": {
325 "pre_patches": [
326 "//third_party/go/patches:nfproxy-adapt-to-k8s-1.28.patch",
Lorenz Brun11bf3d32025-01-07 17:49:27 +0100327 "//third_party/go/patches:nfproxy-adapt-to-nftables-0.2.patch",
328 ],
329 },
330 "github.com/google/nftables": {
331 "pre_patches": [
332 "//third_party/go/patches:nftables-bigger-buffers.patch",
333 "//third_party/go/patches:nftables-dynamic-exprs.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200334 ],
335 },
336 "k8s.io/kubectl": {
337 "patches": [
338 "//third_party/go/patches:kubectl-fix-embed.patch",
339 ],
340 },
341 "github.com/seccomp/libseccomp-golang": {
342 "patches": [
343 "//third_party/go/patches:libseccomp.patch",
344 ],
345 },
346 "github.com/vishvananda/netlink": {
347 "patches": [
Lorenz Brun153c9c12025-01-07 17:44:45 +0100348 "//third_party/go/patches:netlink-psample.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200349 ],
350 },
351 "gvisor.dev/gvisor": {
352 "patches": [
353 "//third_party/go/patches:gvisor-fix-syslog.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200354 ],
355 "pre_patches": [
356 "//third_party/go/patches:gvisor-containerd-compat.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200357 ],
358 },
359 "go.etcd.io/etcd/tests/v3": {
360 "patches": [
361 "//third_party/go/patches:etcd-integration-logging.patch",
362 ],
363 },
364 "k8s.io/mount-utils": {
365 "pre_patches": [
366 "//third_party/go/patches:k8s-native-mounter.patch",
367 ],
368 },
369 "golang.org/x/tools": {
370 "patches": [
371 "//third_party/go/patches:goimports-group-merging.patch",
372 ],
373 },
374}
375
376# MODULE.bazel doesn't support loops, but since we have lots of overrides,
377# this is the more readable approach.
378[
379 [
380 go_deps.gazelle_override(
381 build_extra_args = overrides.get("build_extra_args") or [],
382 build_file_generation = overrides.get("build_file_generation") or "auto",
383 directives = overrides.get("directives") or [],
384 path = path,
385 ),
386 go_deps.module_override(
387 patch_strip = 1,
388 patches = overrides.get("patches") or [],
389 path = path,
390 pre_patches = overrides.get("pre_patches") or [],
391 ),
392 ]
393 for path, overrides in OVERRIDES.items()
394]