compatibility

package
v2.16.4 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package compatibility offers helper functions for comparing and filtering versions.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMajorMismatch signals that the major version of two compared versions don't match.
	ErrMajorMismatch = errors.New("missmatching major version")
	// ErrMinorDrift signals that the minor version of two compared versions are further apart than one.
	ErrMinorDrift = errors.New("version difference larger than one minor version")
	// ErrSemVer signals that a given version does not adhere to the Semver syntax.
	ErrSemVer = errors.New("invalid semantic version")
	// ErrOutdatedCLI signals that the configured version is newer than the CLI. This is not allowed.
	ErrOutdatedCLI = errors.New("target version newer than cli version")
)

Functions

func BinaryWith

func BinaryWith(binaryVersion, target string) error

BinaryWith tests that this binarie's version is greater or equal than some target version, but not further away than one minor version.

func EnsurePrefixV

func EnsurePrefixV(str string) string

EnsurePrefixV returns the input string prefixed with the letter "v", if the string doesn't already start with that letter.

func FilterNewerVersion

func FilterNewerVersion(currentVersion string, newVersions []string) []string

FilterNewerVersion filters the list of versions to only include versions newer than currentVersion.

func IsValidUpgrade

func IsValidUpgrade(a, b string) error

IsValidUpgrade checks that a and b adhere to a version drift of 1 and b is greater than a.

func NextMinorVersion

func NextMinorVersion(version string) (string, error)

NextMinorVersion returns the next minor version for a given canonical semver. The returned format is vMAJOR.MINOR.

Types

type InvalidUpgradeError

type InvalidUpgradeError struct {
	// contains filtered or unexported fields
}

InvalidUpgradeError present an invalid upgrade. It wraps the source and destination version for improved debuggability.

func NewInvalidUpgradeError

func NewInvalidUpgradeError(from string, to string, innerErr error) *InvalidUpgradeError

NewInvalidUpgradeError returns a new InvalidUpgradeError.

func (*InvalidUpgradeError) Error

func (e *InvalidUpgradeError) Error() string

Error returns the String representation of this error.

func (*InvalidUpgradeError) Unwrap

func (e *InvalidUpgradeError) Unwrap() error

Unwrap returns the inner error, which is nil in this case.

Jump to

Keyboard shortcuts

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