versionx

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 4 Imported by: 13

Documentation

Overview

Package versionx provides a single location for setting the version on infratographer binaries. You can set these values at build time using:

 		-X go.infratographer.com/x/versionx.appName=NAME
 		-X go.infratographer.com/x/versionx.version=VERSION
		-X go.infratographer.com/x/versionx.gitCommit=GIT_SHA
		-X go.infratographer.com/x/versionx.buildDate=DATE
		-X go.infratographer.com/x/versionx.builder=USER

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrintVersion

func PrintVersion(lgr *zap.SugaredLogger)

PrintVersion will print out the details of the current build. If a logger is provided they will be printed with the logger, otherwise they will just be printed as output.

func RegisterCobraCommand

func RegisterCobraCommand(cmd *cobra.Command, printFunc func())

RegisterCobraCommand will add a version command to the cobra command provided that prints out the version. An optional logger may be provided at which point the version will be printed as an Info level log with the logger.

Types

type Details

type Details struct {
	AppName string     `json:"app"`
	Version string     `json:"version"`
	Commit  string     `json:"commit,omitempty"`
	BuiltAt *time.Time `json:"built_at,omitempty"`
	Builder string     `json:"builder"`
}

Details stores all the information collected about a version.

func BuildDetails

func BuildDetails() *Details

BuildDetails will return a Details struct containing all the values that were set at build time to provide you the current version information.

func (*Details) String

func (d *Details) String() string

String returns the version as a formatted string

Jump to

Keyboard shortcuts

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