Help us shape the future of Go! Take the 2026 Go Developer Survey

plugin

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package plugin is the local plugin store: verified plugin binaries and manifests under <Dir>/plugins/<qualified name>/<version>/ (0500), and <Dir>/plugins.lock recording what was verified at install time. Every Open re-hashes the binary and the manifest against the lock.

Index

Constants

View Source
const OfficialMarketplace = "official"

OfficialMarketplace is the marketplace name whose plugins have bare names.

Variables

View Source
var (
	ErrTampered     = errors.New("plugin_tampered")
	ErrNotInstalled = errors.New("plugin_not_installed")
	// ErrYanked refuses a version its marketplace withdrew (docs/security-model.md).
	ErrYanked = errors.New("plugin_yanked")
)

Functions

func Qualify

func Qualify(marketplace, name string, official bool) string

Qualify returns the store name of a plugin from a marketplace.

func ValidQualified added in v0.5.2

func ValidQualified(s string) bool

ValidQualified reports whether s is a plugin name, bare (official) or MARKETPLACE/name: one an error may quote.

Types

type Installed

type Installed struct {
	LockEntry
	Manifest pluginspec.Manifest
	Binary   string
	Tampered bool
}

Installed is a lock entry with its manifest as read from disk. Tampered is set, and Manifest left empty, when the manifest on disk no longer matches the lock.

type LockEntry

type LockEntry struct {
	Name           string `toml:"name"`
	Version        string `toml:"version"`
	Marketplace    string `toml:"marketplace"`
	BinarySHA256   string `toml:"binary_sha256"`
	ManifestSHA256 string `toml:"manifest_sha256"`
	Official       bool   `toml:"official"`
	// Yanked is set from a refreshed, signature-verified marketplace index
	// that withdrew this version: Open refuses it.
	Yanked bool `toml:"yanked,omitempty"`
}

LockEntry is one installed plugin in plugins.lock. Name is qualified: bare for the official marketplace, "<marketplace>/<name>" otherwise.

func (LockEntry) Bare added in v0.3.0

func (e LockEntry) Bare() string

Bare is the plugin name of e without its marketplace.

type Store

type Store struct{ Dir string }

func (Store) Install

func (s Store) Install(e LockEntry, binary, manifest []byte) error

Install stores a plugin whose binary and manifest have already been verified against the marketplace, after checking them against e. A previously installed version of the same plugin is replaced.

func (Store) Installed

func (s Store) Installed() ([]Installed, error)

Installed lists the lock with each manifest read and checked.

func (Store) MarkYanked added in v0.3.0

func (s Store) MarkYanked(marketplace string, status func(bare, version string) (yanked, known bool)) ([]LockEntry, error)

MarkYanked records, for every installed plugin of marketplace, the yanked status a freshly verified index gives its version. status returns known=false for a version the index does not list: its status is kept. It returns the entries whose status changed.

func (Store) Open

func (s Store) Open(name string) (*os.File, Installed, error)

Open opens an installed plugin's binary and checks, from the opened file itself, that it still hashes to the lock entry; the returned file is positioned at its start and is the one to execute.

func (Store) Remove

func (s Store) Remove(name string) error

Remove uninstalls a plugin by its qualified name.

func (Store) RemoveAll added in v0.2.0

func (s Store) RemoveAll() error

RemoveAll deletes the whole store (a staging store, once its plugin is copied into the real one).

Jump to

Keyboard shortcuts

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