...

Package version

import "sigs.k8s.io/release-utils/version"
Overview
Index

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" .`

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

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"))

```

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

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