blob: 1b6be74df4872b2877b083d3ef616b1e8e84bcd8 [file] [log] [blame]
Tim Windelschmidt156248b2025-01-10 00:27:45 +01001load("@buildifier_prebuilt//:rules.bzl", "buildifier", "buildifier_test")
Tim Windelschmidted9a5832025-02-04 03:02:45 +01002load("@gazelle//:def.bzl", "gazelle", "gazelle_test")
Tim Windelschmidt156248b2025-01-10 00:27:45 +01003load("@rules_multirun//:defs.bzl", "command", "multirun")
4
5exports_files([
6 "MODULE.bazel",
7])
Leopold Schabel5c80aca2019-10-22 15:48:58 +02008
Serge Bazanski31370b02021-01-07 16:31:14 +01009# gazelle:prefix source.monogon.dev
Lorenz Brund13c1c62022-03-30 19:58:58 +020010# gazelle:go_naming_convention import
Serge Bazanskifdc3a242022-04-06 15:56:38 +020011# gazelle:exclude **/gomod-generated-placeholder.go
Leopold7fbf1042023-01-06 19:57:37 +010012# gazelle:exclude .bazeldnf/**
Tim Windelschmidtd4817492025-06-16 15:03:12 +020013# gazelle:go_grpc_compilers @io_bazel_rules_go//proto:go_proto,@io_bazel_rules_go//proto:go_grpc_v2
Leopold Schabel5c80aca2019-10-22 15:48:58 +020014gazelle(name = "gazelle")
Leopold Schabeld868d692019-11-17 17:28:29 +010015
Tim Windelschmidt156248b2025-01-10 00:27:45 +010016gazelle_test(
17 name = "gazelle_test",
Tim Windelschmidt32e74302025-01-15 04:37:26 +010018 tags = ["no-remote"],
Tim Windelschmidt156248b2025-01-10 00:27:45 +010019 workspace = "//:MODULE.bazel",
20)
21
22BUILDIFIER_EXCLUDES = [
23 "./.git/*",
24 "./.ijwb/*",
25]
26
27# Buildifier formats all Starlark files.
28buildifier(
29 name = "buildifier",
30 exclude_patterns = BUILDIFIER_EXCLUDES,
31 lint_mode = "fix",
32 mode = "fix",
33)
34
35buildifier_test(
36 name = "buildifier_test",
37 exclude_patterns = BUILDIFIER_EXCLUDES,
38 lint_mode = "warn",
39 lint_warnings = [
40 "-module-docstring",
41 "-function-docstring-args",
42 "-function-docstring",
43 "-function-docstring-header",
44 "-function-docstring-return",
Tim Windelschmidt156248b2025-01-10 00:27:45 +010045 ],
46 no_sandbox = True,
Tim Windelschmidt32e74302025-01-15 04:37:26 +010047 tags = ["no-remote"],
Tim Windelschmidt156248b2025-01-10 00:27:45 +010048 workspace = "//:MODULE.bazel",
49)
50
Leopold Schabeld868d692019-11-17 17:28:29 +010051# Shortcut for the Go SDK
52alias(
53 name = "go",
Tim Windelschmidt7b8d86b2024-07-15 19:21:12 +020054 actual = "@io_bazel_rules_go//go",
Leopold Schabela4516f92019-12-04 20:27:05 +000055 visibility = ["//visibility:public"],
56)
57
Leopold Schabel26d41992020-12-15 19:27:58 +010058# Shortcuts for top-level binaries/tools
59
Serge Bazanski2fb13a82020-02-11 12:41:37 +010060# Shortcut for kubectl when running through bazel run
61# (don't depend on this, it might turn into an env-based PATH shortcut, use
Serge Bazanskibb7db922020-04-30 12:43:10 +020062# @io_k8s_kubernetes//cmd/kubectl instead)
Serge Bazanski2fb13a82020-02-11 12:41:37 +010063alias(
64 name = "kubectl",
Serge Bazanskibb7db922020-04-30 12:43:10 +020065 actual = "@io_k8s_kubernetes//cmd/kubectl:kubectl",
Serge Bazanski2fb13a82020-02-11 12:41:37 +010066)
Leopold Schabel3058b7a2020-06-03 17:51:07 +020067
68# Shortcut for the Delve debugger for interactive debugging
69alias(
70 name = "dlv",
71 actual = "@com_github_go_delve_delve//cmd/dlv:dlv",
72)
Lorenz Brunfc5dbc62020-05-28 12:18:07 +020073
Leopold Schabeld2120142021-12-03 21:30:49 +010074alias(
Leopold Schabel26d41992020-12-15 19:27:58 +010075 name = "goimports",
76 actual = "@org_golang_x_tools//cmd/goimports:goimports",
77 visibility = ["//visibility:public"],
78)
Tim Windelschmidt156248b2025-01-10 00:27:45 +010079
80command(
81 name = "go-mod-tidy",
82 arguments = [
83 "mod",
84 "tidy",
85 ],
86 command = ":go",
87)
88
89# Shortcut to update go.mod, gazelle files and formatting.
90multirun(
91 name = "tidy",
92 commands = [
93 ":go-mod-tidy",
94 ":gazelle",
95 ":buildifier",
96 ],
97)