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:
Derek McGowan
2023-10-12 15:36:02 -07:00
parent a80606bc2d
commit 7b2a918213
65 changed files with 363 additions and 299 deletions

View File

@@ -21,6 +21,7 @@ import (
"testing"
"github.com/containerd/containerd/plugin"
"github.com/containerd/containerd/plugin/registry"
srvconfig "github.com/containerd/containerd/services/server/config"
"github.com/stretchr/testify/assert"
)
@@ -57,8 +58,8 @@ func TestCreateTopLevelDirectoriesWithEmptyRootPath(t *testing.T) {
}
func TestMigration(t *testing.T) {
plugin.Reset()
defer plugin.Reset()
registry.Reset()
defer registry.Reset()
version := srvconfig.CurrentConfigVersion - 1
@@ -67,7 +68,7 @@ func TestMigration(t *testing.T) {
NotMigrated string `toml:"notmigrated"`
}
plugin.Register(&plugin.Registration{
registry.Register(&plugin.Registration{
Type: "io.containerd.test",
ID: "t1",
Config: &testConfig{},
@@ -86,7 +87,7 @@ func TestMigration(t *testing.T) {
return nil, nil
},
})
plugin.Register(&plugin.Registration{
registry.Register(&plugin.Registration{
Type: "io.containerd.new",
Requires: []plugin.Type{
"io.containerd.test", // Ensure this test runs second