Documentation
¶
Overview ¶
Package artifactcache acquires pinned publisher archives into a private, content-addressed cache. The trusted host owns the catalog, consent and paths; never construct a Spec from untrusted renderer or network input.
Index ¶
- Variables
- func SelectSource(ctx context.Context, specs []Spec, options Options) (int, error)
- func Verify(ctx context.Context, name string, spec Spec) error
- type Maintenance
- type Options
- type Policy
- type Progress
- type Result
- type Session
- func (s *Session) Acquire(ctx context.Context, spec Spec, options Options) (Result, error)
- func (s *Session) Close() error
- func (s *Session) Path(spec Spec) (string, error)
- func (s *Session) Prune(ctx context.Context, policy Policy) (Maintenance, error)
- func (s *Session) Touch(spec Spec) error
- func (s *Session) Verify(ctx context.Context, spec Spec) error
- type SessionOptions
- type Spec
Constants ¶
This section is empty.
Variables ¶
var ErrBusy = errors.New("archive cache is in use")
var ErrIntegrity = errors.New("archive integrity check failed")
var ErrInvalid = errors.New("invalid archive acquisition configuration")
Functions ¶
func SelectSource ¶ added in v0.22.15
SelectSource probes a small representative set of trusted catalog entries and returns the source index with the lowest total probe latency. The canonical source remains the safe fallback when no source passes validation.
Types ¶
type Maintenance ¶ added in v0.9.0
type Options ¶
type Options struct {
// Client is a trusted integration hook, primarily for network policy/tests.
// Nil selects a client with a fifteen-minute timeout. HTTPS remains required.
Client *http.Client
// PreferredSource selects the first URL to try. -1 uses the canonical URL.
// Remaining trusted URLs are tried in catalog order after it fails.
PreferredSource int
// OnProgress may stop acquisition by returning an error.
OnProgress func(Progress) error
}
type Policy ¶ added in v0.9.0
Policy is opt-in. Zero disables the corresponding eviction limit. MaxBytes counts verified archive files, not locks or temporary bundles.
type Progress ¶
Progress reports absolute byte counts. Phase is checking, downloading or verifying. Cache validation performs no network request.
type Result ¶
func Acquire ¶
Acquire revalidates cached bytes or downloads and atomically publishes the exact archive. root must be an absolute private directory owned by the host. Concurrent calls share an exclusive cache lease and recheck after waiting. A verified cache entry is never deleted by cancellation. Returned paths must not be used concurrently with maintenance; use Session for protected reads.
type Session ¶ added in v0.9.0
type Session struct {
// contains filtered or unexported fields
}
Session owns an exclusive OS lease until Close. Consumers must keep it open through their last archive read. Methods are used sequentially by the owner. A session is not an authorization boundary; root belongs to the trusted host.
func OpenSession ¶ added in v0.9.0
func (*Session) Prune ¶ added in v0.9.0
Prune only removes recognized regular files under the exclusive lease. It never follows symlinks, unlinks lock files, or examines unrelated subdirectories.