registrystaging

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package registrystaging implements durable, atomic staging for OCI/Docker archive uploads prior to queued registry publication.

Artifacts are never stored in Postgres rows or unconfigured ephemeral /tmp directories. Partial uploads remain isolated under an incoming staging prefix until Finalize validates size and SHA-256 checksum, fsyncs the artifact, and atomically renames it into an immutable finalized path.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidConfig indicates an invalid staging store configuration.
	ErrInvalidConfig = errors.New("invalid staging store configuration")
	// ErrInvalidReference indicates a malformed or unsafe upload/artifact reference.
	ErrInvalidReference = errors.New("invalid staging reference")
	// ErrUploadNotFound indicates the in-progress upload does not exist.
	ErrUploadNotFound = errors.New("staging upload not found")
	// ErrArtifactNotFound indicates no finalized immutable artifact exists for the reference.
	ErrArtifactNotFound = errors.New("finalized staging artifact not found")
	// ErrArtifactTooLarge indicates an upload exceeded its configured byte budget.
	ErrArtifactTooLarge = errors.New("staging artifact exceeds size limit")
	// ErrEmptyArtifact indicates an upload has zero bytes at finalization.
	ErrEmptyArtifact = errors.New("staging artifact is empty")
	// ErrChecksumMismatch indicates a finalized artifact's SHA-256 did not match expected.
	ErrChecksumMismatch = errors.New("staging artifact sha256 checksum mismatch")
	// ErrInvalidOffset indicates a chunk write offset did not match current upload length.
	ErrInvalidOffset = errors.New("staging chunk offset mismatch")
)

Functions

This section is empty.

Types

type FSStore

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

FSStore implements Store on an explicit durable filesystem/PV staging root.

func NewFSStore

func NewFSStore(root string) (*FSStore, error)

NewFSStore initializes an FSStore backed by root. root must be an explicit non-empty directory path and must not be bare /tmp.

func (*FSStore) BeginUpload

func (s *FSStore) BeginUpload(ctx context.Context, publicationID string, maxSizeBytes int64) (UploadHandle, error)

BeginUpload allocates an isolated incoming upload slot for publicationID.

func (*FSStore) Delete

func (s *FSStore) Delete(ctx context.Context, ref string) error

Delete removes either a finalized artifact (by ArtifactRef) or an in-progress upload (by uploadID).

func (*FSStore) Finalize

func (s *FSStore) Finalize(ctx context.Context, uploadID string, expectedSHA256 string) (FinalizedArtifact, error)

Finalize verifies size and SHA-256 of an in-progress upload, fsyncs it, and atomically moves it into the immutable finalized directory.

func (*FSStore) OpenFinalized

func (s *FSStore) OpenFinalized(ctx context.Context, artifactRef string) (io.ReadCloser, FinalizedArtifact, error)

OpenFinalized opens an immutable finalized artifact by ArtifactRef. Unfinalized uploads or invalid paths are never opened.

func (*FSStore) SweepExpired

func (s *FSStore) SweepExpired(ctx context.Context, now time.Time, maxUploadAge, maxFinalizedAge time.Duration) (SweepResult, error)

SweepExpired removes interrupted uploads older than maxUploadAge and finalized artifacts older than maxFinalizedAge relative to now.

func (*FSStore) WriteChunk

func (s *FSStore) WriteChunk(ctx context.Context, uploadID string, offset int64, r io.Reader) (int64, error)

WriteChunk appends bytes from r at offset into an in-progress upload while enforcing the upload's byte budget.

type FinalizedArtifact

type FinalizedArtifact struct {
	ArtifactRef   string    `json:"artifact_ref"`
	PublicationID string    `json:"publication_id"`
	SHA256        string    `json:"sha256"`
	SizeBytes     int64     `json:"size_bytes"`
	FinalizedAt   time.Time `json:"finalized_at"`
}

FinalizedArtifact describes an immutable finalized staged archive ready for durable queue acceptance and helper consumption.

type Store

type Store interface {
	BeginUpload(ctx context.Context, publicationID string, maxSizeBytes int64) (UploadHandle, error)
	WriteChunk(ctx context.Context, uploadID string, offset int64, r io.Reader) (int64, error)
	Finalize(ctx context.Context, uploadID string, expectedSHA256 string) (FinalizedArtifact, error)
	OpenFinalized(ctx context.Context, artifactRef string) (io.ReadCloser, FinalizedArtifact, error)
	Delete(ctx context.Context, ref string) error
	SweepExpired(ctx context.Context, now time.Time, maxUploadAge, maxFinalizedAge time.Duration) (SweepResult, error)
}

Store persists staged image archives durably across Pod restarts.

type SweepResult

type SweepResult struct {
	ExpiredUploads   int
	ExpiredFinalized int
}

SweepResult summarizes expired partial uploads and finalized artifacts removed.

type UploadHandle

type UploadHandle struct {
	UploadID      string    `json:"upload_id"`
	PublicationID string    `json:"publication_id"`
	MaxSizeBytes  int64     `json:"max_size_bytes"`
	CreatedAt     time.Time `json:"created_at"`
}

UploadHandle identifies an in-progress staged upload before finalization.

Jump to

Keyboard shortcuts

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