Documentation
¶
Overview ¶
Package install downloads external Marmot plugins from an OCI registry and caches them on disk, where the plugin loader picks them up alongside locally installed plugins.
Index ¶
- Constants
- func CachedPath(cacheDir, registry, name, version string) string
- func EnsureCore(ctx context.Context, opts Options) error
- func EnsurePlugin(ctx context.Context, opts Options, name string) (string, error)
- func Install(ctx context.Context, opts Options, ...) error
- func LoadPlugins(opts Options) error
- type Manifest
- type ManifestPlugin
- type Options
Constants ¶
const ( // ArtifactType identifies a Marmot plugin artifact. ArtifactType = "application/vnd.marmot.plugin.v1" // LayerMediaType is the media type of the gzipped plugin binary layer. LayerMediaType = "application/vnd.marmot.plugin.v1+gzip" )
Media types for Marmot plugin OCI artifacts.
Variables ¶
This section is empty.
Functions ¶
func CachedPath ¶
CachedPath returns the path a plugin binary is cached at: <cacheDir>/<registry>/<name>/<version>/<os>_<arch>/marmot-plugin-<name>.
func EnsureCore ¶
EnsureCore installs every core plugin that is not already cached or shadowed by a locally installed plugin. Failures are logged per plugin and returned aggregated, so an unreachable registry does not have to prevent startup.
func EnsurePlugin ¶
EnsurePlugin installs the named core plugin if it is not already cached, and returns the path to its binary.
func Install ¶
Install pulls a plugin from <registry>/<name> at the given version tag (or digest, when set) and writes its binary for the current platform to dest.
func LoadPlugins ¶
LoadPlugins registers locally installed plugin binaries, then the manifest-pinned version of each core plugin found in the cache. Locally installed plugins load first, so they shadow cached ones.
Cached versions other than the pin are ignored: several Marmot binaries with different embedded manifests can share one cache and each still loads exactly the versions it pins.
Types ¶
type Manifest ¶
type Manifest struct {
// Registry is the OCI registry namespace plugins live under,
// e.g. ghcr.io/marmotdata/plugins. A plugin's repository is
// <registry>/<name>.
Registry string `json:"registry"`
Plugins map[string]ManifestPlugin `json:"plugins"`
}
Manifest describes a set of plugins and the registry they are distributed from.
func CoreManifest ¶
CoreManifest returns the core plugin manifest embedded in this build.
type ManifestPlugin ¶
type ManifestPlugin struct {
Version string `json:"version"`
// Digest is the digest of the plugin's OCI image index for this
// version (sha256:...). When set, the plugin is resolved by digest
// so a re-tagged registry artifact cannot change what runs. When
// empty, the version tag is resolved instead and a warning is
// logged.
Digest string `json:"digest"`
}
ManifestPlugin pins a single plugin.
type Options ¶
type Options struct {
// Registry overrides the manifest's registry namespace, e.g. to
// point at an internal mirror.
Registry string
// CacheDir overrides the plugin cache directory.
CacheDir string
// PlainHTTP allows non-TLS registries (local registries in tests).
PlainHTTP bool
}
Options configures plugin installation.