pluginsource

package
v0.3.0-beta.33 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultMaxCacheBytes int64 = 1 << 30
View Source
const MaxDocumentBytes = 2 << 20

Variables

View Source
var (
	ErrPackageUnavailable = errors.New("marketplace package is unavailable")
	ErrCacheCapacity      = errors.New("marketplace package cache capacity exceeded")
)
View Source
var (
	ErrDocumentTooLarge = errors.New("marketplace_document_too_large")
	ErrNotMarketplace   = errors.New("marketplace_not_a_marketplace")
)
View Source
var ErrInvalidRef = errors.New("marketplace_source_invalid_ref")
View Source
var ErrSourceNameInvalid = errors.New("marketplace_source_name_invalid")
View Source
var ErrSourceNameReserved = errors.New("marketplace_source_name_reserved")
View Source
var ErrSourceOutsideCheckout = errors.New("source_outside_checkout")
View Source
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

func NormalizeRef(value string) (string, error)

NormalizeRef assigns one acquisition identity to equivalent source spellings.

func ValidateName

func ValidateName(name string) error

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 CacheSweepReport struct {
	EvictedCount int
	EvictedBytes int64
}

type Diagnostic

type Diagnostic struct {
	Plugin  string `json:"plugin,omitempty"`
	Code    string `json:"code"`
	Message string `json:"message"`
}

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

func (s *DirectorySource) OpenSnapshot(ctx context.Context, document Document) (*Snapshot, error)

type Document

type Document struct {
	Name, Owner, Path string
	SourceRef         string
	ResolvedRef       string
	DigestSHA256      string
	Plugins           []Plugin
	Diagnostics       []Diagnostic
}

func DecodeDocument

func DecodeDocument(raw []byte) (Document, error)

DecodeDocument tolerates optional metadata drift while validating each plugin's identity and source.

func ReadDirectory

func ReadDirectory(ctx context.Context, root string) (document Document, err error)

ReadDirectory reads a marketplace document from an already acquired checkout or local source.

type GitHubOption

type GitHubOption func(*gitHubOptions)

func WithGitHubBaseURL

func WithGitHubBaseURL(baseURL string) GitHubOption

func WithGitHubHTTPClient

func WithGitHubHTTPClient(client *http.Client) GitHubOption

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) Fetch

func (s *GitHubSource) Fetch(ctx context.Context) (Document, 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
}

func NewGitSource

func NewGitSource(ref string, options ...gitsrc.Option) (*GitSource, error)

func (*GitSource) Fetch

func (s *GitSource) Fetch(ctx context.Context) (document Document, err error)

func (*GitSource) OpenSnapshot

func (s *GitSource) OpenSnapshot(ctx context.Context, document Document, tempDir string) (_ *Snapshot, err error)

type Kind

type Kind string
const (
	SourceRelative Kind = "relative"
	SourceGitHub   Kind = "github"
	SourceHTTPS    Kind = "https"
)

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) Hold

func (c *PackageCache) Hold() func()

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

func (c *PackageCache) Put(ctx context.Context, digest string, source io.Reader) (err error)

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 Plugin

type Plugin struct {
	Name, Description, Version, Author, Homepage, Repository, License, Category, Icon string
	Keywords                                                                          []string
	Source                                                                            PluginSource
}

type PluginSource

type PluginSource struct {
	Kind   Kind
	Ref    string
	Path   string
	GitRef string
}

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.

func (*Resolver) Inspect

func (r *Resolver) Inspect(
	ctx context.Context,
	digest string,
	inspect func(context.Context, string) error,
) (err error)

Inspect lends a verified package tree to the install loader, then removes that private tree.

func (*Resolver) Resolve

func (r *Resolver) Resolve(
	ctx context.Context,
	doc Document,
	snapshot *Snapshot,
	plugin Plugin,
) (record AcquisitionRecord, err error)

Resolve publishes canonical bytes before the caller releases the shared marketplace snapshot.

type Snapshot

type Snapshot struct {
	Root        string
	ResolvedRef string
	// contains filtered or unexported fields
}

func (*Snapshot) Close

func (s *Snapshot) Close() error

type SourceError

type SourceError struct {
	Reason string
	Cause  error
}

func (*SourceError) Error

func (e *SourceError) Error() string

func (*SourceError) Unwrap

func (e *SourceError) Unwrap() []error

type Sources

type Sources struct {
	GitHubOptions []GitHubOption
	GitOptions    []gitsrc.Option
	HTTPClient    *http.Client
	TempDir       string
}

Sources owns public acquisition settings. Configure it before concurrent source refreshes.

func (*Sources) Fetch

func (s *Sources) Fetch(ctx context.Context, ref string) (document Document, err error)

func (*Sources) OpenSnapshot

func (s *Sources) OpenSnapshot(ctx context.Context, document Document) (_ *Snapshot, err error)

OpenSnapshot retains the document's revision for every relative package in a refresh.

Jump to

Keyboard shortcuts

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