Documentation
¶
Index ¶
- Constants
- Variables
- func CapturePackage(ctx context.Context, checkout, relative string, cache *PackageCache) (digest string, err error)
- func NormalizeRef(value string) (string, error)
- func ValidateName(name string) error
- type AcquisitionRecord
- type CacheSweepReport
- type Diagnostic
- type DirectorySource
- type Document
- type GitHubOption
- type GitHubSource
- type GitSource
- type Kind
- type NotMarketplaceError
- type PackageCache
- func (c *PackageCache) Check(ctx context.Context, digest string) (err error)
- func (c *PackageCache) Hold(ctx context.Context) (func(), error)
- func (c *PackageCache) Open(ctx context.Context, digest string) (io.ReadCloser, error)
- func (c *PackageCache) Put(ctx context.Context, digest string, source io.Reader) (err error)
- func (c *PackageCache) Sweep(ctx context.Context, pinned map[string]struct{}) error
- func (c *PackageCache) SweepCurrent(ctx context.Context, ...) (CacheSweepReport, error)
- type Plugin
- type PluginSource
- type Resolver
- func (r *Resolver) Acquire(ctx context.Context, record AcquisitionRecord, expected string) (reader io.ReadCloser, err error)
- func (r *Resolver) Inspect(ctx context.Context, digest string, ...) (err error)
- func (r *Resolver) Resolve(ctx context.Context, doc Document, snapshot *Snapshot, plugin Plugin) (record AcquisitionRecord, err error)
- type Snapshot
- type SourceError
- type Sources
Constants ¶
const DefaultMaxCacheBytes int64 = 1 << 30
const MaxDocumentBytes = 2 << 20
Variables ¶
var ( ErrCacheCapacity = errors.New("marketplace package cache capacity exceeded") )
var ( ErrDocumentTooLarge = errors.New("marketplace_document_too_large") ErrNotMarketplace = errors.New("marketplace_not_a_marketplace") )
var ErrInvalidRef = errors.New("marketplace_source_invalid_ref")
var ErrSourceNameInvalid = errors.New("marketplace_source_name_invalid")
var ErrSourceNameReserved = errors.New("marketplace_source_name_reserved")
var ErrSourceOutsideCheckout = errors.New("source_outside_checkout")
var ErrSourceUnreachable = errors.New("source_unreachable")
Functions ¶
func CapturePackage ¶
func CapturePackage(ctx context.Context, checkout, relative string, cache *PackageCache) (digest string, err error)
CapturePackage commits a confined package's canonical bytes before its checkout can be released.
func NormalizeRef ¶
NormalizeRef assigns one acquisition identity to equivalent source spellings.
func ValidateName ¶
Types ¶
type AcquisitionRecord ¶
type AcquisitionRecord struct {
SourceRef string `json:"source_ref"`
EntryID string `json:"entry_id"`
ResolvedRef string `json:"resolved_ref"`
PackagePath string `json:"package_path"`
DigestSHA256 string `json:"digest_sha256"`
Version string `json:"version"`
Layout string `json:"layout"`
}
AcquisitionRecord contains source identity and immutable package evidence, never a temporary path.
type CacheSweepReport ¶
type Diagnostic ¶
type DirectorySource ¶
type DirectorySource struct {
// contains filtered or unexported fields
}
func NewDirectorySource ¶
func NewDirectorySource(ref string) (*DirectorySource, error)
func (*DirectorySource) Fetch ¶
func (s *DirectorySource) Fetch(ctx context.Context) (Document, error)
func (*DirectorySource) OpenSnapshot ¶
type Document ¶
type Document struct {
Name, Owner, Path string
SourceRef string
ResolvedRef string
DigestSHA256 string
Plugins []Plugin
Diagnostics []Diagnostic
}
func DecodeDocument ¶
DecodeDocument tolerates optional metadata drift while validating each plugin's identity and source.
type GitHubOption ¶
type GitHubOption func(*gitHubOptions)
func WithGitHubBaseURL ¶
func WithGitHubBaseURL(baseURL string) GitHubOption
func WithGitHubHTTPClient ¶
func WithGitHubHTTPClient(client *http.Client) GitHubOption
func WithGitHubNow ¶
func WithGitHubNow(now func() time.Time) GitHubOption
WithGitHubNow injects the clock used for upstream quota deadlines.
type GitHubSource ¶
type GitHubSource struct {
// contains filtered or unexported fields
}
func NewGitHubSource ¶
func NewGitHubSource(ref string, options ...GitHubOption) (*GitHubSource, error)
func (*GitHubSource) Close ¶
func (s *GitHubSource) Close() error
func (*GitHubSource) OpenSnapshot ¶
func (s *GitHubSource) OpenSnapshot(ctx context.Context, document Document, tempDir string) (_ *Snapshot, err error)
OpenSnapshot acquires the document's exact repository revision once for all relative plugins.
type GitSource ¶
type GitSource struct {
// contains filtered or unexported fields
}
type NotMarketplaceError ¶
type NotMarketplaceError struct {
Checked []string
}
func (*NotMarketplaceError) Error ¶
func (e *NotMarketplaceError) Error() string
func (*NotMarketplaceError) Unwrap ¶
func (e *NotMarketplaceError) Unwrap() error
type PackageCache ¶
type PackageCache struct {
Root string
// Zero selects the 1 GiB default; Sweep applies the aggregate budget at refresh commit.
MaxBytes int64
// contains filtered or unexported fields
}
PackageCache owns immutable blobs; Root and MaxBytes must not change during operations.
func (*PackageCache) Check ¶
func (c *PackageCache) Check(ctx context.Context, digest string) (err error)
Check verifies availability, reusing a digest only while held-file change metadata matches. Open independently hashes every blob before returning installation bytes.
func (*PackageCache) Hold ¶
func (c *PackageCache) Hold(ctx context.Context) (func(), error)
Hold keeps packages available until a refresh or installation publishes its references.
func (*PackageCache) Open ¶
func (c *PackageCache) Open(ctx context.Context, digest string) (io.ReadCloser, error)
Open hashes the held file before transferring the immutable blob's reader to its caller.
func (*PackageCache) Put ¶
Put verifies the stream before publishing one complete blob under its digest.
func (*PackageCache) Sweep ¶
func (c *PackageCache) Sweep(ctx context.Context, pinned map[string]struct{}) error
Sweep preserves pinned blobs and evicts unreferenced blobs oldest-first to the configured budget.
func (*PackageCache) SweepCurrent ¶
func (c *PackageCache) SweepCurrent( ctx context.Context, loadPins func(context.Context) (map[string]struct{}, error), ) (CacheSweepReport, error)
SweepCurrent reads references after in-flight acquisitions and publications release their holds.
type Resolver ¶
type Resolver struct {
Cache *PackageCache
Sources Sources
}
func (*Resolver) Acquire ¶
func (r *Resolver) Acquire( ctx context.Context, record AcquisitionRecord, expected string, ) (reader io.ReadCloser, err error)
Acquire verifies approval before I/O and publishes live bytes only when they match the listing.
type SourceError ¶
func (*SourceError) Error ¶
func (e *SourceError) Error() string
func (*SourceError) Unwrap ¶
func (e *SourceError) Unwrap() []error