blob: 1e565a0b7b964c076e34bb88ae01464afdd8606e [file] [log] [blame]
Leopoldbe326c22023-01-04 20:42:59 +01001load("@bazeldnf//:def.bzl", "bazeldnf")
Tim Windelschmidt156248b2025-01-10 00:27:45 +01002load("@buildifier_prebuilt//:rules.bzl", "buildifier", "buildifier_test")
Tim Windelschmidted9a5832025-02-04 03:02:45 +01003load("@gazelle//:def.bzl", "gazelle", "gazelle_test")
Tim Windelschmidt156248b2025-01-10 00:27:45 +01004load("@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",
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
Leopoldbe326c22023-01-04 20:42:59 +010058# bazeldnf binary
59bazeldnf(name = "bazeldnf")
60
Leopold Schabel26d41992020-12-15 19:27:58 +010061# Shortcuts for top-level binaries/tools
62
Serge Bazanski2fb13a82020-02-11 12:41:37 +010063# Shortcut for kubectl when running through bazel run
64# (don't depend on this, it might turn into an env-based PATH shortcut, use
Serge Bazanskibb7db922020-04-30 12:43:10 +020065# @io_k8s_kubernetes//cmd/kubectl instead)
Serge Bazanski2fb13a82020-02-11 12:41:37 +010066alias(
67 name = "kubectl",
Serge Bazanskibb7db922020-04-30 12:43:10 +020068 actual = "@io_k8s_kubernetes//cmd/kubectl:kubectl",
Serge Bazanski2fb13a82020-02-11 12:41:37 +010069)
Leopold Schabel3058b7a2020-06-03 17:51:07 +020070
71# Shortcut for the Delve debugger for interactive debugging
72alias(
73 name = "dlv",
74 actual = "@com_github_go_delve_delve//cmd/dlv:dlv",
75)
Lorenz Brunfc5dbc62020-05-28 12:18:07 +020076
Leopold Schabeld2120142021-12-03 21:30:49 +010077alias(
Leopold Schabel26d41992020-12-15 19:27:58 +010078 name = "goimports",
79 actual = "@org_golang_x_tools//cmd/goimports:goimports",
80 visibility = ["//visibility:public"],
81)
Tim Windelschmidt156248b2025-01-10 00:27:45 +010082
83command(
84 name = "go-mod-tidy",
85 arguments = [
86 "mod",
87 "tidy",
88 ],
89 command = ":go",
90)
91
92# Shortcut to update go.mod, gazelle files and formatting.
93multirun(
94 name = "tidy",
95 commands = [
96 ":go-mod-tidy",
97 ":gazelle",
98 ":buildifier",
99 ],
100)