resolver

package
v1.223.0-rc.9 Latest Latest
Warning

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

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

Documentation

Overview

Package resolver defines the datasource resolver registry for the Atmos Version Tracker. A resolver lists candidate versions for a package from a concrete datasource (GitHub tags/releases, OCI registries, the Atmos toolchain, ...) and can pin a version to an immutable digest.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrResolverUnsupported is returned when a datasource has no registered resolver.
	ErrResolverUnsupported = errors.New("version resolver unsupported")
	// ErrNoVersionMatch is returned when no candidate satisfies the desired expression.
	ErrNoVersionMatch = errors.New("no version satisfies constraint")
	// ErrPinUnsupported is returned when a datasource has no immutable digest concept.
	ErrPinUnsupported = errors.New("datasource does not support digest pinning")
	// ErrDuplicateResolver is returned when two resolvers register the same datasource name.
	ErrDuplicateResolver = errors.New("duplicate resolver registration")
	// ErrVersionListingUnsupported is returned when a datasource cannot enumerate versions.
	ErrVersionListingUnsupported = errors.New("datasource cannot list versions")
)

Functions

func AllowsVersion

func AllowsVersion(version string, include, exclude []string, prerelease bool) bool

AllowsVersion reports whether one concrete version passes the include, exclude, and prerelease rules.

func LooksLikeConstraint

func LooksLikeConstraint(version string) bool

LooksLikeConstraint reports whether a desired version uses constraint syntax rather than naming a concrete version.

func Names

func Names() []string

Names returns the sorted registered datasource names.

func Register

func Register(r Resolver)

Register adds a resolver under each of its datasource names. It panics on a duplicate name: registration happens in init() and a duplicate is a programming error.

Types

type Candidate

type Candidate struct {
	// Version is the version string as published by the datasource.
	Version string
	// Digest is the immutable identifier for the version when known up front
	// (git commit SHA for tags, sha256 digest for OCI images).
	Digest string
	// ReleasedAt is the upstream release timestamp when the datasource
	// provides one; nil otherwise. Used for update cooldown checks.
	ReleasedAt *time.Time
	// Prerelease marks versions the datasource labels as prereleases.
	Prerelease bool
}

Candidate is one version a datasource offers for a package.

func Select

func Select(candidates []Candidate, desired string, include, exclude []string, prerelease bool) (Candidate, error)

Select returns the best candidate for the desired version expression after applying include, exclude, and prerelease rules. Desired takes one of three forms: "latest", a SemVer constraint (e.g. "~1.10", ">= 1.2, < 2"), or a concrete version (returned when present in the candidate list). Prerelease candidates are excluded unless prerelease is true. Include and exclude entries are glob or substring patterns matched against candidate versions.

type Request

type Request struct {
	// Package is the datasource-specific package coordinate (e.g. owner/repo).
	Package string
	// Datasource is the canonical datasource key (e.g. github-tags).
	Datasource string
	// Provider carries backend endpoint/auth configuration from version.providers.
	Provider schema.VersionProvider
	// Config is the Atmos configuration.
	Config *schema.AtmosConfiguration
}

Request identifies the package a resolver operates on.

type Resolver

type Resolver interface {
	// Names returns the datasource names this resolver serves.
	Names() []string
	// Versions returns candidate versions for the requested package.
	Versions(ctx context.Context, req *Request) ([]Candidate, error)
	// Pin resolves a version to its immutable digest. Implementations return
	// ErrPinUnsupported when the datasource has no digest concept.
	Pin(ctx context.Context, req *Request, version string) (string, error)
}

Resolver lists and pins versions for one or more datasources.

func Lookup

func Lookup(datasource string) (Resolver, string, bool)

Lookup returns the resolver serving the datasource along with the canonical datasource name, resolving ecosystem aliases (e.g. github -> github-tags).

Directories

Path Synopsis
Package github implements the "github-tags" and "github-releases" datasource resolvers backed by the shared pkg/github client (token chain and rate-limit handling included).
Package github implements the "github-tags" and "github-releases" datasource resolvers backed by the shared pkg/github client (token chain and rate-limit handling included).
Package oci implements the "oci-tags" and "docker-tags" datasource resolvers backed by go-containerregistry: tag listing for version discovery and manifest digests for immutable pinning.
Package oci implements the "oci-tags" and "docker-tags" datasource resolvers backed by go-containerregistry: tag listing for version discovery and manifest digests for immutable pinning.
Package toolchain implements the "toolchain" datasource resolver backed by the Atmos toolchain's Aqua registry.
Package toolchain implements the "toolchain" datasource resolver backed by the Atmos toolchain's Aqua registry.

Jump to

Keyboard shortcuts

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