plugin

package
v1.2.7 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

	// 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")
)

Functions

func IsSkipPlugin

func IsSkipPlugin(err error) bool

IsSkipPlugin returns true if the error is skipping the plugin

func Load

func Load(path string) (err error)

Load loads all plugins at the provided path into containerd

func Register

func Register(r *Registration)

Register allows plugins to register

Types

type InitContext

type InitContext struct {
	Context context.Context
	Root    string
	State   string
	Config  interface{}
	Address string
	Events  *exchange.Exchange

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

InitContext is used for plugin inititalization

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

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

GetByType returns all plugins with the specific type.

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

Registration contains information for registering a plugin

func Graph

func Graph(disableList []string) (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 Service

type Service interface {
	Register(*grpc.Server) error
}

Service allows GRPC services to be registered with the underlying server

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

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"
	// 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"
)

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