Generalize the plugin package
Remove containerd specific parts of the plugin package to prepare its move out of the main repository. Separate the plugin registration singleton into a separate package. Separating out the plugin package and registration makes it easier to implement external plugins without creating a dependency loop. Signed-off-by: Derek McGowan <derek@mcg.dev>
This commit is contained in:
@@ -21,6 +21,7 @@ import (
|
||||
|
||||
"github.com/containerd/containerd/platforms"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/containerd/containerd/plugin/registry"
|
||||
"github.com/containerd/containerd/plugins"
|
||||
"github.com/containerd/containerd/snapshots/blockfile"
|
||||
)
|
||||
@@ -45,7 +46,7 @@ type Config struct {
|
||||
}
|
||||
|
||||
func init() {
|
||||
plugin.Register(&plugin.Registration{
|
||||
registry.Register(&plugin.Registration{
|
||||
Type: plugins.SnapshotPlugin,
|
||||
ID: "blockfile",
|
||||
Config: &Config{},
|
||||
@@ -58,7 +59,7 @@ func init() {
|
||||
}
|
||||
|
||||
var opts []blockfile.Opt
|
||||
root := ic.Root
|
||||
root := ic.Properties[plugins.PropertyRootDir]
|
||||
if len(config.RootPath) != 0 {
|
||||
root = config.RootPath
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
|
||||
"github.com/containerd/containerd/platforms"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/containerd/containerd/plugin/registry"
|
||||
"github.com/containerd/containerd/plugins"
|
||||
"github.com/containerd/containerd/snapshots/btrfs"
|
||||
)
|
||||
@@ -36,7 +37,7 @@ type Config struct {
|
||||
}
|
||||
|
||||
func init() {
|
||||
plugin.Register(&plugin.Registration{
|
||||
registry.Register(&plugin.Registration{
|
||||
ID: "btrfs",
|
||||
Type: plugins.SnapshotPlugin,
|
||||
Config: &Config{},
|
||||
@@ -48,7 +49,7 @@ func init() {
|
||||
return nil, errors.New("invalid btrfs configuration")
|
||||
}
|
||||
|
||||
root := ic.Root
|
||||
root := ic.Properties[plugins.PropertyRootDir]
|
||||
if len(config.RootPath) != 0 {
|
||||
root = config.RootPath
|
||||
}
|
||||
|
||||
@@ -24,12 +24,13 @@ import (
|
||||
|
||||
"github.com/containerd/containerd/platforms"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/containerd/containerd/plugin/registry"
|
||||
"github.com/containerd/containerd/plugins"
|
||||
"github.com/containerd/containerd/snapshots/devmapper"
|
||||
)
|
||||
|
||||
func init() {
|
||||
plugin.Register(&plugin.Registration{
|
||||
registry.Register(&plugin.Registration{
|
||||
Type: plugins.SnapshotPlugin,
|
||||
ID: "devmapper",
|
||||
Config: &devmapper.Config{},
|
||||
@@ -46,7 +47,7 @@ func init() {
|
||||
}
|
||||
|
||||
if config.RootPath == "" {
|
||||
config.RootPath = ic.Root
|
||||
config.RootPath = ic.Properties[plugins.PropertyRootDir]
|
||||
}
|
||||
|
||||
return devmapper.NewSnapshotter(ic.Context, config)
|
||||
|
||||
@@ -37,6 +37,7 @@ import (
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/mount"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/containerd/containerd/plugin/registry"
|
||||
"github.com/containerd/containerd/plugins"
|
||||
"github.com/containerd/containerd/snapshots"
|
||||
"github.com/containerd/containerd/snapshots/storage"
|
||||
@@ -46,7 +47,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
plugin.Register(&plugin.Registration{
|
||||
registry.Register(&plugin.Registration{
|
||||
Type: plugins.SnapshotPlugin,
|
||||
ID: "windows-lcow",
|
||||
InitFn: func(ic *plugin.InitContext) (interface{}, error) {
|
||||
@@ -54,7 +55,7 @@ func init() {
|
||||
OS: "linux",
|
||||
Architecture: runtime.GOARCH,
|
||||
})
|
||||
return NewSnapshotter(ic.Root)
|
||||
return NewSnapshotter(ic.Properties[plugins.PropertyRootDir])
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
|
||||
"github.com/containerd/containerd/platforms"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/containerd/containerd/plugin/registry"
|
||||
"github.com/containerd/containerd/plugins"
|
||||
"github.com/containerd/containerd/snapshots/native"
|
||||
)
|
||||
@@ -32,7 +33,7 @@ type Config struct {
|
||||
}
|
||||
|
||||
func init() {
|
||||
plugin.Register(&plugin.Registration{
|
||||
registry.Register(&plugin.Registration{
|
||||
Type: plugins.SnapshotPlugin,
|
||||
ID: "native",
|
||||
Config: &Config{},
|
||||
@@ -44,7 +45,7 @@ func init() {
|
||||
return nil, errors.New("invalid native configuration")
|
||||
}
|
||||
|
||||
root := ic.Root
|
||||
root := ic.Properties[plugins.PropertyRootDir]
|
||||
if len(config.RootPath) != 0 {
|
||||
root = config.RootPath
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
|
||||
"github.com/containerd/containerd/platforms"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/containerd/containerd/plugin/registry"
|
||||
"github.com/containerd/containerd/plugins"
|
||||
"github.com/containerd/containerd/snapshots/overlay"
|
||||
"github.com/containerd/containerd/snapshots/overlay/overlayutils"
|
||||
@@ -50,7 +51,7 @@ type Config struct {
|
||||
}
|
||||
|
||||
func init() {
|
||||
plugin.Register(&plugin.Registration{
|
||||
registry.Register(&plugin.Registration{
|
||||
Type: plugins.SnapshotPlugin,
|
||||
ID: "overlayfs",
|
||||
Config: &Config{},
|
||||
@@ -62,7 +63,7 @@ func init() {
|
||||
return nil, errors.New("invalid overlay configuration")
|
||||
}
|
||||
|
||||
root := ic.Root
|
||||
root := ic.Properties[plugins.PropertyRootDir]
|
||||
if config.RootPath != "" {
|
||||
root = config.RootPath
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ import (
|
||||
"github.com/containerd/containerd/mount"
|
||||
"github.com/containerd/containerd/platforms"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/containerd/containerd/plugin/registry"
|
||||
"github.com/containerd/containerd/plugins"
|
||||
"github.com/containerd/containerd/snapshots"
|
||||
"github.com/containerd/containerd/snapshots/storage"
|
||||
@@ -47,12 +48,12 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
plugin.Register(&plugin.Registration{
|
||||
registry.Register(&plugin.Registration{
|
||||
Type: plugins.SnapshotPlugin,
|
||||
ID: "windows",
|
||||
InitFn: func(ic *plugin.InitContext) (interface{}, error) {
|
||||
ic.Meta.Platforms = []ocispec.Platform{platforms.DefaultSpec()}
|
||||
return NewSnapshotter(ic.Root)
|
||||
return NewSnapshotter(ic.Properties[plugins.PropertyRootDir])
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user