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 ¶
- Variables
- type FSStore
- func (s *FSStore) BeginUpload(ctx context.Context, publicationID string, maxSizeBytes int64) (UploadHandle, error)
- func (s *FSStore) Delete(ctx context.Context, ref string) error
- func (s *FSStore) Finalize(ctx context.Context, uploadID string, expectedSHA256 string) (FinalizedArtifact, error)
- func (s *FSStore) OpenFinalized(ctx context.Context, artifactRef string) (io.ReadCloser, FinalizedArtifact, error)
- func (s *FSStore) SweepExpired(ctx context.Context, now time.Time, ...) (SweepResult, error)
- func (s *FSStore) WriteChunk(ctx context.Context, uploadID string, offset int64, r io.Reader) (int64, error)
- type FinalizedArtifact
- type Store
- type SweepResult
- type UploadHandle
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
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.
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 ¶
SweepResult summarizes expired partial uploads and finalized artifacts removed.