resolver

package
v0.12.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ActionsProtocol   = "actions://"
	ContainerProtocol = "container://"
)

Variables

View Source
var (
	ActionsBaseURL   = os.Getenv("ACTIONS_BASE_URL")
	ActionsToken     = cmp.Or(os.Getenv("ACTIONS_TOKEN"), os.Getenv("GITHUB_TOKEN"))
	ActionsUploadURL = os.Getenv("ACTIONS_UPLOAD_URL")
)

Functions

func DenormalizeRef

func DenormalizeRef(in string) string

DenormalizeRef removes the reference prefix.

func NormalizeActionsRef

func NormalizeActionsRef(in string) string

func NormalizeContainerRef

func NormalizeContainerRef(in string) string

Types

type Actions

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

Actions resolves GitHub references.

func NewActions

func NewActions(ctx context.Context) (*Actions, error)

NewActions creates a new resolver for GitHub Actions.

func (*Actions) LatestVersion added in v0.7.0

func (g *Actions) LatestVersion(ctx context.Context, value string) (string, error)

func (*Actions) Resolve

func (g *Actions) Resolve(ctx context.Context, value string) (string, error)

func (*Actions) ResolvedTimestamp added in v0.12.0

func (g *Actions) ResolvedTimestamp(ctx context.Context, value string) (*Timestamp, error)

ResolvedTimestamp reports the most trustworthy known publish or creation time for value, trying sources from most to least trustworthy: a GitHub release's server-set published_at, then an annotated tag's tagger date, then the resolved commit's committer date, then its author date. It returns nil when no time can be determined.

type Container

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

Container resolves Container registry references.

func NewContainer

func NewContainer(ctx context.Context) (*Container, error)

NewContainer creates a new resolver for Container registries.

func (*Container) Resolve

func (g *Container) Resolve(ctx context.Context, value string) (string, error)

func (*Container) ResolvedTimestamp added in v0.12.0

func (g *Container) ResolvedTimestamp(ctx context.Context, value string) (*Timestamp, error)

ResolvedTimestamp reports the image's config "created" time. That value is set by the image builder and is not server-authoritative. Reproducible builds zero it out (or set it to the Unix epoch), which is reported as nil so the caller degrades gracefully.

type DefaultResolver

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

DefaultResolver is the default resolver.

func (*DefaultResolver) LatestVersion added in v0.7.0

func (r *DefaultResolver) LatestVersion(ctx context.Context, ref string) (string, error)

LatestVersion upgrades the ref.

func (*DefaultResolver) Resolve

func (r *DefaultResolver) Resolve(ctx context.Context, ref string) (string, error)

Resolve resolves the ref.

type GitHubRef

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

func ParseActionRef added in v0.2.0

func ParseActionRef(s string) (*GitHubRef, error)

type Option added in v0.12.0

type Option func(*resolverOptions)

Option configures the default resolver.

func WithBakeDelay added in v0.12.0

func WithBakeDelay(d time.Duration) Option

WithBakeDelay sets the minimum age an artifact must have before Resolve will pin it. Zero or negative disables the check.

type Resolver

type Resolver interface {
	// Resolve resolves the given reference, returning the resolved reference or
	// an error. If the provided context is canceled, the resolution is also
	// canceled.
	Resolve(context.Context, string) (string, error)

	// LatestVersion resolves the given reference to the most recent release version,
	// returning the resolved reference or an error. If the provided context is
	// canceled, the resolution is also canceled.
	LatestVersion(context.Context, string) (string, error)
}

Resolver is an interface that resolvers can implement.

func NewDefaultResolver

func NewDefaultResolver(ctx context.Context, opts ...Option) (Resolver, error)

NewDefaultResolver returns the default resolver. Options such as WithBakeDelay customize its behavior.

type Test

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

Test is a test resolver. It accepts a pre-defined list of results and panics if asked to resolve an undefined reference.

func NewTest

func NewTest(data, latest map[string]*TestResult) (*Test, error)

NewTest creates a new test resolver.

func (*Test) LatestVersion added in v0.7.0

func (t *Test) LatestVersion(ctx context.Context, value string) (string, error)

func (*Test) Resolve

func (t *Test) Resolve(ctx context.Context, value string) (string, error)

type TestResult

type TestResult struct {
	Resolved string
	Err      error
}

TestResult represents the result of a resolution. If Err is not nil, Resolved is the empty string.

type Timestamp added in v0.12.0

type Timestamp struct {
	Time   time.Time
	Source string
}

Timestamp is the most trustworthy known publish or creation time for a resolved artifact, along with the source it was derived from (for example "release", "tag", "commit", or "image").

type TimestampResolver added in v0.12.0

type TimestampResolver interface {
	ResolvedTimestamp(ctx context.Context, ref string) (*Timestamp, error)
}

TimestampResolver is an optional capability that a Resolver may implement to report the age of a resolved artifact. It powers the bake delay. Resolvers that cannot determine a time return a nil Timestamp with a nil error, and the caller treats the artifact as passing the bake delay (graceful degradation).

Jump to

Keyboard shortcuts

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