Move plugin type definitions to containerd plugins package
The plugins packages defines the plugins used by containerd. Move all the types and properties to this package. Signed-off-by: Derek McGowan <derek@mcg.dev>
This commit is contained in:
@@ -22,12 +22,13 @@ import (
|
||||
"github.com/containerd/containerd/pkg/imageverifier/bindir"
|
||||
"github.com/containerd/containerd/pkg/tomlext"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/containerd/containerd/plugins"
|
||||
)
|
||||
|
||||
// Register default image verifier service plugin
|
||||
func init() {
|
||||
plugin.Register(&plugin.Registration{
|
||||
Type: plugin.ImageVerifierPlugin,
|
||||
Type: plugins.ImageVerifierPlugin,
|
||||
ID: "bindir",
|
||||
Config: defaultConfig(),
|
||||
InitFn: func(ic *plugin.InitContext) (interface{}, error) {
|
||||
|
||||
@@ -29,6 +29,7 @@ import (
|
||||
"github.com/containerd/containerd/mount"
|
||||
"github.com/containerd/containerd/platforms"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/containerd/containerd/plugins"
|
||||
"github.com/containerd/containerd/runtime"
|
||||
v2 "github.com/containerd/containerd/runtime/v2"
|
||||
"github.com/containerd/containerd/sandbox"
|
||||
@@ -39,25 +40,25 @@ import (
|
||||
|
||||
func init() {
|
||||
plugin.Register(&plugin.Registration{
|
||||
Type: plugin.SandboxControllerPlugin,
|
||||
Type: plugins.SandboxControllerPlugin,
|
||||
ID: "local",
|
||||
Requires: []plugin.Type{
|
||||
plugin.RuntimePluginV2,
|
||||
plugin.EventPlugin,
|
||||
plugin.SandboxStorePlugin,
|
||||
plugins.RuntimePluginV2,
|
||||
plugins.EventPlugin,
|
||||
plugins.SandboxStorePlugin,
|
||||
},
|
||||
InitFn: func(ic *plugin.InitContext) (interface{}, error) {
|
||||
shimPlugin, err := ic.GetByID(plugin.RuntimePluginV2, "shim")
|
||||
shimPlugin, err := ic.GetByID(plugins.RuntimePluginV2, "shim")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
exchangePlugin, err := ic.GetByID(plugin.EventPlugin, "exchange")
|
||||
exchangePlugin, err := ic.GetByID(plugins.EventPlugin, "exchange")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
sbPlugin, err := ic.GetByID(plugin.SandboxStorePlugin, "local")
|
||||
sbPlugin, err := ic.GetByID(plugins.SandboxStorePlugin, "local")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -19,17 +19,18 @@ package sandbox
|
||||
import (
|
||||
"github.com/containerd/containerd/metadata"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/containerd/containerd/plugins"
|
||||
)
|
||||
|
||||
func init() {
|
||||
plugin.Register(&plugin.Registration{
|
||||
Type: plugin.SandboxStorePlugin,
|
||||
Type: plugins.SandboxStorePlugin,
|
||||
ID: "local",
|
||||
Requires: []plugin.Type{
|
||||
plugin.MetadataPlugin,
|
||||
plugins.MetadataPlugin,
|
||||
},
|
||||
InitFn: func(ic *plugin.InitContext) (interface{}, error) {
|
||||
m, err := ic.Get(plugin.MetadataPlugin)
|
||||
m, err := ic.Get(plugins.MetadataPlugin)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -28,17 +28,18 @@ import (
|
||||
"github.com/containerd/containerd/namespaces"
|
||||
"github.com/containerd/containerd/pkg/streaming"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/containerd/containerd/plugins"
|
||||
)
|
||||
|
||||
func init() {
|
||||
plugin.Register(&plugin.Registration{
|
||||
Type: plugin.StreamingPlugin,
|
||||
Type: plugins.StreamingPlugin,
|
||||
ID: "manager",
|
||||
Requires: []plugin.Type{
|
||||
plugin.MetadataPlugin,
|
||||
plugins.MetadataPlugin,
|
||||
},
|
||||
InitFn: func(ic *plugin.InitContext) (interface{}, error) {
|
||||
md, err := ic.Get(plugin.MetadataPlugin)
|
||||
md, err := ic.Get(plugins.MetadataPlugin)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import (
|
||||
"github.com/containerd/containerd/pkg/unpack"
|
||||
"github.com/containerd/containerd/platforms"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/containerd/containerd/plugins"
|
||||
"github.com/containerd/log"
|
||||
|
||||
// Load packages with type registrations
|
||||
@@ -40,29 +41,29 @@ import (
|
||||
// Register local transfer service plugin
|
||||
func init() {
|
||||
plugin.Register(&plugin.Registration{
|
||||
Type: plugin.TransferPlugin,
|
||||
Type: plugins.TransferPlugin,
|
||||
ID: "local",
|
||||
Requires: []plugin.Type{
|
||||
plugin.LeasePlugin,
|
||||
plugin.MetadataPlugin,
|
||||
plugin.DiffPlugin,
|
||||
plugin.ImageVerifierPlugin,
|
||||
plugins.LeasePlugin,
|
||||
plugins.MetadataPlugin,
|
||||
plugins.DiffPlugin,
|
||||
plugins.ImageVerifierPlugin,
|
||||
},
|
||||
Config: defaultConfig(),
|
||||
InitFn: func(ic *plugin.InitContext) (interface{}, error) {
|
||||
config := ic.Config.(*transferConfig)
|
||||
m, err := ic.Get(plugin.MetadataPlugin)
|
||||
m, err := ic.Get(plugins.MetadataPlugin)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ms := m.(*metadata.DB)
|
||||
l, err := ic.Get(plugin.LeasePlugin)
|
||||
l, err := ic.Get(plugins.LeasePlugin)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
vfs := make(map[string]imageverifier.ImageVerifier)
|
||||
vps, err := ic.GetByType(plugin.ImageVerifierPlugin)
|
||||
vps, err := ic.GetByType(plugins.ImageVerifierPlugin)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -82,7 +83,7 @@ func init() {
|
||||
for _, uc := range config.UnpackConfiguration {
|
||||
p, err := platforms.Parse(uc.Platform)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%s: platform configuration %v invalid", plugin.TransferPlugin, uc.Platform)
|
||||
return nil, fmt.Errorf("%s: platform configuration %v invalid", plugins.TransferPlugin, uc.Platform)
|
||||
}
|
||||
|
||||
sn := ms.Snapshotter(uc.Snapshotter)
|
||||
@@ -90,7 +91,7 @@ func init() {
|
||||
return nil, fmt.Errorf("snapshotter %q not found: %w", uc.Snapshotter, errdefs.ErrNotFound)
|
||||
}
|
||||
|
||||
diffPlugins, err := ic.GetByType(plugin.DiffPlugin)
|
||||
diffPlugins, err := ic.GetByType(plugins.DiffPlugin)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error loading diff plugins: %w", err)
|
||||
}
|
||||
|
||||
84
plugins/types.go
Normal file
84
plugins/types.go
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
Copyright The containerd Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// plugins package stores all the plugin types used by containerd internally.
|
||||
//
|
||||
// External plugins should copy from these types and avoid importing this
|
||||
// package.
|
||||
package plugins
|
||||
|
||||
import "github.com/containerd/containerd/plugin"
|
||||
|
||||
const (
|
||||
// InternalPlugin implements an internal plugin to containerd
|
||||
InternalPlugin plugin.Type = "io.containerd.internal.v1"
|
||||
// RuntimePlugin implements a runtime
|
||||
RuntimePlugin plugin.Type = "io.containerd.runtime.v1"
|
||||
// RuntimePluginV2 implements a runtime v2
|
||||
RuntimePluginV2 plugin.Type = "io.containerd.runtime.v2"
|
||||
// ServicePlugin implements a internal service
|
||||
ServicePlugin plugin.Type = "io.containerd.service.v1"
|
||||
// GRPCPlugin implements a grpc service
|
||||
GRPCPlugin plugin.Type = "io.containerd.grpc.v1"
|
||||
// TTRPCPlugin implements a ttrpc shim service
|
||||
TTRPCPlugin plugin.Type = "io.containerd.ttrpc.v1"
|
||||
// SnapshotPlugin implements a snapshotter
|
||||
SnapshotPlugin plugin.Type = "io.containerd.snapshotter.v1"
|
||||
// TaskMonitorPlugin implements a task monitor
|
||||
TaskMonitorPlugin plugin.Type = "io.containerd.monitor.v1"
|
||||
// DiffPlugin implements a differ
|
||||
DiffPlugin plugin.Type = "io.containerd.differ.v1"
|
||||
// MetadataPlugin implements a metadata store
|
||||
MetadataPlugin plugin.Type = "io.containerd.metadata.v1"
|
||||
// ContentPlugin implements a content store
|
||||
ContentPlugin plugin.Type = "io.containerd.content.v1"
|
||||
// GCPlugin implements garbage collection policy
|
||||
GCPlugin plugin.Type = "io.containerd.gc.v1"
|
||||
// EventPlugin implements event handling
|
||||
EventPlugin plugin.Type = "io.containerd.event.v1"
|
||||
// LeasePlugin implements lease manager
|
||||
LeasePlugin plugin.Type = "io.containerd.lease.v1"
|
||||
// StreamingPlugin implements a stream manager
|
||||
StreamingPlugin plugin.Type = "io.containerd.streaming.v1"
|
||||
// TracingProcessorPlugin implements a open telemetry span processor
|
||||
TracingProcessorPlugin plugin.Type = "io.containerd.tracing.processor.v1"
|
||||
// NRIApiPlugin implements the NRI adaptation interface for containerd.
|
||||
NRIApiPlugin plugin.Type = "io.containerd.nri.v1"
|
||||
// TransferPlugin implements a transfer service
|
||||
TransferPlugin plugin.Type = "io.containerd.transfer.v1"
|
||||
// SandboxStorePlugin implements a sandbox store
|
||||
SandboxStorePlugin plugin.Type = "io.containerd.sandbox.store.v1"
|
||||
// SandboxControllerPlugin implements a sandbox controller
|
||||
SandboxControllerPlugin plugin.Type = "io.containerd.sandbox.controller.v1"
|
||||
// ImageVerifierPlugin implements an image verifier service
|
||||
ImageVerifierPlugin plugin.Type = "io.containerd.image-verifier.v1"
|
||||
)
|
||||
|
||||
const (
|
||||
// RuntimeRuncV2 is the runc runtime that supports multiple containers per shim
|
||||
RuntimeRuncV2 = "io.containerd.runc.v2"
|
||||
)
|
||||
|
||||
const (
|
||||
// PropertyRootDir sets the root directory property for a plugin
|
||||
PropertyRootDir = "io.containerd.plugin.root"
|
||||
// PropertyStateDir sets the state directory property for a plugin
|
||||
PropertyStateDir = "io.containerd.plugin.state"
|
||||
// PropertyGRPCAddress is the grpc address used for client connections to containerd
|
||||
PropertyGRPCAddress = "io.containerd.plugin.grpc.address"
|
||||
// PropertyGRPCAddress is the ttrpc address used for client connections to containerd
|
||||
PropertyTTRPCAddress = "io.containerd.plugin.ttrpc.address"
|
||||
)
|
||||
Reference in New Issue
Block a user