imageresolver

package
v0.0.16 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AvailabilityChecker added in v0.0.14

type AvailabilityChecker interface {
	CheckAvailability(context.Context, string, ...ResolveOption) error
}

AvailabilityChecker always contacts the registry, including for digest refs. It must not use Resolve's digest fast path or its successful-resolution cache.

type AvailabilityError added in v0.0.14

type AvailabilityError struct{ Reason string }

AvailabilityError deliberately excludes registry response bodies, URLs with credentials and authentication challenges from user-visible errors.

func (*AvailabilityError) Error added in v0.0.14

func (e *AvailabilityError) Error() string

type DigestResolver

type DigestResolver interface {
	// Resolve resolves an image reference (tag or digest) to its manifest digest.
	// For tag-based refs, it checks the cache first, then queries the registry
	// via HTTP HEAD on cache miss. For digest-based refs (@sha256:...), it
	// extracts and returns the digest directly.
	// Use WithPullSecrets to provide registry credentials for private images.
	Resolve(ctx context.Context, imageRef string, opts ...ResolveOption) (string, error)

	// ResolveConfigDigest resolves an image reference to its config digest
	// (the "image ID" shown by docker inspect / docker images --no-trunc).
	// Unlike manifest digests, the config digest is stable across re-pushes
	// and across registries when the image layers are identical.
	// This requires fetching the manifest body (one GET), not just a HEAD.
	// Use WithPullSecrets to provide registry credentials for private images.
	ResolveConfigDigest(ctx context.Context, imageRef string, opts ...ResolveOption) (string, error)

	// DigestFromStatus extracts the digest from pod status fields and caches
	// the image→digest mapping for future Resolve calls. This is a pure
	// local operation with no network calls.
	//   image:   the image name as reported by kubelet (e.g. "registry/repo:tag")
	//   imageID: the imageID as reported by kubelet (e.g. "registry/repo@sha256:abc...")
	DigestFromStatus(image, imageID string) (string, error)
}

DigestResolver resolves container image references to their content digests.

type ResolveOption

type ResolveOption func(*resolveOptions)

ResolveOption configures a Resolve call.

func WithCredentials added in v0.0.14

func WithCredentials(credentials map[string]authn.AuthConfig) ResolveOption

WithCredentials supplies explicit request credentials, retaining default registry authentication as fallback for other images in the same template.

func WithKeychain added in v0.0.14

func WithKeychain(k authn.Keychain) ResolveOption

WithKeychain supplies request-scoped credentials without persisting them.

func WithPullSecrets

func WithPullSecrets(namespace string, secrets []corev1.LocalObjectReference) ResolveOption

WithPullSecrets provides imagePullSecrets context for authenticating against private registries. The resolver reads the referenced Secrets from the given namespace to build registry credentials.

type Resolver

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

Resolver implements DigestResolver with a TTL-based in-memory cache.

func NewResolver

func NewResolver(k8sClient client.Reader, ttl time.Duration) *Resolver

NewResolver creates a new Resolver.

  • k8sClient: used to read imagePullSecrets from namespaces (may be nil if all registries are public).
  • ttl: cache duration for resolved digests (e.g. 3 days).

func (*Resolver) CheckAvailability added in v0.0.14

func (r *Resolver) CheckAvailability(ctx context.Context, image string, opts ...ResolveOption) error

func (*Resolver) DigestFromStatus

func (r *Resolver) DigestFromStatus(image, imageID string) (string, error)

func (*Resolver) Resolve

func (r *Resolver) Resolve(ctx context.Context, imageRef string, opts ...ResolveOption) (string, error)

func (*Resolver) ResolveConfigDigest

func (r *Resolver) ResolveConfigDigest(ctx context.Context, imageRef string, opts ...ResolveOption) (string, error)

ResolveConfigDigest resolves an image reference to its config digest. The config digest is stable across re-pushes and across registries when image layers are identical (equivalent to `docker inspect --format '{{.Id}}'`). Results are cached separately from manifest digests.

Jump to

Keyboard shortcuts

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