registry

package
v0.26.2 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package registry provides OCI registry integration for resolving base image configuration (env, platform, digest) via containers/image.

Index

Constants

This section is empty.

Variables

View Source
var NewDefaultResolver func() ImageResolver

NewDefaultResolver creates the default ImageResolver for the platform. When built with containers_image_* build tags, this uses go.podman.io/image/v5. Without build tags, this returns nil (slow checks won't be available).

Functions

func RegistryResolverID

func RegistryResolverID() string

RegistryResolverID is the resolver ID for registry-based image resolution.

Types

type AsyncImageResolver

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

AsyncImageResolver adapts an ImageResolver to the async.Resolver interface with retry logic per the error contract.

func NewAsyncImageResolver

func NewAsyncImageResolver(inner ImageResolver) *AsyncImageResolver

NewAsyncImageResolver creates a new async resolver adapter.

func (*AsyncImageResolver) ID

func (r *AsyncImageResolver) ID() string

ID returns the resolver identifier.

func (*AsyncImageResolver) Resolve

func (r *AsyncImageResolver) Resolve(ctx context.Context, data any) (any, error)

Resolve executes the image resolution with retry logic.

Retry policy per error type:

  • PlatformMismatchError: no retry, returns partial config + error (becomes a violation)
  • NotFoundError: no retry (permanent)
  • AuthError: retry once after backoff
  • NetworkError / other: retry with exponential backoff (up to 3 total attempts)

type AuthError

type AuthError struct{ Err error }

AuthError indicates authentication/authorization failure.

func (*AuthError) Error

func (e *AuthError) Error() string

func (*AuthError) SkipReason

func (e *AuthError) SkipReason() async.SkipReason

func (*AuthError) Unwrap

func (e *AuthError) Unwrap() error

type ImageConfig

type ImageConfig struct {
	// Env is the image's environment variables (KEY=VALUE parsed to map).
	Env map[string]string

	// OS is the image's target OS (e.g., "linux").
	OS string

	// Arch is the image's target architecture (e.g., "amd64").
	Arch string

	// Variant is the image's architecture variant (e.g., "v8").
	Variant string

	// Digest is the resolved manifest digest.
	Digest string

	// HasHealthcheck is true if the image defines a HEALTHCHECK (CMD or CMD-SHELL).
	// False if HEALTHCHECK is NONE or absent.
	HasHealthcheck bool

	// WorkingDir is the image's configured working directory (from WORKDIR).
	// Empty string means no explicit WORKDIR was set (default is /).
	WorkingDir string
}

ImageConfig holds resolved image metadata.

type ImageResolver

type ImageResolver interface {
	// ResolveConfig resolves image config (env + resolved digest/platform)
	// for the given ref and platform (e.g., "linux/amd64").
	//
	// Error contract:
	//   - AuthError: 401/403, missing/expired creds
	//   - NetworkError: transient network failure
	//   - NotFoundError: ref/tag/manifest not found
	//   - PlatformMismatchError: image exists but no manifest matches platform
	ResolveConfig(ctx context.Context, ref string, platform string) (ImageConfig, error)
}

ImageResolver resolves image configuration from a registry.

type NetworkError

type NetworkError struct{ Err error }

NetworkError indicates a transient network failure.

func (*NetworkError) Error

func (e *NetworkError) Error() string

func (*NetworkError) SkipReason

func (e *NetworkError) SkipReason() async.SkipReason

func (*NetworkError) Unwrap

func (e *NetworkError) Unwrap() error

type NotFoundError

type NotFoundError struct {
	Ref string
	Err error
}

NotFoundError indicates the ref/tag/manifest was not found.

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

func (*NotFoundError) SkipReason

func (e *NotFoundError) SkipReason() async.SkipReason

func (*NotFoundError) Unwrap

func (e *NotFoundError) Unwrap() error

type PlatformMismatchError

type PlatformMismatchError struct {
	Ref       string
	Requested string
	Available []string
	Err       error
}

PlatformMismatchError indicates the image exists but no manifest matches the requested platform. This is NOT a skip — it becomes a violation.

func (*PlatformMismatchError) Error

func (e *PlatformMismatchError) Error() string

func (*PlatformMismatchError) Unwrap

func (e *PlatformMismatchError) Unwrap() error

type ResolveRequest

type ResolveRequest struct {
	Ref      string
	Platform string
}

ResolveRequest is the typed input for the registry async resolver.

Directories

Path Synopsis
Package testutil provides a deterministic mock OCI registry for testing async checks that resolve image configs from registries.
Package testutil provides a deterministic mock OCI registry for testing async checks that resolve image configs from registries.

Jump to

Keyboard shortcuts

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