plugin

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 19 Imported by: ? 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 plugin is the Go entry point to the ext plugin engine. Hosts use canonical C sessions: linked C with ext_cengine and cgo, or the shared library through purego otherwise. No-cgo hosts require that library at runtime. Guest authoring remains language-native in the default build.

The data model (descriptors, requests, responses, errors, backends) is defined in pkg/ext-go/engine and re-exported here so a program imports this package alone. Engine-only APIs (Host, Streams, Instances, NewProcess and the like) need the C engine build.

Index

Constants

View Source
const (
	APIVersion                = plugin.APIVersion
	AdapterAPIVersion         = plugin.AdapterAPIVersion
	AdapterContractName       = plugin.AdapterContractName
	BoundaryInProcess         = plugin.BoundaryInProcess
	BoundaryProcess           = plugin.BoundaryProcess
	BoundaryConfined          = plugin.BoundaryConfined
	BoundaryRuntime           = plugin.BoundaryRuntime
	BoundaryContainer         = plugin.BoundaryContainer
	BoundaryKernel            = plugin.BoundaryKernel
	DefaultTimeout            = plugin.DefaultTimeout
	MaxFrameBytes             = plugin.MaxFrameBytes
	MaxRetryAfterMilliseconds = plugin.MaxRetryAfterMilliseconds
	StateClosed               = plugin.StateClosed
	StateDraining             = plugin.StateDraining
	StateFailed               = plugin.StateFailed
	StateReady                = plugin.StateReady
)
View Source
const CEngine = true

CEngine reports whether this build runs on the shared C engine.

Variables

View Source
var (
	ErrAmbiguous   = plugin.ErrAmbiguous
	ErrClosed      = plugin.ErrClosed
	ErrDenied      = plugin.ErrDenied
	ErrDraining    = plugin.ErrDraining
	ErrInvalid     = plugin.ErrInvalid
	ErrMismatch    = plugin.ErrMismatch
	ErrNotFound    = plugin.ErrNotFound
	ErrUnsupported = plugin.ErrUnsupported
)

Error classes. They are the same values as the contract package's, so errors.Is works across both packages.

View Source
var (
	AdapterDescriptor      = plugin.AdapterDescriptor
	ValidBoundary          = plugin.ValidBoundary
	CheckRequirements      = plugin.CheckRequirements
	Decode                 = plugin.Decode
	MatchHandshake         = plugin.MatchHandshake
	Method                 = plugin.Method
	NegotiateProtocol      = plugin.NegotiateProtocol
	ParseAdapterInvocation = plugin.ParseAdapterInvocation
	PortablePath           = plugin.PortablePath
	Select                 = plugin.Select
	TreeDigest             = plugin.TreeDigest
	ValidateRequest        = plugin.ValidateRequest
)

Contract helpers, re-exported from pkg/ext-go/engine.

View Source
var ErrPackageExists = errors.New("plugin package already installed")

ErrPackageExists reports an install over an existing package.

View Source
var ErrRegistryExists = errors.New("already registered")

ErrRegistryExists is returned by a GuestRegistry for a contract that is already registered, or a reverse operation that is already routed.

Functions

func ArtifactDigest

func ArtifactDigest(root, path string, tree bool) (string, error)

ArtifactDigest returns the digest of one artifact under root, addressed by a portable relative path, never following symbolic links: the SHA-256 of a file, or for a tree the directory digest of a directory that holds at least one file.

func CheckSchema

func CheckSchema(s schema.Schema, value json.RawMessage) error

func DirectoryDigest

func DirectoryDigest(root string) (string, error)

DirectoryDigest is the digest of every regular file under root.

func NewRegistry

func NewRegistry(identity plugin.Identity) (*author.Registry, error)

NewRegistry returns a typed authoring registry.

func ResolveRoute

func ResolveRoute(hosts, guests []plugin.BackendProfile, bridges []interop.Bridge, w interop.Requirements) (interop.Route, error)

func SHA256

func SHA256(input []byte) [32]byte

SHA256 returns the SHA-256 digest of input.

func StoreDigest

func StoreDigest(root, id string) (string, error)

func TrustRecord

func TrustRecord(path, scope, id, digest string) error

func TrustRevoke

func TrustRevoke(path, scope, id string) error

func TrustStateOf

func TrustStateOf(path, scope, id, digest string) (hosttrust.State, error)

func ValidateSchema

func ValidateSchema(s schema.Schema) error

Types

type AdapterInvocation

type AdapterInvocation = plugin.AdapterInvocation

Data model, re-exported from pkg/ext-go/engine.

type Backend

type Backend = plugin.Backend

Data model, re-exported from pkg/ext-go/engine.

type BackendProfile

type BackendProfile = plugin.BackendProfile

Data model, re-exported from pkg/ext-go/engine.

type Contract

type Contract = plugin.Contract

Data model, re-exported from pkg/ext-go/engine.

type ContractRef

type ContractRef = plugin.ContractRef

Data model, re-exported from pkg/ext-go/engine.

type Descriptor

type Descriptor = plugin.Descriptor

Data model, re-exported from pkg/ext-go/engine.

type Endpoint

type Endpoint = plugin.Endpoint

Data model, re-exported from pkg/ext-go/engine.

type Event

type Event = plugin.Event

Data model, re-exported from pkg/ext-go/engine.

type Guest

type Guest struct{ *plugin.Guest }

Guest serves a descriptor and handler. Destroy is a no-op in this build.

func GuestFromRegistry

func GuestFromRegistry(r *author.Registry, opts author.Options) (*Guest, error)

GuestFromRegistry builds a guest from a registry's descriptor and handlers.

func NewGuest

func NewGuest(d plugin.Descriptor, options plugin.GuestOptions) (*Guest, error)

func (*Guest) Destroy

func (*Guest) Destroy()

Destroy releases the guest. There is nothing native to release in this build.

type GuestOptions

type GuestOptions = plugin.GuestOptions

Data model, re-exported from pkg/ext-go/engine.

type GuestRegistry

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

GuestRegistry routes reverse calls through the canonical C registry.

func NewGuestRegistry

func NewGuestRegistry() *GuestRegistry

func (*GuestRegistry) OpenProcess

func (r *GuestRegistry) OpenProcess(ctx context.Context, d plugin.Descriptor, launch LaunchOptions, options plugin.Options) (*Session, error)

func (*GuestRegistry) Register

func (r *GuestRegistry) Register(ref plugin.ContractRef, s *Session) error

func (*GuestRegistry) Route

func (r *GuestRegistry) Route(from plugin.ContractRef, op string, to plugin.ContractRef, target string) error

func (*GuestRegistry) Unregister

func (r *GuestRegistry) Unregister(ref plugin.ContractRef) error

type Handler

type Handler = plugin.Handler

Data model, re-exported from pkg/ext-go/engine.

type Identity

type Identity = plugin.Identity

Data model, re-exported from pkg/ext-go/engine.

type LaunchOptions

type LaunchOptions struct {
	ProcessOptions
	// Directory is the child's working directory; empty inherits the host's.
	// It must be absolute. The C engine needs a platform with a spawn working
	// directory (macOS, glibc 2.29 or later, Windows).
	Directory string
	// StderrBytes bounds the retained stderr; zero retains 4096 bytes.
	StderrBytes int
}

LaunchOptions starts a reviewed executable the way an installed package is run: like ProcessOptions, but with a working directory, bounded capture of the child's stderr and a scrubbed base environment of PATH. The environment entries are added to it (an entry named PATH replaces it). Executable must be the absolute path of a regular file.

type LayeredPackageStore

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

LayeredPackageStore is the C engine's read-only view of ordered package roots.

func OpenLayeredPackageStore

func OpenLayeredPackageStore(roots []string, limits PackageStoreLimits) (*LayeredPackageStore, error)

func OpenLayeredPackageStoreWithLayout

func OpenLayeredPackageStoreWithLayout(roots []string, limits PackageStoreLimits, layout storelayout.Layout) (*LayeredPackageStore, error)

OpenLayeredPackageStoreWithLayout opens a layered view using the supplied layout.

func (*LayeredPackageStore) Close

func (l *LayeredPackageStore) Close()

func (*LayeredPackageStore) List

func (l *LayeredPackageStore) List() ([]PackageRecord, error)

func (*LayeredPackageStore) ListUnverified

func (l *LayeredPackageStore) ListUnverified() ([]PackageRecord, []PackageCheck, error)

func (*LayeredPackageStore) Load

func (*LayeredPackageStore) Roots

func (l *LayeredPackageStore) Roots() []string

func (*LayeredPackageStore) Verify

func (l *LayeredPackageStore) Verify() ([]PackageCheck, error)

type Observer

type Observer = plugin.Observer

Data model, re-exported from pkg/ext-go/engine.

type Operation

type Operation = plugin.Operation

Data model, re-exported from pkg/ext-go/engine.

type Options

type Options = plugin.Options

Data model, re-exported from pkg/ext-go/engine.

type PackageCheck

type PackageCheck struct {
	ID        string
	Directory string
	Layer     int
	Err       error
}

PackageCheck reports whether an entry below a package root verifies.

type PackageEntrypoint

type PackageEntrypoint struct {
	Name     string `json:"name"`
	Artifact string `json:"artifact"`
	Path     string `json:"path"`
	Digest   string `json:"digest"`
}

PackageEntrypoint is the verified executable selected by contract and protocol.

type PackageRecord

type PackageRecord struct {
	ID        string
	Directory string
	Layer     int
	Manifest  []byte
}

PackageRecord identifies a verified package, its layer and its manifest bytes.

type PackageStore

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

PackageStore delegates storage, verification and lifecycle to the shared C engine.

func OpenPackageStore

func OpenPackageStore(root string, limits PackageStoreLimits) (*PackageStore, error)

func OpenPackageStoreWithLayout

func OpenPackageStoreWithLayout(root string, limits PackageStoreLimits, layout storelayout.Layout) (*PackageStore, error)

OpenPackageStoreWithLayout opens the native store with a caller-selected layout.

func (*PackageStore) Close

func (s *PackageStore) Close()

func (*PackageStore) IDs

func (s *PackageStore) IDs() ([]string, error)

func (*PackageStore) Install

func (s *PackageStore) Install(source string, preserve bool) ([]byte, error)

func (*PackageStore) InstallArchive

func (s *PackageStore) InstallArchive(archive, sum, id string, preserve bool) ([]byte, error)

func (*PackageStore) List

func (s *PackageStore) List() ([]PackageRecord, error)

func (*PackageStore) ListUnverified

func (s *PackageStore) ListUnverified() ([]PackageRecord, []PackageCheck, error)

func (*PackageStore) Load

func (s *PackageStore) Load(id string) ([]byte, error)

func (*PackageStore) Receipt

func (s *PackageStore) Receipt(id string) ([]byte, error)

func (*PackageStore) Remove

func (s *PackageStore) Remove(id string) error

func (*PackageStore) Replace

func (s *PackageStore) Replace(source string, preserve bool) ([]byte, error)

func (*PackageStore) ResolveEntrypoint

func (s *PackageStore) ResolveEntrypoint(id, contract, version, protocol, digest string) (PackageEntrypoint, error)

func (*PackageStore) Upgrade

func (s *PackageStore) Upgrade(source string, preserve bool) ([]byte, error)

func (*PackageStore) Verify

func (s *PackageStore) Verify() ([]PackageCheck, error)

type PackageStoreLimits

type PackageStoreLimits struct {
	MaxArtifactBytes int64
	MaxTreeFiles     int
	MaxTreeBytes     int64
	MaxArchiveBytes  int64
}

PackageStoreLimits bounds artifacts, trees and archives; zero selects C defaults.

type ProcessOptions

type ProcessOptions struct {
	Executable             string
	Arguments, Environment []string
}

ProcessOptions launches a reviewed executable directly, without a shell. Environment is explicit and never inherits the embedding process environment.

type RemoteError

type RemoteError = plugin.RemoteError

Data model, re-exported from pkg/ext-go/engine.

type Request

type Request = plugin.Request

Data model, re-exported from pkg/ext-go/engine.

type Requirement

type Requirement = plugin.Requirement

Data model, re-exported from pkg/ext-go/engine.

type Response

type Response = plugin.Response

Data model, re-exported from pkg/ext-go/engine.

type Session

type Session struct{ *native.Session }

Session is the canonical C host reached through the shared-library driver.

func Open

func Open(ctx context.Context, d plugin.Descriptor, options plugin.Options) (*Session, error)

func OpenProcess

func OpenProcess(ctx context.Context, d plugin.Descriptor, launch LaunchOptions, options plugin.Options) (*Session, error)

type State

type State = plugin.State

Data model, re-exported from pkg/ext-go/engine.

Directories

Path Synopsis
Package host opens an installed package as a running plugin and calls it by dotted method name.
Package host opens an installed package as a running plugin and calls it by dotted method name.
commandscope
Package commandscope binds C-owned dependency snapshots to a local shell-call broker.
Package commandscope binds C-owned dependency snapshots to a local shell-call broker.
store
Package store installs, upgrades, lists and removes reviewed packages under a caller-supplied root.
Package store installs, upgrades, lists and removes reviewed packages under a caller-supplied root.
Package packages validates, resolves and verifies ext.io/v1 manifests (packagekit) with the plugin engine: on the shared C engine when built with the ext_cengine tag and cgo, otherwise in pure Go.
Package packages validates, resolves and verifies ext.io/v1 manifests (packagekit) with the plugin engine: on the shared C engine when built with the ext_cengine tag and cgo, otherwise in pure Go.

Jump to

Keyboard shortcuts

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