blob: b5111ee9b3dd943aa45636916f259e5e922f0f3d [file] [log] [blame]
Tim Windelschmidt156248b2025-01-10 00:27:45 +01001load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_test")
Leopoldbe326c22023-01-04 20:42:59 +01002load("@bazeldnf//:def.bzl", "bazeldnf")
Tim Windelschmidt156248b2025-01-10 00:27:45 +01003load("@buildifier_prebuilt//:rules.bzl", "buildifier", "buildifier_test")
4load("@rules_multirun//:defs.bzl", "command", "multirun")
5
6exports_files([
7 "MODULE.bazel",
8])
Leopold Schabel5c80aca2019-10-22 15:48:58 +02009
Serge Bazanski31370b02021-01-07 16:31:14 +010010# gazelle:prefix source.monogon.dev
Lorenz Brund13c1c62022-03-30 19:58:58 +020011# gazelle:go_naming_convention import
Serge Bazanskifdc3a242022-04-06 15:56:38 +020012# gazelle:exclude **/gomod-generated-placeholder.go
Leopold7fbf1042023-01-06 19:57:37 +010013# gazelle:exclude .bazeldnf/**
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",
18 workspace = "//:MODULE.bazel",
19)
20
21BUILDIFIER_EXCLUDES = [
22 "./.git/*",
23 "./.ijwb/*",
24]
25
26# Buildifier formats all Starlark files.
27buildifier(
28 name = "buildifier",
29 exclude_patterns = BUILDIFIER_EXCLUDES,
30 lint_mode = "fix",
31 mode = "fix",
32)
33
34buildifier_test(
35 name = "buildifier_test",
36 exclude_patterns = BUILDIFIER_EXCLUDES,
37 lint_mode = "warn",
38 lint_warnings = [
39 "-module-docstring",
40 "-function-docstring-args",
41 "-function-docstring",
42 "-function-docstring-header",
43 "-function-docstring-return",
44 "-unnamed-macro", #TODO(tim): Update code to pass this
45 ],
46 no_sandbox = True,
47 workspace = "//:MODULE.bazel",
48)
49
Leopold Schabeld868d692019-11-17 17:28:29 +010050# Shortcut for the Go SDK
51alias(
52 name = "go",
Tim Windelschmidt7b8d86b2024-07-15 19:21:12 +020053 actual = "@io_bazel_rules_go//go",
Leopold Schabela4516f92019-12-04 20:27:05 +000054 visibility = ["//visibility:public"],
55)
56
Leopoldbe326c22023-01-04 20:42:59 +010057# bazeldnf binary
58bazeldnf(name = "bazeldnf")
59
Leopold Schabel26d41992020-12-15 19:27:58 +010060# Shortcuts for top-level binaries/tools
61
Serge Bazanski2fb13a82020-02-11 12:41:37 +010062# Shortcut for kubectl when running through bazel run
63# (don't depend on this, it might turn into an env-based PATH shortcut, use
Serge Bazanskibb7db922020-04-30 12:43:10 +020064# @io_k8s_kubernetes//cmd/kubectl instead)
Serge Bazanski2fb13a82020-02-11 12:41:37 +010065alias(
66 name = "kubectl",
Serge Bazanskibb7db922020-04-30 12:43:10 +020067 actual = "@io_k8s_kubernetes//cmd/kubectl:kubectl",
Serge Bazanski2fb13a82020-02-11 12:41:37 +010068)
Leopold Schabel3058b7a2020-06-03 17:51:07 +020069
70# Shortcut for the Delve debugger for interactive debugging
71alias(
72 name = "dlv",
73 actual = "@com_github_go_delve_delve//cmd/dlv:dlv",
74)
Lorenz Brunfc5dbc62020-05-28 12:18:07 +020075
Leopold Schabeld2120142021-12-03 21:30:49 +010076alias(
Leopold Schabel26d41992020-12-15 19:27:58 +010077 name = "goimports",
78 actual = "@org_golang_x_tools//cmd/goimports:goimports",
79 visibility = ["//visibility:public"],
80)
Tim Windelschmidt156248b2025-01-10 00:27:45 +010081
82command(
83 name = "go-mod-tidy",
84 arguments = [
85 "mod",
86 "tidy",
87 ],
88 command = ":go",
89)
90
91# Shortcut to update go.mod, gazelle files and formatting.
92multirun(
93 name = "tidy",
94 commands = [
95 ":go-mod-tidy",
96 ":gazelle",
97 ":buildifier",
98 ],
99)