version

package
v0.78.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: Apache-2.0 Imports: 7 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")
	// ErrNoValidSemVerFound return a error when the versions list is empty
	ErrNoValidSemVerFound error = errors.New("no valid semantic version found")
)
View Source
var (
	// SupportedKind holds a list of supported version kind
	SupportedKind []string = []string{
		REGEXVERSIONKIND,
		SEMVERVERSIONKIND,
		LATESTVERSIONKIND,
	}
)

Functions

This section is empty.

Types

type ErrIncorrectSemVerConstraint added in v0.55.0

type ErrIncorrectSemVerConstraint struct {
	SemVerConstraint string
}

ErrUnsupportedVersionKind returns when the provided combination of version and pattern filter is unsupported

func (*ErrIncorrectSemVerConstraint) Error added in v0.55.0

type ErrNoVersionFoundForPattern added in v0.55.0

type ErrNoVersionFoundForPattern struct {
	Pattern string
}

ErrNoVersionFoundForPattern returns when a given pattern does not find any version

func (*ErrNoVersionFoundForPattern) Error added in v0.55.0

type ErrUnsupportedVersionKind added in v0.55.0

type ErrUnsupportedVersionKind struct {
	Kind string
}

ErrUnsupportedVersionKind returns when the provided version filter is unsupported

func (*ErrUnsupportedVersionKind) Error added in v0.55.0

func (e *ErrUnsupportedVersionKind) Error() string

type ErrUnsupportedVersionKindPattern added in v0.55.0

type ErrUnsupportedVersionKindPattern struct {
	Kind    string
	Pattern string
}

ErrUnsupportedVersionKind returns when the provided combination of version and pattern filter is unsupported

func (*ErrUnsupportedVersionKindPattern) Error added in v0.55.0

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"`
	// strict enforce strict versioning rule. Only used for semantic versioning at this time
	Strict bool `yaml:",omitempty"`
}

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

func (*Filter) GreaterThanPattern added in v0.49.0

func (f *Filter) GreaterThanPattern(version string) (string, error)

GreaterThanPattern returns a pattern that can be used to find newer version

func (Filter) Init added in v0.22.3

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

Init returns a new (copy) valid instantiated filter

func (Filter) IsZero added in v0.37.0

func (f Filter) IsZero() bool

IsZero return true if filter is not initialized

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
	Strict       bool
	// 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