versionutils

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2024 License: Apache-2.0 Imports: 14 Imported by: 26

Documentation

Index

Constants

View Source
const (
	SemverNilVersionValue = "v0.0.0"
	SemverMinimumVersion  = "v0.0.1"
)

SemverLowerBound is the "nil" value for changelog versions It is not itself a valid version but it allows us to use our semver validation on the v0.0.1 edge case

Variables

View Source
var (
	UnableToFindVersionInTomlError = func(pkgName string) error {
		return fmt.Errorf("unable to find version for %s in toml", pkgName)
	}
	FailedCommandError = func(err error, args []string, output string) error {
		return errors.Wrapf(err, "%v failed: %s", args, output)
	}
)
View Source
var (
	InvalidSemverVersionError = func(tag string) error {
		return eris.Errorf("Tag %s is not a valid semver version, must be of the form vX.Y.Z[-<label>#]", tag)
	}
)

Functions

func GetDependencyVersionInfo added in v0.10.8

func GetDependencyVersionInfo(pkgName string, toml *TomlWrapper) (*dep.VersionInfo, error)

Returns the version of the given package together with the type of version identifier, i.e. revision, version, branch.

func GetGitVersion deprecated

func GetGitVersion(relativeRepoDir string) (string, error)

Deprecated: use git.GetGitRefInfo

func GetImageVersion added in v0.9.7

func GetImageVersion(version *Version) string

func GetTag deprecated

func GetTag(version string) string

Deprecated: use git.AppendTagPrefix

func GetTomlVersion deprecated

func GetTomlVersion(pkgName string, toml *TomlWrapper) (string, error)

Deprecated: use GetDependencyVersionInfo

func GetVersion deprecated

func GetVersion(pkgName string, tomlTree []*toml.Tree) (string, error)

Deprecated: Use GetTomlVersion instead

func GetVersionFromTag

func GetVersionFromTag(shouldBeAVersion string) (string, error)

func Index added in v0.21.7

func Index(versions []Version, v Version) int

func IndexPtr added in v0.21.7

func IndexPtr(versions []*Version, v Version) int

func IsGreaterThanTag

func IsGreaterThanTag(greaterTag, lesserTag string) (bool, bool, error)

func IsGreaterThanTagWithLabelOrder added in v0.21.2

func IsGreaterThanTagWithLabelOrder(greaterTag, lesserTag string, labelOrder []string) (bool, bool, error)

func MatchesRegex

func MatchesRegex(tag string) bool

func ParseToml deprecated

func ParseToml() ([]*toml.Tree, error)

Deprecated: Use ParseFullToml instead

func ParseTomlFromDir deprecated

func ParseTomlFromDir(relativeDir string) ([]*toml.Tree, error)

Deprecated: Use ParseFullTomlFromDir instead

func ParseTomlOverrides deprecated

func ParseTomlOverrides() ([]*toml.Tree, error)

Deprecated: Use ParseFullToml instead

func ParseTomlOverridesFromDir deprecated

func ParseTomlOverridesFromDir(relativeDir string) ([]*toml.Tree, error)

Deprecated: Use ParseFullTomlFromDir instead

func PinGitVersion deprecated

func PinGitVersion(relativeRepoDir string, semVerVersion string) error

Deprecated: use git.PinDependencyVersion This function prepends a "v" to the semver and then tries to 'git checkout' the resulting tag in the given directory.

Types

type TomlWrapper

type TomlWrapper struct {
	Overrides   []*toml.Tree
	Constraints []*toml.Tree
}

func ParseFullToml

func ParseFullToml() (*TomlWrapper, error)

func ParseFullTomlFromDir

func ParseFullTomlFromDir(relativeDir string) (*TomlWrapper, error)

type Version

type Version struct {
	Major int
	Minor int
	Patch int

	// optional to support a version like "1.0.0-rc1", where "rc" is the label and "1" is the label version
	// for comparisons:
	//  - "1.0.0-rc1" is greater than "0.X.Y" and less than "1.0.0"
	//  - "1.0.0-rc5" is greater than "1.0.0-rc1"
	//  - "1.0.0-aX" is not greater than or less than "1.0.0-bY", except by convention
	Label        string
	LabelVersion int
}

func GetReleaseVersionOrExitGracefully

func GetReleaseVersionOrExitGracefully() *Version

func NewVersion

func NewVersion(major, minor, patch int, label string, labelVersion int) *Version

func ParseVersion

func ParseVersion(tag string) (*Version, error)

func StableApiVersion

func StableApiVersion() Version

func Zero

func Zero() Version

func (*Version) Equals

func (v *Version) Equals(other *Version) bool

func (*Version) IncrementVersion

func (v *Version) IncrementVersion(breakingChange, newFeature bool) *Version

func (Version) IsGreaterThan

func (v Version) IsGreaterThan(lesser Version) (bool, bool)

In order, returns isGreaterThanOrEqualTo, isDeterminable isDeterminable is for incomparable versions because they have different labels, e.g. 1.0.0-foo1 vs 1.0.0-bar2 If you want to tiebreak indeterminate comparisons using alphanumeric ordering, try MustIsGreaterThan

func (Version) IsGreaterThanOrEqualTo

func (v Version) IsGreaterThanOrEqualTo(lesser Version) (bool, bool)

In order, returns isGreaterThanOrEqualTo, isDeterminable isDeterminable is for incomparable versions because they have different labels, e.g. 1.0.0-foo1 vs 1.0.0-bar2 If you want to tiebreak indeterminate comparisons using alphanumeric ordering, try MustIsGreaterThanOrEqualTo

func (*Version) IsGreaterThanOrEqualToPtr added in v0.12.0

func (v *Version) IsGreaterThanOrEqualToPtr(lesser *Version) (bool, bool, error)

In order, returns isGreaterThanOrEqualTo, isDeterminable, err isDeterminable is for incomparable versions because they have different labels, e.g. 1.0.0-foo1 vs 1.0.0-bar2 If you want to tiebreak indeterminate comparisons using alphanumeric ordering, try MustIsGreaterThanOrEqualTo

func (*Version) IsGreaterThanPtr added in v0.12.0

func (v *Version) IsGreaterThanPtr(lesser *Version) (bool, bool, error)

In order, returns isGreaterThanOrEqualTo, isDeterminable, err isDeterminable is for incomparable versions because they have different labels, e.g. 1.0.0-foo1 vs 1.0.0-bar2 If you want to tiebreak indeterminate comparisons using alphanumeric ordering, try MustIsGreaterThan

func (Version) IsGreaterThanWithLabelOrder added in v0.21.2

func (v Version) IsGreaterThanWithLabelOrder(lesser Version, labelOrder []string) (bool, bool)

In order, returns isGreaterThanOrEqualTo, isDeterminable labelOrder specifies tie-break order for labels e.g. labelOrder = [ beta, alpha, predev ], then 1.7.0-beta11 > 1.7.0-alpha5 > 1.7.0-predev9 isDeterminable is for incomporable versions because they have different labels not specified in labelOrder

func (*Version) MarshalJSON added in v0.21.7

func (v *Version) MarshalJSON() ([]byte, error)

func (Version) MustIsGreaterThan added in v0.12.0

func (v Version) MustIsGreaterThan(lesser Version) bool

for incomparable versions, default to alphanumeric sort on label e.g. 1.0.0-foo1 > 1.0.0-bar2

func (Version) MustIsGreaterThanOrEqualTo added in v0.12.0

func (v Version) MustIsGreaterThanOrEqualTo(lesser Version) bool

for incomparable versions, default to alphanumeric sort on label e.g. 1.0.0-foo1 > 1.0.0-bar2

func (*Version) String

func (v *Version) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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