version

package
v0.0.0-...-703489d Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const AnyVersion = ">=0.0.0"

AnyVersion is a range that matches any released version.

Variables

View Source
var (
	// ErrIsNotValid when version data is malformed.
	ErrIsNotValid = errors.New("is not valid")

	// ErrVersionIsNotValid when given version is not semantic.
	ErrVersionIsNotValid = fmt.Errorf("version %w", ErrIsNotValid)

	// ErrRangeIsNotValid when given range is not valid.
	ErrRangeIsNotValid = fmt.Errorf("range %w", ErrIsNotValid)

	// ErrVersionOutsideOfRange when given version is outside of range.
	ErrVersionOutsideOfRange = fmt.Errorf("version %w for given range", ErrIsNotValid)
)

Functions

func CompatibleRanges

func CompatibleRanges(resolver Resolver) ([]string, error)

CompatibleRanges will resolve compatible ranges from a version resolver.

func IsLatest

func IsLatest(version, versionRange string, resolver IsLatestResolver) (bool, error)

IsLatest does basic coherence checking on version and range, before executing provided resolver to answer if given version is the latest within the given version range.

func IsLatestGivenReleases

func IsLatestGivenReleases(
	version, versionRange string,
	skipInvalidReleases bool,
	releases func() []string,
) (bool, error)

IsLatestGivenReleases checks if given version is the latest within the given version range, using a list of provided releases.

Types

type IsLatestResolver

type IsLatestResolver func(version semver.Version, versionRange semver.Range) (bool, error)

IsLatestResolver is a func that returns true if given version is the latest one within given version range.

type Resolver

type Resolver interface {
	// Version returns the version string.
	Version() string
	// IsLatest tells if the version is the latest one within given version range.
	IsLatest(versionRange string) (bool, error)
}

Resolver will resolve version string, and tell is that the latest artifact.

Jump to

Keyboard shortcuts

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