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") // 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 ¶
IsSkipPlugin returns true if the error is skipping the plugin
Types ¶
type InitContext ¶
type InitContext struct { Context context.Context Root string //如runtime插件 默认为 /var/lib/containerd/io.containerd.runtime.v1.linux State string //如runtime插件 默认为 /run/containerd/io.containerd.runtime.v1.linux Config interface{} // 插件自定义的配置。具体实现在各个插件的注册函数 Address string // containerd grpc地址 默认 /run/contained/containerd.sock 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 后去
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.
type Registration ¶
type Registration struct { // Type of the plugin Type Type //插件类型如:io.containerd.runtime.v1(插件类型为运行时) // ID of the plugin ID string //插件ID io.containerd.runtime.v1这类型插件可能有多个不同的插件, 如linux的,如 windows. 这些就是特定插件的ID // Config specific to the plugin Config interface{} // 插件自定义的配置, 每个插件都有各自不同的配置。 containerd配置文件可以替换插件的配置 // 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)
Graph0 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
v1/runtime插件 类型io.containerd.runtime.v1 ID为linux
type Service ¶
Service allows GRPC services to be registered with the underlying server 就是将这些插件实现的服务添加到grpc 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.
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" //为什么 service/contaienrs中同时注册了 ServicePlugin以及GRPC Plugin? // 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" )
containerd默认的插件