Documentation
¶
Overview ¶
Package providerstore owns content-addressed provider artifact records and, later, their deployment-local publication and reachability.
Index ¶
- Constants
- func CanonicalSourceURLV1(raw string) (string, error)
- func InspectArtifactFile(path string, descriptor ArtifactDescriptor) error
- func NormalizeArchivePath(value string, directory bool) (string, error)
- func PortableArchiveDestinationKey(value string) string
- func PreflightZipCentralDirectory(ctx context.Context, reader io.ReaderAt, size int64) error
- func ValidateArtifactSource(source ArtifactSource, artifact ArtifactDescriptor) error
- func ValidateZipMetadata(header *zip.FileHeader) error
- func VerifyArtifactFile(path string, descriptor ArtifactDescriptor) error
- func VerifyOpenArtifact(file *os.File, descriptor ArtifactDescriptor) error
- type AcquisitionAttempt
- type AcquisitionPolicy
- type AcquisitionProvenance
- type AcquisitionRequest
- type AcquisitionResult
- type ArchiveFormat
- type ArchiveMaterializationEntry
- type ArchiveMaterializationRequest
- type ArchiveMaterializationResult
- type ArchiveSymbolicLinkPolicy
- type ArtifactDescriptor
- type ArtifactSource
- type Store
- func (store Store) AcquireArtifact(ctx context.Context, request AcquisitionRequest) (AcquisitionResult, error)
- func (store Store) AcquisitionAttemptsPath(descriptor ArtifactDescriptor) (string, error)
- func (store Store) BlobPath(digest canonical.Digest) (string, error)
- func (store Store) Exists() (bool, error)
- func (store Store) InspectArtifactPath(descriptor ArtifactDescriptor) (string, error)
- func (store Store) LoadManifest(reference StoreObjectRef) ([]byte, error)
- func (store Store) LoadValidationRecord(reference StoreObjectRef) ([]byte, error)
- func (store Store) ManifestPath(reference StoreObjectRef) (string, error)
- func (store Store) MaterializeArchive(ctx context.Context, request ArchiveMaterializationRequest) (ArchiveMaterializationResult, error)
- func (store Store) NewWorkspace(pattern string) (string, error)
- func (store Store) OpenVerifiedArtifact(descriptor ArtifactDescriptor) (*os.File, error)
- func (store Store) Publish(ctx context.Context, logicalPath string, kind string, reader io.Reader) (ArtifactDescriptor, error)
- func (store Store) PublishExpected(ctx context.Context, expected ArtifactDescriptor, reader io.Reader) (ArtifactDescriptor, error)
- func (store Store) PublishManifest(ctx context.Context, reference StoreObjectRef, content []byte) error
- func (store Store) PublishValidationRecord(ctx context.Context, reference StoreObjectRef, content []byte) error
- func (store Store) Remove() (bool, error)
- func (store Store) RemoveTemporaryEntries() error
- func (store Store) RemoveUnreachable(reachable []StoreObjectRef) error
- func (store Store) RestoreWorkspaceOwners() error
- func (store Store) Root() string
- func (store Store) ValidationRecordPath(reference StoreObjectRef) (string, error)
- func (store Store) VerifyArtifact(descriptor ArtifactDescriptor) error
- func (store Store) VerifyCachedDeb(descriptor ArtifactDescriptor) error
- func (store Store) WithWorkspaceOwnerRestoration() Store
- type StoreObjectRef
Constants ¶
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.
const ( AcquisitionOutcomeCacheHit = "cache-hit" AcquisitionOutcomeNetwork = "network" AcquisitionOutcomeHTTPStatus = "http-status" AcquisitionOutcomeTransport = "transport" AcquisitionOutcomeTimeout = "timeout" AcquisitionOutcomeRedirect = "redirect" AcquisitionOutcomeSizeMismatch = "size-mismatch" AcquisitionOutcomeDigestMismatch = "digest-mismatch" )
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 )
const ( ArchiveEntryKindDirectory = "directory" ArchiveEntryKindRegular = "regular" ArchiveEntryKindSymbolicLink = "symbolic-link" )
const ( BlobKind = "blob" BundleManifestKind = "bundle-manifest" ValidationRecordKind = "validation-record" )
const StoreDirName = "provider-store"
Variables ¶
This section is empty.
Functions ¶
func CanonicalSourceURLV1 ¶
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 ¶
NormalizeArchivePath applies the provider-store archive path policy without touching archive contents. It is shared by bounded archive inventories.
func PortableArchiveDestinationKey ¶
PortableArchiveDestinationKey returns the collision key used for archive destinations after Unicode normalization and case folding.
func PreflightZipCentralDirectory ¶
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 ¶
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 (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) Exists ¶
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 ¶
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) PublishValidationRecord ¶
func (Store) Remove ¶
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 ¶
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 ¶
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) 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 ¶
WithWorkspaceOwnerRestoration scopes descriptor retention to one privileged source operation. Its caller must defer RestoreWorkspaceOwners before work.
type StoreObjectRef ¶
func (StoreObjectRef) Validate ¶
func (reference StoreObjectRef) Validate() error
Source Files
¶
- acquisition.go
- acquisition_network.go
- archive_materialization.go
- archive_materialization_contract.go
- archive_materialization_destination.go
- archive_materialization_mode_unix.go
- archive_materialization_publish_linux.go
- archive_materialization_stage_unix.go
- archive_materialization_sync_unix.go
- archive_materialization_tar.go
- archive_materialization_transaction.go
- archive_materialization_zip.go
- artifact.go
- artifact_verification.go
- ownership.go
- reachability.go
- ref.go
- source_url.go
- store.go
- store_sync_unix.go