blob: 7d25e8a857be14141fcb4189fee99867b5c3e6a4 [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",
21 "com_github_coredns_coredns",
22 "com_github_coreos_go_semver",
23 "com_github_corverroos_commentwrap",
24 "com_github_diskfs_go_diskfs",
25 "com_github_docker_distribution",
26 "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",
62 "com_github_rmohr_bazeldnf",
63 "com_github_sbezverk_nfproxy",
64 "com_github_spf13_cobra",
65 "com_github_spf13_pflag",
66 "com_github_sqlc_dev_sqlc",
67 "com_github_stretchr_testify",
68 "com_github_vishvananda_netlink",
69 "com_github_yalue_native_endian",
70 "com_google_cloud_go_storage",
71 "com_zx2c4_golang_wireguard_wgctrl",
72 "dev_gvisor_gvisor",
73 "io_etcd_go_etcd_api_v3",
74 "io_etcd_go_etcd_client_pkg_v3",
75 "io_etcd_go_etcd_client_v3",
76 "io_etcd_go_etcd_server_v3",
77 "io_etcd_go_etcd_tests_v3",
78 "io_k8s_api",
79 "io_k8s_apimachinery",
80 "io_k8s_apiserver",
81 "io_k8s_cli_runtime",
82 "io_k8s_client_go",
83 "io_k8s_code_generator",
84 "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",
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020091 "net_starlark_go",
92 "org_golang_google_genproto_googleapis_api",
93 "org_golang_google_grpc",
94 "org_golang_google_protobuf",
95 "org_golang_x_crypto",
96 "org_golang_x_mod",
97 "org_golang_x_net",
98 "org_golang_x_sync",
99 "org_golang_x_sys",
100 "org_golang_x_text",
101 "org_golang_x_time",
102 "org_golang_x_tools",
103 "org_uber_go_multierr",
104 "org_uber_go_zap",
105)
106
107# Instead of defining a gazelle/module override for every dependency, we have a
108# big dict containing all of them.
109OVERRIDES = {
110 "github.com/containerd/cgroups": {
111 "directives": [
112 "gazelle:proto disable",
113 ],
114 },
115 "github.com/containerd/containerd": {
116 "directives": [
117 "gazelle:proto disable",
118 "gazelle:build_tags no_btrfs,no_zfs",
119 ],
120 "pre_patches": [
121 # We build with newer CRI API definitions.
122 "//third_party/go/patches:containerd-grpc-inherit-unimplemented.patch",
123 ],
124 },
125 "github.com/containerd/cgroups/v3": {
126 "directives": [
127 "gazelle:proto disable",
128 ],
129 },
130 "github.com/containerd/nri": {
131 "directives": [
132 "gazelle:proto disable",
133 ],
134 },
135 "github.com/gogo/protobuf": {
136 "directives": [
137 "gazelle:proto disable",
138 ],
139 },
140 "github.com/google/cel-go": {
141 "build_file_generation": "on",
142 "directives": [
143 "gazelle:go_naming_convention go_default_library",
144 ],
145 },
146 "github.com/google/go-tpm-tools": {
147 "directives": [
148 "gazelle:proto file",
149 ],
150 "pre_patches": [
151 "//third_party/go/patches:go-tpm-tools-fix-proto-paths.patch",
152 ],
153 },
154 "github.com/googleapis/gax-go/v2": {
155 "directives": [
156 "gazelle:proto disable",
157 ],
158 },
159 "github.com/Microsoft/hcsshim": {
160 "directives": [
161 "gazelle:proto disable",
162 ],
163 },
164 "github.com/opencontainers/runc": {
165 "directives": [
166 "gazelle:build_tags seccomp",
167 ],
168 "patches": [
169 "//third_party/go/patches:runc-add-cdeps.patch",
170 ],
171 },
172 "github.com/prometheus/node_exporter": {
173 "directives": [
174 "gazelle:build_tags nobtrfs,nozfs,notapestats,norapl",
175 ],
176 },
177 "github.com/pseudomuto/protoc-gen-doc": {
178 "directives": [
179 "gazelle:resolve go github.com/mwitkow/go-proto-validators @com_github_mwitkow_go_proto_validators//:validators_golang",
180 ],
181 "pre_patches": [
182 "//third_party/go/patches:protoc-gen-doc-no-gogo.patch",
183 ],
184 },
185 "github.com/pseudomuto/protokit": {
186 "directives": [
187 "gazelle:proto disable",
188 ],
189 },
190 "github.com/google/cadvisor": {
191 "directives": [
192 "gazelle:proto disable_global",
193 ],
194 },
195 "github.com/sqlc-dev/sqlc": {
196 "build_extra_args": [
197 "-exclude=internal/ext/wasm/wasm.go",
198 ],
199 "directives": [
200 "gazelle:proto disable",
201 ],
202 },
203 "github.com/containerd/ttrpc": {
204 "directives": [
205 "gazelle:proto disable",
206 ],
207 },
208 "go.etcd.io/etcd/api/v3": {
209 "directives": [
210 "gazelle:proto disable",
211 ],
212 },
213 "go.etcd.io/etcd/raft/v3": {
214 "directives": [
215 "gazelle:proto disable",
216 ],
217 },
218 "go.etcd.io/etcd/server/v3": {
219 "directives": [
220 "gazelle:proto disable",
221 ],
222 "patches": [
223 "//third_party/go/patches:etcd-fix-embed-close.patch",
224 ],
225 },
226 "github.com/grpc-ecosystem/grpc-gateway": {
227 # Force generation of new build files for this package, required due to changes in how gazelle handles @go_googleapis.
228 "build_file_generation": "on",
229 "directives": [
230 "gazelle:exclude **/**_test.go",
231 "gazelle:exclude examples",
232 "gazelle:resolve go github.com/grpc-ecosystem/grpc-gateway/internal //internal",
233 "gazelle:resolve go github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options //protoc-gen-swagger/options",
234 "gazelle:proto disable_global",
235 ],
236 },
237 "k8s.io/api": {
238 "directives": [
239 "gazelle:proto disable",
240 ],
241 },
242 "k8s.io/apiextensions-apiserver": {
243 "directives": [
244 "gazelle:proto disable",
245 ],
246 },
247 "k8s.io/apiserver": {
248 "directives": [
249 "gazelle:proto disable",
250 ],
251 },
252 "k8s.io/cri-api": {
253 "directives": [
254 "gazelle:proto disable",
255 ],
256 },
257 "k8s.io/kube-aggregator": {
258 "directives": [
259 "gazelle:proto disable",
260 ],
261 },
262 "k8s.io/kubelet": {
263 "directives": [
264 "gazelle:proto disable",
265 ],
266 "patches": [
267 "//third_party/go/patches:kubelet-fix-path.patch",
268 ],
269 },
270 "k8s.io/kubernetes": {
271 "directives": [
272 "gazelle:proto disable",
273 "gazelle:build_tags providerless,dockerless",
274 ],
275 "patches": [
276 "//third_party/go/patches:k8s-native-metrics.patch",
277 "//third_party/go/patches:k8s-removed-block-device-pseudo-locks.patch",
278 "//third_party/go/patches:k8s-add-pause-build-file.patch",
279 "//third_party/go/patches:k8s-reserve-metropolis-ports-import.patch",
280 ],
281 "pre_patches": [
282 "//third_party/go/patches:k8s-drop-legacy-log-path.patch",
283 "//third_party/go/patches:k8s-reserve-metropolis-ports.patch",
284 ],
285 },
286 "k8s.io/metrics": {
287 "directives": [
288 "gazelle:proto disable",
289 ],
290 },
291 "google.golang.org/genproto/googleapis/api": {
292 "directives": [
293 "gazelle:proto disable_global",
294 ],
295 },
296 "google.golang.org/genproto/googleapis/rpc": {
297 "directives": [
298 "gazelle:proto disable_global",
299 ],
300 },
301 "google.golang.org/grpc": {
302 "directives": [
303 "gazelle:proto disable",
304 ],
305 },
306 "github.com/pingcap/tidb/parser": {
307 "build_file_generation": "on",
308 },
309 "golang.org/x/mod": {
310 "build_extra_args": [
311 "-go_naming_convention=import_alias",
312 "-go_naming_convention_external=import_alias",
313 ],
314 },
315 "golang.org/x/sync": {
316 "build_extra_args": [
317 "-go_naming_convention=import_alias",
318 "-go_naming_convention_external=import_alias",
319 ],
320 },
321 "github.com/containernetworking/cni": {
322 "patches": [
323 "//third_party/go/patches:cni-fix-cachepath.patch",
324 ],
325 },
326 "github.com/coredns/coredns": {
327 "pre_patches": [
328 "//third_party/go/patches:coredns-remove-unused-plugins.patch",
329 ],
330 },
331 "github.com/corverroos/commentwrap": {
332 "patches": [
333 "//third_party/go/patches:commentwrap-uri.patch",
334 ],
335 },
336 "github.com/go-delve/delve": {
337 "patches": [
338 "//third_party/go/patches:delve-fix-cgo.patch",
339 ],
340 },
341 "github.com/pganalyze/pg_query_go/v4": {
342 "patches": [
343 "//third_party/go/patches:pganalyze-add-cdeps.patch",
344 ],
345 },
346 "github.com/sbezverk/nfproxy": {
347 "pre_patches": [
348 "//third_party/go/patches:nfproxy-adapt-to-k8s-1.28.patch",
349 ],
350 },
351 "k8s.io/kubectl": {
352 "patches": [
353 "//third_party/go/patches:kubectl-fix-embed.patch",
354 ],
355 },
356 "github.com/seccomp/libseccomp-golang": {
357 "patches": [
358 "//third_party/go/patches:libseccomp.patch",
359 ],
360 },
361 "github.com/vishvananda/netlink": {
362 "patches": [
363 "//third_party/go/patches:netlink-permhwaddr.patch",
364 "//third_party/go/patches:netlink-use-rtm_setlink.patch",
365 ],
366 },
367 "gvisor.dev/gvisor": {
368 "patches": [
369 "//third_party/go/patches:gvisor-fix-syslog.patch",
370 # Gazelle doesn't understand conditional build files.
371 # https://github.com/bazelbuild/bazel-gazelle/issues/1262
372 "//third_party/go/patches:gvisor-fix-gazelle-debug-builds.patch",
373 ],
374 "pre_patches": [
375 "//third_party/go/patches:gvisor-containerd-compat.patch",
376 # Modified patch for the go branch.
377 # Upstream issue https://github.com/google/gvisor/issues/9039
378 # Upstream patch https://github.com/google/gvisor/commit/62afa160fe8ad17302d43f7c6016061de57c7f4d
379 "//third_party/go/patches:gvisor-fix-debug-builds.patch",
380 ],
381 },
382 "go.etcd.io/etcd/tests/v3": {
383 "patches": [
384 "//third_party/go/patches:etcd-integration-logging.patch",
385 ],
386 },
387 "k8s.io/mount-utils": {
388 "pre_patches": [
389 "//third_party/go/patches:k8s-native-mounter.patch",
390 ],
391 },
392 "golang.org/x/tools": {
393 "patches": [
394 "//third_party/go/patches:goimports-group-merging.patch",
395 ],
396 },
397}
398
399# MODULE.bazel doesn't support loops, but since we have lots of overrides,
400# this is the more readable approach.
401[
402 [
403 go_deps.gazelle_override(
404 build_extra_args = overrides.get("build_extra_args") or [],
405 build_file_generation = overrides.get("build_file_generation") or "auto",
406 directives = overrides.get("directives") or [],
407 path = path,
408 ),
409 go_deps.module_override(
410 patch_strip = 1,
411 patches = overrides.get("patches") or [],
412 path = path,
413 pre_patches = overrides.get("pre_patches") or [],
414 ),
415 ]
416 for path, overrides in OVERRIDES.items()
417]