providerstore

package
v0.0.0-...-e84d2fa Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 32 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package providerstore owns content-addressed provider artifact records and, later, their deployment-local publication and reachability.

Index

Constants

View Source
const (
	CoreMaxArtifactMirrors           = 8
	CoreMaxArtifactAttemptsPerMirror = 3
	CoreMaxArtifactAttempts          = 16
	CoreMaxArtifactBytesPerAttempt   = int64(1 << 30)
	CoreMaxArtifactBytesTotal        = int64(4 << 30)
	CoreMaxArtifactElapsed           = 10 * time.Minute
	CoreMaxArtifactRedirects         = 3
)

The acquisition caps are core safety limits. A request may select tighter values, but it cannot raise any of these limits.

View Source
const (
	AcquisitionOutcomeCacheHit       = "cache-hit"
	AcquisitionOutcomeNetwork        = "network"
	AcquisitionOutcomeHTTPStatus     = "http-status"
	AcquisitionOutcomeTransport      = "transport"
	AcquisitionOutcomeTimeout        = "timeout"
	AcquisitionOutcomeRedirect       = "redirect"
	AcquisitionOutcomeSizeMismatch   = "size-mismatch"
	AcquisitionOutcomeDigestMismatch = "digest-mismatch"
)
View Source
const (
	ArchiveFormatTarGz ArchiveFormat = "tar.gz"
	ArchiveFormatZip   ArchiveFormat = "zip"

	ArchiveSymbolicLinkPolicyReject                   ArchiveSymbolicLinkPolicy = "reject"
	ArchiveSymbolicLinkPolicyMaterializeRegularTarget ArchiveSymbolicLinkPolicy = "materialize-regular-target"

	CoreMaxArchiveEntries        = 10_000
	CoreMaxArchiveUnpackedBytes  = 1 << 30
	CoreMaxArchivePathBytes      = 4096
	CoreMaxArchiveComponentBytes = 255
)
View Source
const (
	ArchiveEntryKindDirectory    = "directory"
	ArchiveEntryKindRegular      = "regular"
	ArchiveEntryKindSymbolicLink = "symbolic-link"
)
View Source
const (
	BlobKind             = "blob"
	BundleManifestKind   = "bundle-manifest"
	ValidationRecordKind = "validation-record"
)
View Source
const StoreDirName = "provider-store"

Variables

This section is empty.

Functions

func CanonicalSourceURLV1

func CanonicalSourceURLV1(raw string) (string, error)

CanonicalSourceURLV1 returns the single catalog-and-lock spelling for a credential-free HTTPS source URL. Catalog loading and locked replay share this implementation so their accepted source evidence cannot diverge.

func InspectArtifactFile

func InspectArtifactFile(path string, descriptor ArtifactDescriptor) error

InspectArtifactFile validates a staged artifact's path, type, and size without hashing it. It is used only after the same exact staged file was already verified or published during the current operation.

func NormalizeArchivePath

func NormalizeArchivePath(value string, directory bool) (string, error)

NormalizeArchivePath applies the provider-store archive path policy without touching archive contents. It is shared by bounded archive inventories.

func PortableArchiveDestinationKey

func PortableArchiveDestinationKey(value string) string

PortableArchiveDestinationKey returns the collision key used for archive destinations after Unicode normalization and case folding.

func PreflightZipCentralDirectory

func PreflightZipCentralDirectory(ctx context.Context, reader io.ReaderAt, size int64) error

PreflightZipCentralDirectory bounds ZIP directory parsing before zip.Reader can allocate one File per central-directory record. It counts fixed-size central headers instead of trusting the forgeable EOCD record count.

func ValidateArtifactSource

func ValidateArtifactSource(source ArtifactSource, artifact ArtifactDescriptor) error

ValidateArtifactSource applies the same immutable source and locator checks used by acquisition. Lock decoders use it to reject source evidence that could never have authorized a production acquisition.

func ValidateZipMetadata

func ValidateZipMetadata(header *zip.FileHeader) error

ValidateZipMetadata applies the shared ZIP extra-field safety policy.

func VerifyArtifactFile

func VerifyArtifactFile(path string, descriptor ArtifactDescriptor) error

VerifyArtifactFile validates one regular file against an immutable artifact descriptor. Backends use it for same-filesystem staged links that will be consumed directly by a resolver or materializer.

func VerifyOpenArtifact

func VerifyOpenArtifact(file *os.File, descriptor ArtifactDescriptor) error

VerifyOpenArtifact hashes the exact open file rather than reopening its pathname. It resets the file offset to the start before returning.

Types

type AcquisitionAttempt

type AcquisitionAttempt struct {
	Mirror         string
	Attempt        int
	Outcome        string
	HTTPStatus     int
	ObservedBytes  int64
	ObservedSHA256 canonical.Digest
	ContentLength  int64
	Redirects      int
}

AcquisitionAttempt is the in-memory summary of one failed network attempt. It intentionally contains observed metadata only, never response bytes.

type AcquisitionPolicy

type AcquisitionPolicy struct {
	MaxMirrors         int
	AttemptsPerMirror  int
	MaxAttempts        int
	MaxBytesPerAttempt int64
	MaxBytesTotal      int64
	AttemptTimeout     time.Duration
	TotalTimeout       time.Duration
	MaxRedirects       int
}

AcquisitionPolicy contains the definition-selected limits for one acquisition. Zero policy means DefaultAcquisitionPolicy.

func DefaultAcquisitionPolicy

func DefaultAcquisitionPolicy() AcquisitionPolicy

type AcquisitionProvenance

type AcquisitionProvenance struct {
	OperationID      string
	Outcome          string
	SourceID         string
	SuccessfulMirror string
	// Redirects is the number of sanitized redirect hops followed by the
	// successful attempt. Redirect target locators are deliberately never
	// retained in acquisition provenance.
	Redirects int
	Attempts  []AcquisitionAttempt
}

AcquisitionProvenance is the outcome that a later lock or plan can carry. A cache hit has no successful locator because no locator was contacted.

type AcquisitionRequest

type AcquisitionRequest struct {
	Artifact    ArtifactDescriptor
	Source      ArtifactSource
	Policy      AcquisitionPolicy
	OperationID string
	// contains filtered or unexported fields
}

AcquisitionRequest is the complete immutable input to one acquisition. OperationID is optional; when omitted, the store creates a unique local ID for the durable failure records.

type AcquisitionResult

type AcquisitionResult struct {
	Artifact   ArtifactDescriptor
	Provenance AcquisitionProvenance
}

func AcquireArtifact

func AcquireArtifact(ctx context.Context, store Store, request AcquisitionRequest) (AcquisitionResult, error)

AcquireArtifact is the package-level form for callers that keep the store separate from the request construction.

type ArchiveFormat

type ArchiveFormat string

ArchiveFormat is one of the closed archive formats understood by the provider materializer.

type ArchiveMaterializationEntry

type ArchiveMaterializationEntry struct {
	ArchivePath     string `json:"archive_path"`
	DestinationPath string `json:"destination_path"`
	Kind            string `json:"kind"`
	Size            string `json:"size"`
}

ArchiveMaterializationEntry is one normalized archive member observed by the materializer. ArchivePath is the path in the archive; DestinationPath is its path relative to the published install directory.

type ArchiveMaterializationRequest

type ArchiveMaterializationRequest struct {
	Artifact             ArtifactDescriptor
	Format               ArchiveFormat
	DestinationRoot      string
	InstallDirectory     string
	ArchiveRoot          string
	ExpectedEntryCount   string
	ExpectedUnpackedSize string
	ExecutablePaths      []string
	SymbolicLinkPolicy   ArchiveSymbolicLinkPolicy
}

ArchiveMaterializationRequest is the immutable, definition-selected contract for one offline archive installation. Expected counts and sizes deliberately use the repository's canonical decimal representation.

type ArchiveMaterializationResult

type ArchiveMaterializationResult struct {
	FinalPath            string                        `json:"final_path"`
	ObservedEntryCount   string                        `json:"observed_entry_count"`
	ObservedUnpackedSize string                        `json:"observed_unpacked_size"`
	ObservedEntries      []ArchiveMaterializationEntry `json:"observed_entries"`
}

ArchiveMaterializationResult reports the atomically published destination and the exact inventory observed while parsing the archive.

func MaterializeArchive

func MaterializeArchive(ctx context.Context, store Store, request ArchiveMaterializationRequest) (ArchiveMaterializationResult, error)

MaterializeArchive is the package-level form for callers that keep the store separate from the request construction.

type ArchiveSymbolicLinkPolicy

type ArchiveSymbolicLinkPolicy string

ArchiveSymbolicLinkPolicy controls whether a materializer may accept a symbolic-link archive member. The zero value rejects links. The only supported opt-in resolves an in-tree link whose direct target is a regular archive member and writes an ordinary file at the link path.

type ArtifactDescriptor

type ArtifactDescriptor struct {
	LogicalPath string           `json:"logical_path"`
	Kind        string           `json:"kind"`
	Size        string           `json:"size"`
	SHA256      canonical.Digest `json:"sha256"`
}

func (ArtifactDescriptor) StoreObjectRef

func (descriptor ArtifactDescriptor) StoreObjectRef() (StoreObjectRef, error)

func (ArtifactDescriptor) Validate

func (descriptor ArtifactDescriptor) Validate() error

type ArtifactSource

type ArtifactSource struct {
	ID      string
	SHA256  canonical.Digest
	Mirrors []string
}

ArtifactSource is the bounded, ordered source declaration for one pinned artifact. SHA256 must match Artifact.SHA256; mirrors never carry distinct content identities.

type Store

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

func NewStore

func NewStore(deploymentRoot string) (Store, error)

func (Store) AcquireArtifact

func (store Store) AcquireArtifact(ctx context.Context, request AcquisitionRequest) (AcquisitionResult, error)

AcquireArtifact verifies a pinned artifact from the store's ordered source mirrors. The returned descriptor refers only to bytes already verified and atomically published in the content-addressed store; callers can use OpenVerifiedArtifact to consume those bytes.

func (Store) AcquisitionAttemptsPath

func (store Store) AcquisitionAttemptsPath(descriptor ArtifactDescriptor) (string, error)

AcquisitionAttemptsPath returns the durable failure-record directory for an artifact. It does not create the directory.

func (Store) BlobPath

func (store Store) BlobPath(digest canonical.Digest) (string, error)

func (Store) Exists

func (store Store) Exists() (bool, error)

Exists distinguishes a deliberately absent cache root from a present but malformed provider store. Callers may treat only the former as a cache miss.

func (Store) InspectArtifactPath

func (store Store) InspectArtifactPath(descriptor ArtifactDescriptor) (string, error)

InspectArtifactPath validates the immutable store layout, final file type, and declared size without reading and hashing the file contents.

func (Store) LoadManifest

func (store Store) LoadManifest(reference StoreObjectRef) ([]byte, error)

func (Store) LoadValidationRecord

func (store Store) LoadValidationRecord(reference StoreObjectRef) ([]byte, error)

func (Store) ManifestPath

func (store Store) ManifestPath(reference StoreObjectRef) (string, error)

func (Store) MaterializeArchive

func (store Store) MaterializeArchive(ctx context.Context, request ArchiveMaterializationRequest) (ArchiveMaterializationResult, error)

MaterializeArchive verifies and installs one closed archive without invoking any command or using the network.

func (Store) NewWorkspace

func (store Store) NewWorkspace(pattern string) (string, error)

NewWorkspace creates private same-filesystem scratch beneath the deployment-owned store. Callers can therefore stage immutable blobs with hardlinks instead of copying their bytes.

func (Store) OpenVerifiedArtifact

func (store Store) OpenVerifiedArtifact(descriptor ArtifactDescriptor) (*os.File, error)

OpenVerifiedArtifact opens and hashes one immutable store artifact. The returned descriptor-bound file remains stable if its store path is replaced; callers that parse it should call VerifyOpenArtifact again before closing to detect in-place modification during parsing.

func (Store) Publish

func (store Store) Publish(ctx context.Context, logicalPath string, kind string, reader io.Reader) (ArtifactDescriptor, error)

Publish implements providers.ArtifactSink without importing the provider package. It streams one raw artifact into private storage, then atomically publishes it under its content digest without replacing an existing object.

func (Store) PublishExpected

func (store Store) PublishExpected(ctx context.Context, expected ArtifactDescriptor, reader io.Reader) (ArtifactDescriptor, error)

PublishExpected atomically publishes an artifact only when the streamed bytes match the caller's already-validated descriptor. A mismatch never creates a digest-addressed blob.

func (Store) PublishManifest

func (store Store) PublishManifest(ctx context.Context, reference StoreObjectRef, content []byte) error

func (Store) PublishValidationRecord

func (store Store) PublishValidationRecord(ctx context.Context, reference StoreObjectRef, content []byte) error

func (Store) Remove

func (store Store) Remove() (bool, error)

Remove deletes the complete deployment-owned provider store, including abandoned temporary workspaces. It refuses to follow a replaced or corrupt store path and is absent-safe so clean can be repeated.

func (Store) RemoveTemporaryEntries

func (store Store) RemoveTemporaryEntries() error

RemoveTemporaryEntries empties only the deployment-owned scratch directory. Callers hold the deployment operation lock and establish that no active or recoverable publication can still own these entries.

func (Store) RemoveUnreachable

func (store Store) RemoveUnreachable(reachable []StoreObjectRef) error

RemoveUnreachable removes only recognized immutable objects not present in the supplied closure. Callers hold the deployment operation lock and derive reachable from the selected build lock before invoking this method.

func (Store) RestoreWorkspaceOwners

func (store Store) RestoreWorkspaceOwners() error

RestoreWorkspaceOwners runs after privileged source preparation on success, failure and cancellation, while its operation lock is still held. Only newly created scratch roots are visited; existing application data is not walked.

func (Store) Root

func (store Store) Root() string

func (Store) ValidationRecordPath

func (store Store) ValidationRecordPath(reference StoreObjectRef) (string, error)

func (Store) VerifyArtifact

func (store Store) VerifyArtifact(descriptor ArtifactDescriptor) error

func (Store) VerifyCachedDeb

func (store Store) VerifyCachedDeb(descriptor ArtifactDescriptor) error

VerifyCachedDeb trusts the previous content verification only when the deployment-local blob still has the declared size and exact recorded modification time. A missing or nonmatching stamp causes one full hash and refreshes the derived stamp; a blob-size mismatch is rejected during path inspection. The stamp is cache evidence only: it is not part of artifact or bundle identity and may be deleted safely.

func (Store) WithWorkspaceOwnerRestoration

func (store Store) WithWorkspaceOwnerRestoration() Store

WithWorkspaceOwnerRestoration scopes descriptor retention to one privileged source operation. Its caller must defer RestoreWorkspaceOwners before work.

type StoreObjectRef

type StoreObjectRef struct {
	Kind   string           `json:"kind"`
	Digest canonical.Digest `json:"digest"`
}

func (StoreObjectRef) Validate

func (reference StoreObjectRef) Validate() error

Jump to

Keyboard shortcuts

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