Documentation
¶
Index ¶
- Constants
- Variables
- func DefaultRetryBackoff() remote.Backoff
- type Client
- type ManifestResult
- type Platform
- type PlatformManifest
- type RegistryClient
- func (c *RegistryClient) Exists(ctx context.Context, imageRef string) (bool, error)
- func (c *RegistryClient) GetDescriptor(ctx context.Context, imageRef string) (v1.Descriptor, error)
- func (c *RegistryClient) GetImage(ctx context.Context, imageRef string, platform *Platform) (v1.Image, error)
- func (c *RegistryClient) Inspect(ctx context.Context, imageRef string, platform *Platform) (*ManifestResult, error)
- func (c *RegistryClient) PushImage(ctx context.Context, ref string, img v1.Image) error
- func (c *RegistryClient) PushIndex(ctx context.Context, ref string, idx v1.ImageIndex) error
- func (c *RegistryClient) WriteLayer(ctx context.Context, opts WriteLayerOptions) error
- type RetryCallback
- type RetryConfig
- type RetryEvent
- type WriteLayerOptions
Constants ¶
const ( // DefaultChunkSize is the size (in bytes) of each chunk in a multipart upload. // This is used as a fallback when the registry does not advertise chunk size // limits via OCI-Chunk-Min-Length / OCI-Chunk-Max-Length headers. // 96 MB stays under common CDN/proxy request body limits while still being // large enough to reduce HTTP round-trips for multi-GB files. DefaultChunkSize = 96 * 1024 * 1024 // 96 MB // DefaultMultipartThreshold is the minimum blob size (in bytes) before using multipart upload. // Blobs smaller than this are uploaded in a single request to avoid multipart overhead. // Set higher than DefaultChunkSize so that blobs that would fit in a single chunk // are uploaded in one request, avoiding unnecessary multipart overhead. DefaultMultipartThreshold = 128 * 1024 * 1024 // 128 MB )
Variables ¶
var NotFoundError = errors.New("image reference not found")
Functions ¶
func DefaultRetryBackoff ¶ added in v0.17.0
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 PlatformManifest ¶
type RegistryClient ¶ added in v0.15.3
type RegistryClient struct {
// contains filtered or unexported fields
}
func (*RegistryClient) GetDescriptor ¶ added in v0.17.0
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) Inspect ¶ added in v0.15.3
func (c *RegistryClient) Inspect(ctx context.Context, imageRef string, platform *Platform) (*ManifestResult, error)
func (*RegistryClient) PushIndex ¶ added in v0.17.0
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 ¶ added in v0.17.0
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 ¶ added in v0.17.0
type RetryCallback func(event RetryEvent) bool
RetryCallback is called when a retry occurs. Return false to abort retrying.
type RetryConfig ¶ added in v0.17.0
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 ¶ added in v0.17.0
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 ¶ added in v0.17.0
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.