version

package
v0.19.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package version holds the shared types and helpers used by each binary's version subpackage (pkg/version/cli and pkg/version/daemon). The two subpackages each embed their own VERSION + COMMIT and register themselves here at init time via SetCurrent so shared code (internal/...) can read the running binary's version through Get / Number / Commit without knowing which binary it belongs to.

Index

Constants

View Source
const (
	FormatYAML = "yaml"
	FormatJSON = "json"
)

Variables

This section is empty.

Functions

func Commit

func Commit() string

Commit returns the running binary's commit hash.

func NewCmd added in v0.18.0

func NewCmd(getter func() Info) *cobra.Command

NewCmd returns a "version" Cobra command that prints the Info returned by getter. Each binary's version subpackage instantiates this with its own Get function so the parent package stays free of binary-specific state.

func Number

func Number() string

Number returns the running binary's version number.

func Print

func Print(cmd *cobra.Command, format string, info Info) error

Print writes info in the requested format to cmd's stdout.

func SetCurrent added in v0.18.0

func SetCurrent(info Info)

SetCurrent registers the running binary's Info. Called from each binary's pkg/version/{cli,daemon} subpackage init().

func Text

func Text(info Info) string

Text returns a human-readable version string for display purposes.

Types

type Info

type Info struct {
	Number    string `json:"version" yaml:"version"`
	Commit    string `json:"commit" yaml:"commit"`
	GoVersion string `json:"goversion" yaml:"goversion"`
}

func Get

func Get() Info

Get returns the running binary's Info.

func (Info) Format

func (v Info) Format(format string) (string, error)

func (Info) Text

func (v Info) Text() string

Directories

Path Synopsis
Package cli is the version subpackage owned by the solo-provisioner CLI binary.
Package cli is the version subpackage owned by the solo-provisioner CLI binary.
Package daemon is the version subpackage owned by the solo-provisioner-daemon binary.
Package daemon is the version subpackage owned by the solo-provisioner-daemon binary.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL