version

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// REGEXVERSIONKIND represents versions as a simple string
	REGEXVERSIONKIND string = "regex"
	// SEMVERVERSIONKIND represents versions as a semantic versioning type
	SEMVERVERSIONKIND string = "semver"
	// LATESTVERSIONKIND specifies that we are looking for the latest version of an array
	LATESTVERSIONKIND string = "latest"
)

Variables

View Source
var (
	// ErrNoVersionFound return a error when no version couldn't be found
	ErrNoVersionFound error = errors.New("no version found")
	// ErrNoVersionsFound return a error when the versions list is empty
	ErrNoVersionsFound error = errors.New("versions list empty")
)
View Source
var (
	// SupportedKind holds a list of supported version kind
	SupportedKind []string = []string{
		REGEXVERSIONKIND,
		SEMVERVERSIONKIND,
		LATESTVERSIONKIND,
	}
)

Functions

This section is empty.

Types

type Filter

type Filter struct {
	// Specifies the version kind such as semver, regex, or latest
	Kind string `yaml:",omitempty"`
	// Specifies the version pattern according the version kind
	Pattern string `yaml:",omitempty"`
}

Filter defines parameters to apply different kind of version matching based on a list of versions

func (Filter) Init added in v0.22.3

func (f Filter) Init() (Filter, error)

Init returns a new (copy) valid instanciated filter

func (*Filter) Search

func (f *Filter) Search(versions []string) (Version, error)

Search returns a value matching pattern

func (Filter) Validate

func (f Filter) Validate() error

Validate tests if our filter contains valid parameters

type Semver

type Semver struct {
	Constraint string

	FoundVersion Version
	// contains filtered or unexported fields
}

Semver is an interface in front the masterminds/semver used across the updatecli project

func (*Semver) Init

func (s *Semver) Init(versions []string) error

Init creates a new semver object

func (*Semver) Search

func (s *Semver) Search(versions []string) error

Search returns the version matching pattern from a sorted list.

func (*Semver) Sort

func (s *Semver) Sort()

Sort re-order a list of versions with the newest version first

type Version

type Version struct {
	ParsedVersion   string
	OriginalVersion string
}

TODO: Remove this struct once https://github.com/updatecli/updatecli/issues/803 is fixed. Version defines a version from a filter that holds both the original found version and the parsed version (depending on the kind of filter: semantic, text, etc.) Keeping the original found versions is useful when checking for metadata around the version, such as the changelog

func (Version) GetVersion added in v0.30.0

func (v Version) GetVersion() string

TODO: Change the receiver of this function to Filter once https://github.com/updatecli/updatecli/issues/803 is fixed.

Jump to

Keyboard shortcuts

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