updatepolicy

package
v0.19.1069 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package updatepolicy implements the semver-based tag selection used by image-type component builds when the user has set a `update_policy` constraint.

The runner is the single owner of this code path. ctl-api stores and passes the policy string through unchanged; the runner lists tags from the user's source registry, filters/sorts them with this package, and resolves the selected tag to a manifest digest the same way it would for a literal tag.

The package is intentionally tiny and pure: it takes a list of tag strings and a Masterminds-compatible semver constraint, and returns the highest tag that parses as a valid semver and satisfies the constraint. Tags that do not parse as semver (e.g. "latest", "stable", "main") are silently skipped. A constraint that matches zero parseable tags returns ErrNoMatchingTag so the caller can fail the build loudly.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoMatchingTag = errors.New("no tags in the source registry match the update_policy constraint")

ErrNoMatchingTag is returned when zero tags in the input list parse as semver and satisfy the constraint. Callers should treat this as a build failure: the user's constraint doesn't match anything in the registry.

Functions

func SelectHighestMatching

func SelectHighestMatching(tags []string, constraint string) (string, error)

SelectHighestMatching returns the tag from tags that:

  • parses as a valid semver version, and
  • satisfies constraint (a Masterminds-compatible constraint string),

preferring the highest-precedence semver among the matches.

Tags that do not parse as semver are silently skipped (e.g. "latest", "stable", "main"). Returns ErrNoMatchingTag when zero tags match.

The returned string is the original tag as it appeared in the input list, preserving any leading "v" or other formatting the registry used (e.g. input "v1.25.5" → returned "v1.25.5", not "1.25.5").

func Validate

func Validate(constraint string) error

Validate reports whether constraint is a syntactically valid Masterminds-semver constraint (e.g. "~1.25.0", "^2", ">=1.0.0,<2.0.0"). Used at the API boundary to reject malformed user input before we ever reach the runner.

Types

This section is empty.

Jump to

Keyboard shortcuts

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