v1.7.13 Latest Latest

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

Go to latest
Published: Jan 31, 2024 License: Apache-2.0 Imports: 10 Imported by: 3,160




View Source
const (
	// RuntimeLinuxV1 is the legacy linux runtime
	RuntimeLinuxV1 = "io.containerd.runtime.v1.linux"
	// RuntimeRuncV1 is the runc runtime that supports a single container
	RuntimeRuncV1 = "io.containerd.runc.v1"
	// RuntimeRuncV2 is the runc runtime that supports multiple containers per shim
	RuntimeRuncV2      = "io.containerd.runc.v2"
	DeprecationsPlugin = "deprecations"


View Source
var (
	// ErrNoType is returned when no type is specified
	ErrNoType = errors.New("plugin: no type")
	// ErrNoPluginID is returned when no id is specified
	ErrNoPluginID = errors.New("plugin: no id")
	// ErrIDRegistered is returned when a duplicate id is already registered
	ErrIDRegistered = errors.New("plugin: id already registered")
	// ErrSkipPlugin is used when a plugin is not initialized and should not be loaded,
	// this allows the plugin loader differentiate between a plugin which is configured
	// not to load and one that fails to load.
	ErrSkipPlugin = errors.New("skip plugin")

	// ErrInvalidRequires will be thrown if the requirements for a plugin are
	// defined in an invalid manner.
	ErrInvalidRequires = errors.New("invalid requires")


func IsSkipPlugin

func IsSkipPlugin(err error) bool

IsSkipPlugin returns true if the error is skipping the plugin

func Load

func Load(path string) (count int, err error)

Load loads all plugins at the provided path into containerd

func Register

func Register(r *Registration)

Register allows plugins to register


type DisableFilter added in v1.3.0

type DisableFilter func(r *Registration) bool

DisableFilter filters out disabled plugins

type InitContext

type InitContext struct {
	Context           context.Context
	Root              string
	State             string
	Config            interface{}
	Address           string
	TTRPCAddress      string
	RegisterReadiness func() func()

	// deprecated: will be removed in 2.0, use plugin.EventType
	Events *exchange.Exchange

	Meta *Meta // plugins can fill in metadata at init.
	// contains filtered or unexported fields

InitContext is used for plugin initialization

func NewContext

func NewContext(ctx context.Context, r *Registration, plugins *Set, root, state string) *InitContext

NewContext returns a new plugin InitContext

func (*InitContext) Get

func (i *InitContext) Get(t Type) (interface{}, error)

Get returns the first plugin by its type

func (*InitContext) GetAll

func (i *InitContext) GetAll() []*Plugin

GetAll plugins in the set

func (*InitContext) GetByID added in v1.6.0

func (i *InitContext) GetByID(t Type, id string) (interface{}, error)

GetByID returns the plugin of the given type and ID

func (*InitContext) GetByType

func (i *InitContext) GetByType(t Type) (map[string]*Plugin, error)

GetByType returns all plugins with the specific type.

func (*InitContext) Plugins added in v1.6.0

func (i *InitContext) Plugins() *Set

Plugins returns plugin set

type Meta

type Meta struct {
	Platforms    []ocispec.Platform // platforms supported by plugin
	Exports      map[string]string  // values exported by plugin
	Capabilities []string           // feature switches for plugin

Meta contains information gathered from the registration and initialization process.

type Plugin

type Plugin struct {
	Registration *Registration // registration, as initialized
	Config       interface{}   // config, as initialized
	Meta         *Meta
	// contains filtered or unexported fields

Plugin represents an initialized plugin, used with an init context.

func (*Plugin) Err

func (p *Plugin) Err() error

Err returns the errors during initialization. returns nil if not error was encountered

func (*Plugin) Instance

func (p *Plugin) Instance() (interface{}, error)

Instance returns the instance and any initialization error of the plugin

type Registration

type Registration struct {
	// Type of the plugin
	Type Type
	// ID of the plugin
	ID string
	// Config specific to the plugin
	Config interface{}
	// Requires is a list of plugins that the registered plugin requires to be available
	Requires []Type

	// InitFn is called when initializing a plugin. The registration and
	// context are passed in. The init function may modify the registration to
	// add exports, capabilities and platform support declarations.
	InitFn func(*InitContext) (interface{}, error)
	// Disable the plugin from loading
	Disable bool

Registration contains information for registering a plugin

func Graph

func Graph(filter DisableFilter) (ordered []*Registration)

Graph returns an ordered list of registered plugins for initialization. Plugins in disableList specified by id will be disabled.

func (*Registration) Init

func (r *Registration) Init(ic *InitContext) *Plugin

Init the registered plugin

func (*Registration) URI

func (r *Registration) URI() string

URI returns the full plugin URI

type Set

type Set struct {
	// contains filtered or unexported fields

Set defines a plugin collection, used with InitContext.

This maintains ordering and unique indexing over the set.

After iteratively instantiating plugins, this set should represent, the ordered, initialization set of plugins for a containerd instance.

func NewPluginSet

func NewPluginSet() *Set

NewPluginSet returns an initialized plugin set

func (*Set) Add

func (ps *Set) Add(p *Plugin) error

Add a plugin to the set

func (*Set) Get

func (ps *Set) Get(t Type) (interface{}, error)

Get returns the first plugin by its type

func (*Set) GetAll added in v1.6.0

func (ps *Set) GetAll() []*Plugin

GetAll returns all initialized plugins

func (*Set) GetByID added in v1.6.25

func (ps *Set) GetByID(t Type, id string) (*Plugin, error)

GetByID returns the plugin of the given type and ID

type Type

type Type string

Type is the type of the plugin

const (
	// InternalPlugin implements an internal plugin to containerd
	InternalPlugin Type = "io.containerd.internal.v1"
	// RuntimePlugin implements a runtime
	RuntimePlugin Type = "io.containerd.runtime.v1"
	// RuntimePluginV2 implements a runtime v2
	RuntimePluginV2 Type = "io.containerd.runtime.v2"
	// ServicePlugin implements a internal service
	ServicePlugin Type = "io.containerd.service.v1"
	// GRPCPlugin implements a grpc service
	GRPCPlugin Type = "io.containerd.grpc.v1"
	// TTRPCPlugin implements a ttrpc shim service
	TTRPCPlugin Type = "io.containerd.ttrpc.v1"
	// SnapshotPlugin implements a snapshotter
	SnapshotPlugin Type = "io.containerd.snapshotter.v1"
	// TaskMonitorPlugin implements a task monitor
	TaskMonitorPlugin Type = "io.containerd.monitor.v1"
	// DiffPlugin implements a differ
	DiffPlugin Type = "io.containerd.differ.v1"
	// MetadataPlugin implements a metadata store
	MetadataPlugin Type = "io.containerd.metadata.v1"
	// ContentPlugin implements a content store
	ContentPlugin Type = "io.containerd.content.v1"
	// GCPlugin implements garbage collection policy
	GCPlugin Type = "io.containerd.gc.v1"
	// EventPlugin implements event handling
	EventPlugin Type = "io.containerd.event.v1"
	// LeasePlugin implements lease manager
	LeasePlugin Type = ""
	// Streaming implements a stream manager
	StreamingPlugin Type = "io.containerd.streaming.v1"
	// TracingProcessorPlugin implements a open telemetry span processor
	TracingProcessorPlugin Type = "io.containerd.tracing.processor.v1"
	// NRIApiPlugin implements the NRI adaptation interface for containerd.
	NRIApiPlugin Type = "io.containerd.nri.v1"
	// TransferPlugin implements a transfer service
	TransferPlugin Type = "io.containerd.transfer.v1"
	// SandboxStorePlugin implements a sandbox store
	SandboxStorePlugin Type = ""
	// SandboxControllerPlugin implements a sandbox controller
	SandboxControllerPlugin Type = "io.containerd.sandbox.controller.v1"
	// WarningPlugin implements a warning service
	WarningPlugin Type = "io.containerd.warning.v1"

func (Type) String

func (t Type) String() string

Jump to

Keyboard shortcuts

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