blob: e5de3951d3e349bae5376ed9597aa5f33512c946 [file] [log] [blame]
Tim Windelschmidte5e90a82024-07-17 23:46:22 +02001go_sdk = use_extension("@io_bazel_rules_go//go:extensions.bzl", "go_sdk")
2go_sdk.download(version = "1.22.5")
3go_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",
19 "com_github_containerd_containerd",
20 "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",
61 "com_github_pseudomuto_protoc_gen_doc",
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",
65 "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",
84 "io_k8s_code_generator",
85 "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",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020092 "net_starlark_go",
93 "org_golang_google_genproto_googleapis_api",
94 "org_golang_google_grpc",
95 "org_golang_google_protobuf",
96 "org_golang_x_crypto",
97 "org_golang_x_mod",
98 "org_golang_x_net",
99 "org_golang_x_sync",
100 "org_golang_x_sys",
101 "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 = {
111 "github.com/containerd/cgroups": {
112 "directives": [
113 "gazelle:proto disable",
114 ],
115 },
116 "github.com/containerd/containerd": {
117 "directives": [
118 "gazelle:proto disable",
119 "gazelle:build_tags no_btrfs,no_zfs",
120 ],
121 "pre_patches": [
122 # We build with newer CRI API definitions.
123 "//third_party/go/patches:containerd-grpc-inherit-unimplemented.patch",
124 ],
125 },
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": [
152 "//third_party/go/patches:go-tpm-tools-fix-proto-paths.patch",
153 ],
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",
168 ],
169 "patches": [
170 "//third_party/go/patches:runc-add-cdeps.patch",
171 ],
172 },
173 "github.com/prometheus/node_exporter": {
174 "directives": [
175 "gazelle:build_tags nobtrfs,nozfs,notapestats,norapl",
176 ],
177 },
178 "github.com/pseudomuto/protoc-gen-doc": {
179 "directives": [
180 "gazelle:resolve go github.com/mwitkow/go-proto-validators @com_github_mwitkow_go_proto_validators//:validators_golang",
181 ],
182 "pre_patches": [
183 "//third_party/go/patches:protoc-gen-doc-no-gogo.patch",
184 ],
185 },
186 "github.com/pseudomuto/protokit": {
187 "directives": [
188 "gazelle:proto disable",
189 ],
190 },
191 "github.com/google/cadvisor": {
192 "directives": [
193 "gazelle:proto disable_global",
194 ],
195 },
196 "github.com/sqlc-dev/sqlc": {
197 "build_extra_args": [
198 "-exclude=internal/ext/wasm/wasm.go",
199 ],
200 "directives": [
201 "gazelle:proto disable",
202 ],
203 },
204 "github.com/containerd/ttrpc": {
205 "directives": [
206 "gazelle:proto disable",
207 ],
208 },
209 "go.etcd.io/etcd/api/v3": {
210 "directives": [
211 "gazelle:proto disable",
212 ],
213 },
214 "go.etcd.io/etcd/raft/v3": {
215 "directives": [
216 "gazelle:proto disable",
217 ],
218 },
219 "go.etcd.io/etcd/server/v3": {
220 "directives": [
221 "gazelle:proto disable",
222 ],
223 "patches": [
224 "//third_party/go/patches:etcd-fix-embed-close.patch",
225 ],
226 },
227 "github.com/grpc-ecosystem/grpc-gateway": {
228 # Force generation of new build files for this package, required due to changes in how gazelle handles @go_googleapis.
229 "build_file_generation": "on",
230 "directives": [
231 "gazelle:exclude **/**_test.go",
232 "gazelle:exclude examples",
233 "gazelle:resolve go github.com/grpc-ecosystem/grpc-gateway/internal //internal",
234 "gazelle:resolve go github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options //protoc-gen-swagger/options",
235 "gazelle:proto disable_global",
236 ],
237 },
238 "k8s.io/api": {
239 "directives": [
240 "gazelle:proto disable",
241 ],
242 },
243 "k8s.io/apiextensions-apiserver": {
244 "directives": [
245 "gazelle:proto disable",
246 ],
247 },
248 "k8s.io/apiserver": {
249 "directives": [
250 "gazelle:proto disable",
251 ],
252 },
253 "k8s.io/cri-api": {
254 "directives": [
255 "gazelle:proto disable",
256 ],
257 },
258 "k8s.io/kube-aggregator": {
259 "directives": [
260 "gazelle:proto disable",
261 ],
262 },
263 "k8s.io/kubelet": {
264 "directives": [
265 "gazelle:proto disable",
266 ],
267 "patches": [
268 "//third_party/go/patches:kubelet-fix-path.patch",
269 ],
270 },
271 "k8s.io/kubernetes": {
272 "directives": [
273 "gazelle:proto disable",
274 "gazelle:build_tags providerless,dockerless",
275 ],
276 "patches": [
277 "//third_party/go/patches:k8s-native-metrics.patch",
278 "//third_party/go/patches:k8s-removed-block-device-pseudo-locks.patch",
279 "//third_party/go/patches:k8s-add-pause-build-file.patch",
280 "//third_party/go/patches:k8s-reserve-metropolis-ports-import.patch",
281 ],
282 "pre_patches": [
283 "//third_party/go/patches:k8s-drop-legacy-log-path.patch",
284 "//third_party/go/patches:k8s-reserve-metropolis-ports.patch",
285 ],
286 },
287 "k8s.io/metrics": {
288 "directives": [
289 "gazelle:proto disable",
290 ],
291 },
292 "google.golang.org/genproto/googleapis/api": {
293 "directives": [
294 "gazelle:proto disable_global",
295 ],
296 },
297 "google.golang.org/genproto/googleapis/rpc": {
298 "directives": [
299 "gazelle:proto disable_global",
300 ],
301 },
302 "google.golang.org/grpc": {
303 "directives": [
304 "gazelle:proto disable",
305 ],
306 },
307 "github.com/pingcap/tidb/parser": {
308 "build_file_generation": "on",
309 },
310 "golang.org/x/mod": {
311 "build_extra_args": [
312 "-go_naming_convention=import_alias",
313 "-go_naming_convention_external=import_alias",
314 ],
315 },
316 "golang.org/x/sync": {
317 "build_extra_args": [
318 "-go_naming_convention=import_alias",
319 "-go_naming_convention_external=import_alias",
320 ],
321 },
322 "github.com/containernetworking/cni": {
323 "patches": [
324 "//third_party/go/patches:cni-fix-cachepath.patch",
325 ],
326 },
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200327 "github.com/corverroos/commentwrap": {
328 "patches": [
329 "//third_party/go/patches:commentwrap-uri.patch",
330 ],
331 },
332 "github.com/go-delve/delve": {
333 "patches": [
334 "//third_party/go/patches:delve-fix-cgo.patch",
335 ],
336 },
337 "github.com/pganalyze/pg_query_go/v4": {
338 "patches": [
339 "//third_party/go/patches:pganalyze-add-cdeps.patch",
340 ],
341 },
342 "github.com/sbezverk/nfproxy": {
343 "pre_patches": [
344 "//third_party/go/patches:nfproxy-adapt-to-k8s-1.28.patch",
345 ],
346 },
347 "k8s.io/kubectl": {
348 "patches": [
349 "//third_party/go/patches:kubectl-fix-embed.patch",
350 ],
351 },
352 "github.com/seccomp/libseccomp-golang": {
353 "patches": [
354 "//third_party/go/patches:libseccomp.patch",
355 ],
356 },
357 "github.com/vishvananda/netlink": {
358 "patches": [
359 "//third_party/go/patches:netlink-permhwaddr.patch",
360 "//third_party/go/patches:netlink-use-rtm_setlink.patch",
361 ],
362 },
363 "gvisor.dev/gvisor": {
364 "patches": [
365 "//third_party/go/patches:gvisor-fix-syslog.patch",
366 # Gazelle doesn't understand conditional build files.
367 # https://github.com/bazelbuild/bazel-gazelle/issues/1262
368 "//third_party/go/patches:gvisor-fix-gazelle-debug-builds.patch",
369 ],
370 "pre_patches": [
371 "//third_party/go/patches:gvisor-containerd-compat.patch",
372 # Modified patch for the go branch.
373 # Upstream issue https://github.com/google/gvisor/issues/9039
374 # Upstream patch https://github.com/google/gvisor/commit/62afa160fe8ad17302d43f7c6016061de57c7f4d
375 "//third_party/go/patches:gvisor-fix-debug-builds.patch",
Lorenz Brun732a8842024-08-26 23:25:37 +0200376 "//third_party/go/patches:gvisor-unix-0.20.patch",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +0200377 ],
378 },
379 "go.etcd.io/etcd/tests/v3": {
380 "patches": [
381 "//third_party/go/patches:etcd-integration-logging.patch",
382 ],
383 },
384 "k8s.io/mount-utils": {
385 "pre_patches": [
386 "//third_party/go/patches:k8s-native-mounter.patch",
387 ],
388 },
389 "golang.org/x/tools": {
390 "patches": [
391 "//third_party/go/patches:goimports-group-merging.patch",
392 ],
393 },
394}
395
396# MODULE.bazel doesn't support loops, but since we have lots of overrides,
397# this is the more readable approach.
398[
399 [
400 go_deps.gazelle_override(
401 build_extra_args = overrides.get("build_extra_args") or [],
402 build_file_generation = overrides.get("build_file_generation") or "auto",
403 directives = overrides.get("directives") or [],
404 path = path,
405 ),
406 go_deps.module_override(
407 patch_strip = 1,
408 patches = overrides.get("patches") or [],
409 path = path,
410 pre_patches = overrides.get("pre_patches") or [],
411 ),
412 ]
413 for path, overrides in OVERRIDES.items()
414]