Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
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") // ErrPluginInitialized is used when a plugin is already initialized ErrPluginInitialized = errors.New("plugin: already initialized") // ErrPluginNotFound is used when a plugin is looked up but not found ErrPluginNotFound = errors.New("plugin: not found") // ErrPluginMultipleInstances is used when a plugin is expected a single instance but has multiple ErrPluginMultipleInstances = errors.New("plugin: multiple instances") // ErrInvalidRequires will be thrown if the requirements for a plugin are // defined in an invalid manner. ErrInvalidRequires = errors.New("invalid requires") )
Functions ¶
func IsSkipPlugin ¶
IsSkipPlugin returns true if the error is skipping the plugin
Types ¶
type DisableFilter ¶
type DisableFilter func(r *Registration) bool
DisableFilter filters out disabled plugins
type InitContext ¶
type InitContext struct { Context context.Context Properties map[string]string Config interface{} RegisterReadiness func() func() // Meta is metadata plugins can fill in at init Meta *Meta // contains filtered or unexported fields }
InitContext is used for plugin initialization
func NewContext ¶
NewContext returns a new plugin InitContext
func (*InitContext) GetByID ¶
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]interface{}, error)
GetByType returns all plugins with the specific type.
func (*InitContext) GetSingle ¶
func (i *InitContext) GetSingle(t Type) (interface{}, error)
GetSingle returns a plugin instance of the given type when only a single instance of that type is expected. Throws an ErrPluginNotFound if no plugin is found and ErrPluginMultipleInstances when multiple instances are found. Since plugins are not ordered, if multiple instances is suported then GetByType should be used. If only one is expected, then to switch plugins, disable or remove the unused plugins of the same type.
type Meta ¶
type Meta struct { Platforms []imagespec.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.
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) // ConfigMigration allows a plugin to migrate configurations from an older // version to handle plugin renames or moving of features from one plugin // to another in a later version. // The configuration map is keyed off the plugin name and the value // is the configuration for that objects, with the structure defined // for the plugin. No validation is done on the value before performing // the migration. ConfigMigration func(context.Context, int, map[string]interface{}) error }
Registration contains information for registering a plugin
func (Registration) Init ¶
func (r Registration) Init(ic *InitContext) *Plugin
Init the registered plugin
type Registry ¶
type Registry []*Registration
Registry is list of registrations which can be registered to and produce a filtered and ordered output. The Registry itself is immutable and the list will be copied and appeneded to a new registry when new items are registered.
func (Registry) Graph ¶
func (registry Registry) Graph(filter DisableFilter) []Registration
Graph computes the ordered list of registrations based on their dependencies, filtering out any plugins which match the provided filter.
func (Registry) Register ¶
func (registry Registry) Register(r *Registration) Registry
Register adds the registration to a Registry and returns the updated Registry, panicking if registration could not succeed.
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.