registry

package
v0.17.0-beta1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NotFoundError = errors.New("image reference not found")

Functions

func DefaultRetryBackoff

func DefaultRetryBackoff() remote.Backoff

DefaultRetryBackoff returns the default retry backoff configuration for weight pushes. It retries 5 times with exponential backoff starting at 2 seconds.

Types

type Client

type Client interface {
	// Read methods
	Inspect(ctx context.Context, imageRef string, platform *Platform) (*ManifestResult, error)
	GetImage(ctx context.Context, imageRef string, platform *Platform) (v1.Image, error)
	Exists(ctx context.Context, imageRef string) (bool, error)

	// GetDescriptor returns the OCI descriptor for an image reference without downloading
	// the full image. This is a lightweight HEAD request useful for building OCI indexes
	// from already-pushed manifests.
	GetDescriptor(ctx context.Context, imageRef string) (v1.Descriptor, error)

	// Write methods for OCI index support
	PushImage(ctx context.Context, ref string, img v1.Image) error
	PushIndex(ctx context.Context, ref string, idx v1.ImageIndex) error

	// WriteLayer pushes a single layer (blob) to a repository with retry and optional progress reporting.
	// This method handles transient failures automatically with exponential backoff.
	// Use WriteLayerOptions to configure progress reporting and retry callbacks.
	WriteLayer(ctx context.Context, opts WriteLayerOptions) error
}

func NewRegistryClient added in v0.15.3

func NewRegistryClient() Client

type ManifestResult

type ManifestResult struct {
	SchemaVersion int64
	MediaType     string
	// Digest is the content-addressable digest of the manifest (sha256:...).
	Digest string

	Manifests []PlatformManifest
	Layers    []string
	Config    string
	Labels    map[string]string
}

func (*ManifestResult) IsIndex

func (m *ManifestResult) IsIndex() bool

func (*ManifestResult) IsSinglePlatform

func (m *ManifestResult) IsSinglePlatform() bool

type Platform

type Platform struct {
	OS           string
	Architecture string
	Variant      string
}

type PlatformManifest

type PlatformManifest struct {
	Digest       string
	MediaType    string
	Size         int64
	OS           string
	Architecture string
	Variant      string
	Annotations  map[string]string
}

type RegistryClient added in v0.15.3

type RegistryClient struct{}

func (*RegistryClient) Exists added in v0.15.3

func (c *RegistryClient) Exists(ctx context.Context, imageRef string) (bool, error)

func (*RegistryClient) GetDescriptor

func (c *RegistryClient) GetDescriptor(ctx context.Context, imageRef string) (v1.Descriptor, error)

GetDescriptor returns the OCI descriptor for an image reference using a HEAD request. This is lightweight — it does not download the full manifest or image layers.

func (*RegistryClient) GetImage added in v0.15.3

func (c *RegistryClient) GetImage(ctx context.Context, imageRef string, platform *Platform) (v1.Image, error)

func (*RegistryClient) Inspect added in v0.15.3

func (c *RegistryClient) Inspect(ctx context.Context, imageRef string, platform *Platform) (*ManifestResult, error)

func (*RegistryClient) PushImage

func (c *RegistryClient) PushImage(ctx context.Context, ref string, img v1.Image) error

PushImage pushes a single image to a registry.

func (*RegistryClient) PushIndex

func (c *RegistryClient) PushIndex(ctx context.Context, ref string, idx v1.ImageIndex) error

PushIndex pushes an OCI Image Index to a registry.

func (*RegistryClient) WriteLayer

func (c *RegistryClient) WriteLayer(ctx context.Context, opts WriteLayerOptions) error

WriteLayer pushes a single layer with retry and optional progress reporting. This implements retry at the application level with callbacks for CLI feedback. Unlike the standard remote.WriteLayer, this implementation performs multipart uploads using Content-Range headers to upload the blob in chunks.

type RetryCallback

type RetryCallback func(event RetryEvent) bool

RetryCallback is called when a retry occurs. Return false to abort retrying.

type RetryConfig

type RetryConfig struct {
	// Backoff configures the exponential backoff for retries.
	// If nil, the default backoff from go-containerregistry is used (3 attempts, 1s initial, 3x factor).
	Backoff *remote.Backoff
	// OnRetry is called when a retry occurs. If nil, no callback is invoked.
	// The callback receives information about the retry attempt.
	OnRetry RetryCallback
}

RetryConfig configures retry behavior for registry operations.

type RetryEvent

type RetryEvent struct {
	// Attempt is the current retry attempt number (1-indexed).
	Attempt int
	// MaxAttempts is the maximum number of retry attempts.
	MaxAttempts int
	// Err is the error that caused the retry.
	Err error
	// NextRetryIn is the duration until the next retry attempt.
	NextRetryIn time.Duration
}

RetryEvent contains information about a retry attempt.

type WriteLayerOptions

type WriteLayerOptions struct {
	// Repo is the repository to push to.
	Repo string
	// Layer is the layer to push.
	Layer v1.Layer
	// ProgressCh receives progress updates. Use a buffered channel to avoid deadlocks.
	// If nil, no progress updates are sent.
	ProgressCh chan<- v1.Update
	// Retry configures retry behavior. If nil, default retry behavior is used
	// (5 attempts with exponential backoff starting at 2 seconds).
	Retry *RetryConfig
}

WriteLayerOptions configures the WriteLayer operation.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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