version

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: Apache-2.0 Imports: 11 Imported by: 87

Documentation

Overview

Package version provides an importable cobra command and a fixed package path location to set compile time version information. To override the default values, set the `-ldflags` flags with the following strings:

sigs.k8s.io/release-utils/version.gitVersion=<GitVersion> sigs.k8s.io/release-utils/version.gitCommit=<GitCommit> sigs.k8s.io/release-utils/version.gitTreeState=<GitTreeState> sigs.k8s.io/release-utils/version.buildDate=<BuildDate>

Example: `go build -ldflags " -X sigs.k8s.io/release-utils/version.gitVersion=v0.4.0-1-g040f53c -X sigs.k8s.io/release-utils/version.gitCommit=040f53c -X sigs.k8s.io/release-utils/version.gitTreeState=dirty -X sigs.k8s.io/release-utils/version.buildDate=2022-02-03T17:30:01Z" .`

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Version

func Version() *cobra.Command

Version returns a cobra command to be added to another cobra command, like: ```go

rootCmd.AddCommand(version.Version())

```

func WithFont added in v0.6.0

func WithFont(fontName string) *cobra.Command

WithFont returns a cobra command to be added to another cobra command with a select font for ASCII, like: ```go

rootCmd.AddCommand(version.WithFont("starwars"))

```

Types

type Info

type Info struct {
	GitVersion   string `json:"gitVersion"`
	GitCommit    string `json:"gitCommit"`
	GitTreeState string `json:"gitTreeState"`
	BuildDate    string `json:"buildDate"`
	GoVersion    string `json:"goVersion"`
	Compiler     string `json:"compiler"`
	Platform     string `json:"platform"`

	ASCIIName   string `json:"-"`
	FontName    string `json:"-"`
	Name        string `json:"-"`
	Description string `json:"-"`
}

func GetVersionInfo

func GetVersionInfo() Info

GetVersionInfo represents known information on how this binary was built.

func (*Info) CheckFontName added in v0.6.0

func (i *Info) CheckFontName(fontName string) bool

func (*Info) JSONString

func (i *Info) JSONString() (string, error)

JSONString returns the JSON representation of the version info

func (*Info) String

func (i *Info) String() string

String returns the string representation of the version info

Jump to

Keyboard shortcuts

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