version

package
v5.10.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2019 License: MIT, MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Version stores the version of the current build (e.g. 2.0.0)
	Version = ""

	// PreReleaseIdentifier stores the pre-release identifier of the current
	// build (e.g. the 2 in beta-2)
	PreReleaseIdentifier string

	// BuildDate stores the timestamp of the build
	// (e.g. 2017-07-31T13:11:15-0700)
	BuildDate string

	// BuildSHA stores the git sha of the build
	// (e.g. 8673bed0a9705083987b9ecbbc1cc0758df13dd2)
	BuildSHA string
)

These values are baked into the sensu-agent and sensu-backend binaries during compilation, and are accessed using the Semver() function

View Source
var (
	ErrNoBuildIteration = errors.New("Build iteration could not be found. If running locally you must set SENSU_BUILD_ITERATION.")
	ErrTagParse         = errors.New("A build iteration could not be parsed from the tag")
)

Functions

func FullVersion

func FullVersion(tag string, bt BuildType) (string, error)

FullVersion will output the version of the build (with iteration) (e.g. "2.0.0-alpha.17-1")

func GetBaseVersion

func GetBaseVersion(tag string, bt BuildType) (string, error)

GetBaseVersion will output the major, minor, and patch #s with dots. (e.g. "2.0.1")

func GetPrereleaseVersion

func GetPrereleaseVersion(tag string, bt BuildType) (string, error)

GetPrereleaseVersion will output the version of a prerelease from its tag (e.g. "17" from tag "2.0.0-alpha.17")

func GetVersion

func GetVersion(tag string, bt BuildType) (string, error)

GetVersion will output the version of the build (without iteration) (e.g. "2.0.0-alpha.17")

func Iteration

func Iteration(tag string, bt BuildType) (string, error)

Iteration will output an iteration number based on what type of build the git sha represents and the ci platform it is running on. (e.g. the 1 in 2.0.0-alpha.17-1)

func Semver

func Semver() string

Semver returns full semantic versioning compatible identifier. Format: VERSION-PRERELEASE+METADATA

Types

type BuildEnv

type BuildEnv interface {
	IsCI() bool
	IsNightly() (bool, error)
	GetMostRecentTag() (string, error)
}

BuildEnv provides methods for determining version info from the current env.

type BuildType

type BuildType string
const (
	Dev     BuildType = "dev"
	Nightly BuildType = "nightly"
	Alpha   BuildType = "alpha"
	Beta    BuildType = "beta"
	RC      BuildType = "rc"
	Stable  BuildType = "stable"
)

func FindVersionInfo

func FindVersionInfo(env BuildEnv) (string, BuildType, error)

FindVersionInfo discovers the most recent tag and BuildType using the current build environment

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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