Documentation
¶
Overview ¶
Package version centralizes CLI build/version metadata across cmd/*. It mirrors kubectl's version.Info schema so downstream tooling can parse the JSON form interchangeably.
Index ¶
Constants ¶
const Devel = "(devel)"
Devel is the placeholder used when no value is injected via -ldflags and runtime/debug.ReadBuildInfo cannot supply one (e.g. `go run`, `go test`, ad-hoc local builds).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Info ¶
type Info struct {
Name string `json:"name"`
Version string `json:"version"`
GitCommit string `json:"git_commit"`
GitTreeState string `json:"git_tree_state"`
BuildTime string `json:"build_time"`
GoVersion string `json:"go_version"`
Compiler string `json:"compiler"`
Platform string `json:"platform"`
}
Info captures CLI release identity. Field order mirrors kubectl's version.Info to ease integration with downstream tooling.
func Resolve ¶
Resolve returns Info populated from Seed first, then runtime/debug, then runtime constants. Missing string values fall back to Devel so callers always get a renderable value.
func Wire ¶
Wire resolves Seed, sets app.Version to the multi-line form, registers the global --version-format flag (text|json|short), and overrides cli.VersionPrinter so `-v` honors the chosen format. Returns the resolved Info so callers can reuse it (e.g. as a toolstream version).
It also chains app.Before to warn when --version-format is set but --version is not, since the format flag has no effect on its own.
Must be called after the caller has populated app.Flags, since Wire appends to that slice.
func (*Info) Labels ¶
Labels returns an independent set of build identity labels using the JSON keys.