versionresolver

package
v6.9.1 Latest Latest
Warning

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

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

Documentation

Overview

Package versionresolver discovers available container image versions from OCI registries and computes ordered upgrade paths.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidVersion = errors.New("invalid version")

ErrInvalidVersion is returned when a version string cannot be parsed.

View Source
var ErrNoUpgradesAvailable = errors.New("no upgrades available")

ErrNoUpgradesAvailable is returned when no newer versions exist.

View Source
var ErrNoVersionsFound = errors.New("no stable versions found")

ErrNoVersionsFound is returned when no stable versions are available.

View Source
var ErrRegistryAccess = errors.New("failed to access registry")

ErrRegistryAccess is returned when the OCI registry cannot be reached.

Functions

func SortVersions

func SortVersions(versions []Version)

SortVersions sorts versions in ascending order.

Types

type OCIResolver

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

OCIResolver lists tags from OCI-compliant registries using the Distribution API.

func NewOCIResolver

func NewOCIResolver(opts ...remote.Option) *OCIResolver

NewOCIResolver creates a new OCIResolver with optional remote options.

func (*OCIResolver) ListVersions

func (r *OCIResolver) ListVersions(ctx context.Context, imageRef string) ([]Version, error)

ListVersions queries the OCI registry for all tags of the given repository and parses them into Version structs. Unparseable tags are silently skipped.

type Resolver

type Resolver interface {
	// ListVersions returns all parseable version tags for the given image reference.
	// The imageRef should be a repository reference without a tag (e.g., "kindest/node").
	ListVersions(ctx context.Context, imageRef string) ([]Version, error)
}

Resolver discovers available versions from a container image registry.

type UpgradeStep

type UpgradeStep struct {
	Version  Version
	ImageRef string
}

UpgradeStep represents a single step in an upgrade path.

func ComputeUpgradePath

func ComputeUpgradePath(
	ctx context.Context,
	resolver Resolver,
	imageRef string,
	currentTag string,
	suffix string,
) ([]UpgradeStep, error)

ComputeUpgradePath discovers available versions from the registry, filters to stable versions newer than currentTag, and returns an ordered upgrade path. The suffix parameter filters versions by distribution-specific suffix (e.g., "k3s1"). Pass empty string to match only tags without a suffix.

type Version

type Version struct {
	Major      int
	Minor      int
	Patch      int
	PreRelease string
	Suffix     string // distribution-specific suffix, e.g. "k3s1" (without leading dash)
	Original   string // original tag string as found in the registry
}

Version represents a parsed semantic version.

func FilterStable

func FilterStable(versions []Version) []Version

FilterStable returns only stable versions from the input.

func MatchingSuffix

func MatchingSuffix(versions []Version, suffix string) []Version

MatchingSuffix filters versions to those whose suffix shares the same base prefix as the reference. Trailing digits are stripped before comparison, so passing "k3s1" matches "k3s1", "k3s2", etc. When suffix is empty, only versions without a suffix are returned.

func NewerThan

func NewerThan(versions []Version, current Version) []Version

NewerThan returns versions strictly newer than current, sorted ascending.

func ParseTags

func ParseTags(tags []string) []Version

ParseTags parses a list of tag strings into versions, skipping unparseable tags.

func ParseVersion

func ParseVersion(tag string) (Version, error)

ParseVersion parses a version tag string into a Version struct.

func (Version) Equal

func (v Version) Equal(other Version) bool

Equal returns true if v and other have the same major.minor.patch, suffix, and pre-release label.

func (Version) IsStable

func (v Version) IsStable() bool

IsStable returns true if the version has no pre-release component and the original tag does not contain pre-release indicators.

func (Version) Less

func (v Version) Less(other Version) bool

Less returns true if v is strictly less than other. When major.minor.patch are equal, suffixes are compared by extracting the trailing numeric portion (e.g., k3s1 < k3s2) so that K3s patch-level bumps are ordered correctly. Pre-release versions are always less than their stable counterpart (e.g., v1.35.1-rc.1 < v1.35.1).

func (Version) String

func (v Version) String() string

String returns the version as "vMAJOR.MINOR.PATCH" with pre-release and suffix if present (e.g., "v1.13.0-beta.1", "v1.35.3-k3s1").

Jump to

Keyboard shortcuts

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