Documentation
¶
Overview ¶
Package versionresolver discovers available container image versions from OCI registries and computes ordered upgrade paths.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidVersion = errors.New("invalid version")
ErrInvalidVersion is returned when a version string cannot be parsed.
var ErrNoUpgradesAvailable = errors.New("no upgrades available")
ErrNoUpgradesAvailable is returned when no newer versions exist.
var ErrNoVersionsFound = errors.New("no stable versions found")
ErrNoVersionsFound is returned when no stable versions are available.
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 ¶
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 ¶
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 ¶
FilterStable returns only stable versions from the input.
func MatchingSuffix ¶
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 ParseVersion ¶
ParseVersion parses a version tag string into a Version struct.
func (Version) Equal ¶
Equal returns true if v and other have the same major.minor.patch, suffix, and pre-release label.
func (Version) IsStable ¶
IsStable returns true if the version has no pre-release component and the original tag does not contain pre-release indicators.
func (Version) Less ¶
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).