version

package
v2.18.0+incompatible Latest Latest
Warning

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

Go to latest
Published: May 17, 2021 License: AGPL-3.0 Imports: 6 Imported by: 22

Documentation

Overview

Package version provides helpers for working with versions and build info.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Component name, e.g. "pmm-managed" or "mongodb_exporter".
	// {{ .ProjectName }} for GoReleaser.
	ProjectName string

	// Component version, e.g. "2.1.2-beta1" for pmm-managed or "0.6.3" for mongodb_exporter.
	// {{ .Version }} for GoReleaser.
	Version string

	// PMM version. Empty for non-PMM builds.
	// For example, "2.1.2-beta1" for mongodb_exporter when built with PMM Client, empty otherwise.
	PMMVersion string

	// Build UNIX timestamp, e.g. "1545226908".
	// {{ .Timestamp }} for GoReleaser.
	Timestamp string

	// Full git commit hash, e.g. "6559a94ab33831deeda04193f74413b735edb1a1".
	// {{ .FullCommit }} for GoReleaser.
	FullCommit string

	// Git branch name, e.g. "master".
	Branch string
)

https://goreleaser.com/templates/

Functions

func FullInfo

func FullInfo() string

FullInfo returns multi-line version information.

func FullInfoJson

func FullInfoJson() string

FullInfoJson returns version information in JSON format.

func ShortInfo

func ShortInfo() string

ShortInfo returns project name and short version as one line.

func Time

func Time() (time.Time, error)

Time returns parsed Timestamp.

Types

type PackageInfo

type PackageInfo struct {
	Version     string     `json:"version"`
	FullVersion string     `json:"full_version"`
	BuildTime   *time.Time `json:"build_time"`
	Repo        string     `json:"repo"`
}

PackageInfo describes a single package version.

type Parsed

type Parsed struct {
	Major   int
	Minor   int
	Patch   int
	Rest    string
	Num     int // MMmmpp
	NumRest int
}

Parsed represents a SemVer-like version information.

func MustParse

func MustParse(s string) *Parsed

MustParse is like Parse but panics if given string cannot be parsed. It simplifies safe initialization of global variables holding parsed versions.

func Parse

func Parse(s string) (*Parsed, error)

Parse parses version information from given string.

func (*Parsed) Less

func (p *Parsed) Less(right *Parsed) bool

Less returns true if this (left) Info is less than given argument (right).

func (*Parsed) String

func (p *Parsed) String() string

String returns original string representation of version information.

type UpdateCheckResult

type UpdateCheckResult struct {
	Installed       PackageInfo `json:"installed"`
	Latest          PackageInfo `json:"latest,omitempty"`
	UpdateAvailable bool        `json:"update_available"`
	LatestNewsURL   string      `json:"latest_news_url"`
}

UpdateCheckResult represents `pmm-update -check` result.

type UpdateInstalledResult

type UpdateInstalledResult struct {
	Installed PackageInfo `json:"installed"`
}

UpdateInstalledResult represents `pmm-update -installed` result.

Jump to

Keyboard shortcuts

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