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:
		| @@ -52,7 +52,7 @@ import ( | ||||
| 	"github.com/containerd/containerd/namespaces" | ||||
| 	"github.com/containerd/containerd/pkg/dialer" | ||||
| 	"github.com/containerd/containerd/platforms" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	ptypes "github.com/containerd/containerd/protobuf/types" | ||||
| 	"github.com/containerd/containerd/remotes" | ||||
| 	"github.com/containerd/containerd/remotes/docker" | ||||
| @@ -185,7 +185,7 @@ func NewWithConn(conn *grpc.ClientConn, opts ...ClientOpt) (*Client, error) { | ||||
| 	c := &Client{ | ||||
| 		defaultns: copts.defaultns, | ||||
| 		conn:      conn, | ||||
| 		runtime:   plugin.RuntimePlugin.String() + "." + runtime.GOOS, | ||||
| 		runtime:   plugins.RuntimePlugin.String() + "." + runtime.GOOS, | ||||
| 	} | ||||
|  | ||||
| 	if copts.defaultPlatform != nil { | ||||
| @@ -826,7 +826,7 @@ func (c *Client) getSnapshotter(ctx context.Context, name string) (snapshots.Sna | ||||
| // GetSnapshotterSupportedPlatforms returns a platform matchers which represents the | ||||
| // supported platforms for the given snapshotters | ||||
| func (c *Client) GetSnapshotterSupportedPlatforms(ctx context.Context, snapshotterName string) (platforms.MatchComparer, error) { | ||||
| 	filters := []string{fmt.Sprintf("type==%s, id==%s", plugin.SnapshotPlugin, snapshotterName)} | ||||
| 	filters := []string{fmt.Sprintf("type==%s, id==%s", plugins.SnapshotPlugin, snapshotterName)} | ||||
| 	in := c.IntrospectionService() | ||||
|  | ||||
| 	resp, err := in.Plugins(ctx, filters) | ||||
| @@ -857,7 +857,7 @@ func toPlatforms(pt []*apitypes.Platform) []ocispec.Platform { | ||||
|  | ||||
| // GetSnapshotterCapabilities returns the capabilities of a snapshotter. | ||||
| func (c *Client) GetSnapshotterCapabilities(ctx context.Context, snapshotterName string) ([]string, error) { | ||||
| 	filters := []string{fmt.Sprintf("type==%s, id==%s", plugin.SnapshotPlugin, snapshotterName)} | ||||
| 	filters := []string{fmt.Sprintf("type==%s, id==%s", plugins.SnapshotPlugin, snapshotterName)} | ||||
| 	in := c.IntrospectionService() | ||||
|  | ||||
| 	resp, err := in.Plugins(ctx, filters) | ||||
|   | ||||
| @@ -31,7 +31,7 @@ import ( | ||||
| 	"github.com/containerd/containerd" | ||||
| 	"github.com/containerd/containerd/integration/remote" | ||||
| 	"github.com/containerd/containerd/namespaces" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	"github.com/containerd/log" | ||||
| 	metrics "github.com/docker/go-metrics" | ||||
| 	"github.com/urfave/cli" | ||||
| @@ -167,7 +167,7 @@ func main() { | ||||
| 		cli.StringFlag{ | ||||
| 			Name:  "runtime", | ||||
| 			Usage: "Set the runtime to stress test", | ||||
| 			Value: plugin.RuntimeRuncV2, | ||||
| 			Value: plugins.RuntimeRuncV2, | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 			Name:  "snapshotter", | ||||
|   | ||||
| @@ -36,6 +36,7 @@ import ( | ||||
| 	"github.com/containerd/containerd/metadata" | ||||
| 	"github.com/containerd/containerd/mount" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	"github.com/containerd/log" | ||||
| 	digest "github.com/opencontainers/go-digest" | ||||
| 	ocispec "github.com/opencontainers/image-spec/specs-go/v1" | ||||
| @@ -48,13 +49,13 @@ const ( | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type: plugin.DiffPlugin, | ||||
| 		Type: plugins.DiffPlugin, | ||||
| 		ID:   "windows-lcow", | ||||
| 		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 | ||||
| 			} | ||||
|   | ||||
| @@ -23,17 +23,18 @@ import ( | ||||
| 	"github.com/containerd/containerd/metadata" | ||||
| 	"github.com/containerd/containerd/platforms" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| ) | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type: plugin.DiffPlugin, | ||||
| 		Type: plugins.DiffPlugin, | ||||
| 		ID:   "walking", | ||||
| 		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 | ||||
| 			} | ||||
|   | ||||
| @@ -39,6 +39,7 @@ import ( | ||||
| 	"github.com/containerd/containerd/pkg/epoch" | ||||
| 	"github.com/containerd/containerd/platforms" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	"github.com/containerd/log" | ||||
| 	"github.com/opencontainers/go-digest" | ||||
| 	ocispec "github.com/opencontainers/image-spec/specs-go/v1" | ||||
| @@ -46,13 +47,13 @@ import ( | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type: plugin.DiffPlugin, | ||||
| 		Type: plugins.DiffPlugin, | ||||
| 		ID:   "windows", | ||||
| 		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 | ||||
| 			} | ||||
|   | ||||
| @@ -19,11 +19,12 @@ package plugin | ||||
| import ( | ||||
| 	"github.com/containerd/containerd/events/exchange" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| ) | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type: plugin.EventPlugin, | ||||
| 		Type: plugins.EventPlugin, | ||||
| 		ID:   "exchange", | ||||
| 		InitFn: func(ic *plugin.InitContext) (interface{}, error) { | ||||
| 			return exchange.NewExchange(), nil | ||||
|   | ||||
| @@ -25,6 +25,7 @@ import ( | ||||
|  | ||||
| 	"github.com/containerd/containerd/gc" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	"github.com/containerd/log" | ||||
| ) | ||||
|  | ||||
| @@ -97,10 +98,10 @@ func (d duration) MarshalText() (text []byte, err error) { | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type: plugin.GCPlugin, | ||||
| 		Type: plugins.GCPlugin, | ||||
| 		ID:   "scheduler", | ||||
| 		Requires: []plugin.Type{ | ||||
| 			plugin.MetadataPlugin, | ||||
| 			plugins.MetadataPlugin, | ||||
| 		}, | ||||
| 		Config: &config{ | ||||
| 			PauseThreshold:    0.02, | ||||
| @@ -110,14 +111,14 @@ func init() { | ||||
| 			StartupDelay:      duration(100 * time.Millisecond), | ||||
| 		}, | ||||
| 		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 | ||||
| 			} | ||||
|  | ||||
| 			mdCollector, ok := md.(collector) | ||||
| 			if !ok { | ||||
| 				return nil, fmt.Errorf("%s %T must implement collector", plugin.MetadataPlugin, md) | ||||
| 				return nil, fmt.Errorf("%s %T must implement collector", plugins.MetadataPlugin, md) | ||||
| 			} | ||||
|  | ||||
| 			m := newScheduler(mdCollector, ic.Config.(*config)) | ||||
|   | ||||
| @@ -38,7 +38,7 @@ import ( | ||||
| 	"github.com/containerd/containerd/containers" | ||||
| 	"github.com/containerd/containerd/errdefs" | ||||
| 	"github.com/containerd/containerd/oci" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	"github.com/containerd/containerd/runtime/v2/runc/options" | ||||
| 	"github.com/containerd/containerd/sys" | ||||
|  | ||||
| @@ -1028,7 +1028,7 @@ func TestContainerRuntimeOptionsv2(t *testing.T) { | ||||
| 		ctx, id, | ||||
| 		WithNewSnapshot(id, image), | ||||
| 		WithNewSpec(oci.WithImageConfig(image), withExitStatus(7)), | ||||
| 		WithRuntime(plugin.RuntimeRuncV2, &options.Options{BinaryName: "no-runc"}), | ||||
| 		WithRuntime(plugins.RuntimeRuncV2, &options.Options{BinaryName: "no-runc"}), | ||||
| 	) | ||||
| 	if err != nil { | ||||
| 		t.Fatal(err) | ||||
|   | ||||
| @@ -39,7 +39,7 @@ import ( | ||||
| 	"github.com/containerd/containerd/namespaces" | ||||
| 	"github.com/containerd/containerd/oci" | ||||
| 	"github.com/containerd/containerd/platforms" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	gogotypes "github.com/containerd/containerd/protobuf/types" | ||||
| 	_ "github.com/containerd/containerd/runtime" | ||||
| 	"github.com/containerd/containerd/runtime/v2/runc/options" | ||||
| @@ -172,7 +172,7 @@ func TestContainerStart(t *testing.T) { | ||||
| } | ||||
|  | ||||
| func readShimPath(taskID string) (string, error) { | ||||
| 	runtime := plugin.RuntimePluginV2.String() + ".task" | ||||
| 	runtime := plugins.RuntimePluginV2.String() + ".task" | ||||
| 	shimBinaryNamePath := filepath.Join(defaultState, runtime, testNamespace, taskID, "shim-binary-path") | ||||
|  | ||||
| 	shimPath, err := os.ReadFile(shimBinaryNamePath) | ||||
|   | ||||
| @@ -29,7 +29,7 @@ import ( | ||||
| 	"github.com/containerd/cgroups/v3" | ||||
| 	. "github.com/containerd/containerd" | ||||
| 	"github.com/containerd/containerd/oci" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	"github.com/containerd/containerd/runtime/v2/runc/options" | ||||
| ) | ||||
|  | ||||
| @@ -55,7 +55,7 @@ version = 2 | ||||
| 	} | ||||
|  | ||||
| 	id := t.Name() | ||||
| 	container, err := client.NewContainer(ctx, id, WithNewSnapshot(id, image), WithNewSpec(oci.WithImageConfig(image), withProcessArgs("top")), WithRuntime(plugin.RuntimeRuncV2, &options.Options{ | ||||
| 	container, err := client.NewContainer(ctx, id, WithNewSnapshot(id, image), WithNewSpec(oci.WithImageConfig(image), withProcessArgs("top")), WithRuntime(plugins.RuntimeRuncV2, &options.Options{ | ||||
| 		Root: runtimeRoot, | ||||
| 	})) | ||||
| 	if err != nil { | ||||
|   | ||||
| @@ -28,6 +28,7 @@ import ( | ||||
| 	"github.com/containerd/containerd/pkg/failpoint" | ||||
| 	"github.com/containerd/containerd/pkg/shutdown" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	"github.com/containerd/containerd/runtime/v2/runc/task" | ||||
| 	"github.com/containerd/containerd/runtime/v2/shim" | ||||
| 	"github.com/containerd/ttrpc" | ||||
| @@ -39,18 +40,18 @@ const ( | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type: plugin.TTRPCPlugin, | ||||
| 		Type: plugins.TTRPCPlugin, | ||||
| 		ID:   "task", | ||||
| 		Requires: []plugin.Type{ | ||||
| 			plugin.EventPlugin, | ||||
| 			plugin.InternalPlugin, | ||||
| 			plugins.EventPlugin, | ||||
| 			plugins.InternalPlugin, | ||||
| 		}, | ||||
| 		InitFn: func(ic *plugin.InitContext) (interface{}, error) { | ||||
| 			pp, err := ic.GetByID(plugin.EventPlugin, "publisher") | ||||
| 			pp, err := ic.GetByID(plugins.EventPlugin, "publisher") | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			ss, err := ic.GetByID(plugin.InternalPlugin, "shutdown") | ||||
| 			ss, err := ic.GetByID(plugins.InternalPlugin, "shutdown") | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
|   | ||||
| @@ -23,22 +23,23 @@ import ( | ||||
| 	"github.com/containerd/containerd/leases" | ||||
| 	"github.com/containerd/containerd/metadata" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| ) | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type: plugin.LeasePlugin, | ||||
| 		Type: plugins.LeasePlugin, | ||||
| 		ID:   "manager", | ||||
| 		Requires: []plugin.Type{ | ||||
| 			plugin.MetadataPlugin, | ||||
| 			plugin.GCPlugin, | ||||
| 			plugins.MetadataPlugin, | ||||
| 			plugins.GCPlugin, | ||||
| 		}, | ||||
| 		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 | ||||
| 			} | ||||
| 			g, err := ic.Get(plugin.GCPlugin) | ||||
| 			g, err := ic.Get(plugins.GCPlugin) | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
|   | ||||
| @@ -28,6 +28,7 @@ import ( | ||||
| 	"github.com/containerd/containerd/metadata" | ||||
| 	"github.com/containerd/containerd/pkg/timeout" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	"github.com/containerd/containerd/snapshots" | ||||
| 	"github.com/containerd/log" | ||||
|  | ||||
| @@ -82,12 +83,12 @@ func (bc *BoltConfig) Validate() error { | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type: plugin.MetadataPlugin, | ||||
| 		Type: plugins.MetadataPlugin, | ||||
| 		ID:   "bolt", | ||||
| 		Requires: []plugin.Type{ | ||||
| 			plugin.ContentPlugin, | ||||
| 			plugin.EventPlugin, | ||||
| 			plugin.SnapshotPlugin, | ||||
| 			plugins.ContentPlugin, | ||||
| 			plugins.EventPlugin, | ||||
| 			plugins.SnapshotPlugin, | ||||
| 		}, | ||||
| 		Config: &BoltConfig{ | ||||
| 			ContentSharingPolicy: SharingPolicyShared, | ||||
| @@ -96,12 +97,12 @@ func init() { | ||||
| 			if err := os.MkdirAll(ic.Root, 0711); err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			cs, err := ic.Get(plugin.ContentPlugin) | ||||
| 			cs, err := ic.Get(plugins.ContentPlugin) | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
|  | ||||
| 			snapshottersRaw, err := ic.GetByType(plugin.SnapshotPlugin) | ||||
| 			snapshottersRaw, err := ic.GetByType(plugins.SnapshotPlugin) | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| @@ -119,7 +120,7 @@ func init() { | ||||
| 				snapshotters[name] = sn.(snapshots.Snapshotter) | ||||
| 			} | ||||
|  | ||||
| 			ep, err := ic.Get(plugin.EventPlugin) | ||||
| 			ep, err := ic.Get(plugins.EventPlugin) | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
|   | ||||
| @@ -25,6 +25,7 @@ import ( | ||||
| 	v2 "github.com/containerd/containerd/metrics/cgroups/v2" | ||||
| 	"github.com/containerd/containerd/platforms" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	"github.com/containerd/containerd/runtime" | ||||
| 	metrics "github.com/docker/go-metrics" | ||||
| ) | ||||
| @@ -36,11 +37,11 @@ type Config struct { | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type:   plugin.TaskMonitorPlugin, | ||||
| 		Type:   plugins.TaskMonitorPlugin, | ||||
| 		ID:     "cgroups", | ||||
| 		InitFn: New, | ||||
| 		Requires: []plugin.Type{ | ||||
| 			plugin.EventPlugin, | ||||
| 			plugins.EventPlugin, | ||||
| 		}, | ||||
| 		Config: &Config{}, | ||||
| 	}) | ||||
| @@ -58,7 +59,7 @@ func New(ic *plugin.InitContext) (interface{}, error) { | ||||
| 		err error | ||||
| 	) | ||||
|  | ||||
| 	ep, err := ic.Get(plugin.EventPlugin) | ||||
| 	ep, err := ic.Get(plugins.EventPlugin) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|   | ||||
| @@ -27,6 +27,7 @@ import ( | ||||
| 	nriservice "github.com/containerd/containerd/pkg/nri" | ||||
| 	"github.com/containerd/containerd/platforms" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	"github.com/containerd/log" | ||||
| 	imagespec "github.com/opencontainers/image-spec/specs-go/v1" | ||||
| 	"k8s.io/klog/v2" | ||||
| @@ -39,13 +40,13 @@ import ( | ||||
| func init() { | ||||
| 	config := criconfig.DefaultConfig() | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type:   plugin.GRPCPlugin, | ||||
| 		Type:   plugins.GRPCPlugin, | ||||
| 		ID:     "cri", | ||||
| 		Config: &config, | ||||
| 		Requires: []plugin.Type{ | ||||
| 			plugin.EventPlugin, | ||||
| 			plugin.ServicePlugin, | ||||
| 			plugin.NRIApiPlugin, | ||||
| 			plugins.EventPlugin, | ||||
| 			plugins.ServicePlugin, | ||||
| 			plugins.NRIApiPlugin, | ||||
| 		}, | ||||
| 		InitFn: initCRIService, | ||||
| 	}) | ||||
| @@ -125,7 +126,7 @@ func setGLogLevel() error { | ||||
| // Get the NRI plugin, and set up our NRI API for it. | ||||
| func getNRIAPI(ic *plugin.InitContext) *nri.API { | ||||
| 	const ( | ||||
| 		pluginType = plugin.NRIApiPlugin | ||||
| 		pluginType = plugins.NRIApiPlugin | ||||
| 		pluginName = "nri" | ||||
| 	) | ||||
|  | ||||
|   | ||||
| @@ -41,7 +41,7 @@ import ( | ||||
| 	containerstore "github.com/containerd/containerd/pkg/cri/store/container" | ||||
| 	imagestore "github.com/containerd/containerd/pkg/cri/store/image" | ||||
| 	runtimeoptions "github.com/containerd/containerd/pkg/runtimeoptions/v1" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	runcoptions "github.com/containerd/containerd/runtime/v2/runc/options" | ||||
| 	"github.com/containerd/log" | ||||
| ) | ||||
| @@ -289,7 +289,7 @@ func generateRuntimeOptions(r criconfig.Runtime) (interface{}, error) { | ||||
| // getRuntimeOptionsType gets empty runtime options by the runtime type name. | ||||
| func getRuntimeOptionsType(t string) interface{} { | ||||
| 	switch t { | ||||
| 	case plugin.RuntimeRuncV2: | ||||
| 	case plugins.RuntimeRuncV2: | ||||
| 		return &runcoptions.Options{} | ||||
| 	case runtimeRunhcsV1: | ||||
| 		return &runhcsoptions.Options{} | ||||
|   | ||||
| @@ -30,7 +30,7 @@ import ( | ||||
| 	"github.com/containerd/containerd/oci" | ||||
| 	criconfig "github.com/containerd/containerd/pkg/cri/config" | ||||
| 	containerstore "github.com/containerd/containerd/pkg/cri/store/container" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	"github.com/containerd/containerd/protobuf/types" | ||||
| 	runcoptions "github.com/containerd/containerd/runtime/v2/runc/options" | ||||
| 	"github.com/containerd/typeurl/v2" | ||||
| @@ -119,7 +119,7 @@ systemd_cgroup = true | ||||
|   no_pivot = true | ||||
|   default_runtime_name = "default" | ||||
| [containerd.runtimes.runcv2] | ||||
|   runtime_type = "` + plugin.RuntimeRuncV2 + `" | ||||
|   runtime_type = "` + plugins.RuntimeRuncV2 + `" | ||||
| ` | ||||
| 	nonNilOpts := ` | ||||
| systemd_cgroup = true | ||||
| @@ -134,7 +134,7 @@ systemd_cgroup = true | ||||
|   Root = "/runc" | ||||
|   NoNewKeyring = true | ||||
| [containerd.runtimes.runcv2] | ||||
|   runtime_type = "` + plugin.RuntimeRuncV2 + `" | ||||
|   runtime_type = "` + plugins.RuntimeRuncV2 + `" | ||||
| [containerd.runtimes.runcv2.options] | ||||
|   BinaryName = "runc" | ||||
|   Root = "/runcv2" | ||||
|   | ||||
| @@ -22,7 +22,7 @@ import ( | ||||
|  | ||||
| 	criconfig "github.com/containerd/containerd/pkg/cri/config" | ||||
| 	"github.com/containerd/containerd/pkg/systemd" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	"github.com/stretchr/testify/assert" | ||||
| 	runtime "k8s.io/cri-api/pkg/apis/runtime/v1" | ||||
| ) | ||||
| @@ -30,7 +30,7 @@ import ( | ||||
| func newFakeRuntimeConfig(runcV2, systemdCgroup bool) criconfig.Runtime { | ||||
| 	r := criconfig.Runtime{Type: "default", Options: map[string]interface{}{}} | ||||
| 	if runcV2 { | ||||
| 		r.Type = plugin.RuntimeRuncV2 | ||||
| 		r.Type = plugins.RuntimeRuncV2 | ||||
| 		if systemdCgroup { | ||||
| 			r.Options["SystemdCgroup"] = true | ||||
| 		} | ||||
|   | ||||
| @@ -36,7 +36,7 @@ import ( | ||||
| 	imagestore "github.com/containerd/containerd/pkg/cri/store/image" | ||||
| 	snapshotstore "github.com/containerd/containerd/pkg/cri/store/snapshot" | ||||
| 	"github.com/containerd/containerd/pkg/cri/streaming" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	"github.com/containerd/containerd/sandbox" | ||||
| 	"github.com/containerd/go-cni" | ||||
| 	"github.com/containerd/log" | ||||
| @@ -350,7 +350,7 @@ func (c *criService) register(s *grpc.Server) error { | ||||
| // imageFSPath returns containerd image filesystem path. | ||||
| // Note that if containerd changes directory layout, we also needs to change this. | ||||
| func imageFSPath(rootDir, snapshotter string) string { | ||||
| 	return filepath.Join(rootDir, plugin.SnapshotPlugin.String()+"."+snapshotter) | ||||
| 	return filepath.Join(rootDir, plugins.SnapshotPlugin.String()+"."+snapshotter) | ||||
| } | ||||
|  | ||||
| func loadOCISpec(filename string) (*oci.Spec, error) { | ||||
|   | ||||
| @@ -19,11 +19,12 @@ package plugin | ||||
| import ( | ||||
| 	"github.com/containerd/containerd/pkg/nri" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| ) | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type:   plugin.NRIApiPlugin, | ||||
| 		Type:   plugins.NRIApiPlugin, | ||||
| 		ID:     "nri", | ||||
| 		Config: nri.DefaultConfig(), | ||||
| 		InitFn: initFunc, | ||||
|   | ||||
| @@ -50,56 +50,6 @@ type Type string | ||||
|  | ||||
| func (t Type) String() string { return string(t) } | ||||
|  | ||||
| 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" | ||||
| 	// GRPCPlugin implements a grpc service | ||||
| 	GRPCPlugin Type = "io.containerd.grpc.v1" | ||||
| 	// TTRPCPlugin implements a ttrpc shim service | ||||
| 	TTRPCPlugin Type = "io.containerd.ttrpc.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" | ||||
| 	// EventPlugin implements event handling | ||||
| 	EventPlugin Type = "io.containerd.event.v1" | ||||
| 	// LeasePlugin implements lease manager | ||||
| 	LeasePlugin Type = "io.containerd.lease.v1" | ||||
| 	// StreamingPlugin implements a stream manager | ||||
| 	StreamingPlugin Type = "io.containerd.streaming.v1" | ||||
| 	// TracingProcessorPlugin implements a open telemetry span processor | ||||
| 	TracingProcessorPlugin Type = "io.containerd.tracing.processor.v1" | ||||
| 	// NRIApiPlugin implements the NRI adaptation interface for containerd. | ||||
| 	NRIApiPlugin Type = "io.containerd.nri.v1" | ||||
| 	// TransferPlugin implements a transfer service | ||||
| 	TransferPlugin Type = "io.containerd.transfer.v1" | ||||
| 	// SandboxStorePlugin implements a sandbox store | ||||
| 	SandboxStorePlugin Type = "io.containerd.sandbox.store.v1" | ||||
| 	// SandboxControllerPlugin implements a sandbox controller | ||||
| 	SandboxControllerPlugin Type = "io.containerd.sandbox.controller.v1" | ||||
| 	// ImageVerifierPlugin implements an image verifier service | ||||
| 	ImageVerifierPlugin Type = "io.containerd.image-verifier.v1" | ||||
| ) | ||||
|  | ||||
| const ( | ||||
| 	// RuntimeRuncV2 is the runc runtime that supports multiple containers per shim | ||||
| 	RuntimeRuncV2 = "io.containerd.runc.v2" | ||||
| ) | ||||
|  | ||||
| // Registration contains information for registering a plugin | ||||
| type Registration struct { | ||||
| 	// Type of the plugin | ||||
|   | ||||
| @@ -32,24 +32,39 @@ func mockPluginFilter(*Registration) bool { | ||||
| 	return false | ||||
| } | ||||
|  | ||||
| var tasksServiceRequires = []Type{ | ||||
| 	RuntimePlugin, | ||||
| 	RuntimePluginV2, | ||||
| 	MetadataPlugin, | ||||
| 	TaskMonitorPlugin, | ||||
| } | ||||
|  | ||||
| // TestContainerdPlugin tests the logic of Graph, use the containerd's plugin | ||||
| func TestContainerdPlugin(t *testing.T) { | ||||
| 	registerClear() | ||||
| 	// Plugin types commonly used by containerd | ||||
| 	const ( | ||||
| 		InternalPlugin         Type = "io.containerd.internal.v1" | ||||
| 		RuntimePlugin          Type = "io.containerd.runtime.v1" | ||||
| 		RuntimePluginV2        Type = "io.containerd.runtime.v2" | ||||
| 		ServicePlugin          Type = "io.containerd.service.v1" | ||||
| 		GRPCPlugin             Type = "io.containerd.grpc.v1" | ||||
| 		SnapshotPlugin         Type = "io.containerd.snapshotter.v1" | ||||
| 		TaskMonitorPlugin      Type = "io.containerd.monitor.v1" | ||||
| 		DiffPlugin             Type = "io.containerd.differ.v1" | ||||
| 		MetadataPlugin         Type = "io.containerd.metadata.v1" | ||||
| 		ContentPlugin          Type = "io.containerd.content.v1" | ||||
| 		GCPlugin               Type = "io.containerd.gc.v1" | ||||
| 		LeasePlugin            Type = "io.containerd.lease.v1" | ||||
| 		TracingProcessorPlugin Type = "io.containerd.tracing.processor.v1" | ||||
| 	) | ||||
|  | ||||
| 	Register(&Registration{ | ||||
| 		Type: TaskMonitorPlugin, | ||||
| 		ID:   "cgroups", | ||||
| 	}) | ||||
| 	Register(&Registration{ | ||||
| 		Type:     ServicePlugin, | ||||
| 		ID:       services.TasksService, | ||||
| 		Requires: tasksServiceRequires, | ||||
| 		Type: ServicePlugin, | ||||
| 		ID:   services.TasksService, | ||||
| 		Requires: []Type{ | ||||
| 			RuntimePlugin, | ||||
| 			RuntimePluginV2, | ||||
| 			MetadataPlugin, | ||||
| 			TaskMonitorPlugin, | ||||
| 		}, | ||||
| 	}) | ||||
| 	Register(&Registration{ | ||||
| 		Type: ServicePlugin, | ||||
|   | ||||
| @@ -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" | ||||
| ) | ||||
| @@ -26,6 +26,7 @@ import ( | ||||
| 	"github.com/containerd/containerd" | ||||
| 	"github.com/containerd/containerd/namespaces" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	"github.com/containerd/containerd/runtime/restart" | ||||
| 	"github.com/containerd/log" | ||||
| ) | ||||
| @@ -52,10 +53,10 @@ type Config struct { | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type: plugin.InternalPlugin, | ||||
| 		Type: plugins.InternalPlugin, | ||||
| 		Requires: []plugin.Type{ | ||||
| 			plugin.EventPlugin, | ||||
| 			plugin.ServicePlugin, | ||||
| 			plugins.EventPlugin, | ||||
| 			plugins.ServicePlugin, | ||||
| 		}, | ||||
| 		ID: "restart", | ||||
| 		Config: &Config{ | ||||
|   | ||||
| @@ -24,6 +24,7 @@ import ( | ||||
| 	"github.com/containerd/containerd/errdefs" | ||||
| 	"github.com/containerd/containerd/pkg/shutdown" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	ptypes "github.com/containerd/containerd/protobuf/types" | ||||
| 	"github.com/containerd/containerd/runtime/v2/shim" | ||||
| 	"github.com/containerd/ttrpc" | ||||
| @@ -31,18 +32,18 @@ import ( | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type: plugin.TTRPCPlugin, | ||||
| 		Type: plugins.TTRPCPlugin, | ||||
| 		ID:   "task", | ||||
| 		Requires: []plugin.Type{ | ||||
| 			plugin.EventPlugin, | ||||
| 			plugin.InternalPlugin, | ||||
| 			plugins.EventPlugin, | ||||
| 			plugins.InternalPlugin, | ||||
| 		}, | ||||
| 		InitFn: func(ic *plugin.InitContext) (interface{}, error) { | ||||
| 			pp, err := ic.GetByID(plugin.EventPlugin, "publisher") | ||||
| 			pp, err := ic.GetByID(plugins.EventPlugin, "publisher") | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			ss, err := ic.GetByID(plugin.InternalPlugin, "shutdown") | ||||
| 			ss, err := ic.GetByID(plugins.InternalPlugin, "shutdown") | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
|   | ||||
| @@ -34,6 +34,7 @@ import ( | ||||
| 	"github.com/containerd/containerd/pkg/timeout" | ||||
| 	"github.com/containerd/containerd/platforms" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	"github.com/containerd/containerd/protobuf" | ||||
| 	"github.com/containerd/containerd/runtime" | ||||
| 	shimbinary "github.com/containerd/containerd/runtime/v2/shim" | ||||
| @@ -51,11 +52,11 @@ type Config struct { | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type: plugin.RuntimePluginV2, | ||||
| 		Type: plugins.RuntimePluginV2, | ||||
| 		ID:   "task", | ||||
| 		Requires: []plugin.Type{ | ||||
| 			plugin.EventPlugin, | ||||
| 			plugin.MetadataPlugin, | ||||
| 			plugins.EventPlugin, | ||||
| 			plugins.MetadataPlugin, | ||||
| 		}, | ||||
| 		Config: &Config{ | ||||
| 			Platforms: defaultPlatforms(), | ||||
| @@ -69,11 +70,11 @@ func init() { | ||||
|  | ||||
| 			ic.Meta.Platforms = supportedPlatforms | ||||
|  | ||||
| 			m, err := ic.Get(plugin.MetadataPlugin) | ||||
| 			m, err := ic.Get(plugins.MetadataPlugin) | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			ep, err := ic.GetByID(plugin.EventPlugin, "exchange") | ||||
| 			ep, err := ic.GetByID(plugins.EventPlugin, "exchange") | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| @@ -104,10 +105,10 @@ func init() { | ||||
| 	// use the following workaround. | ||||
| 	// This expected to be removed in 1.7. | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type: plugin.RuntimePluginV2, | ||||
| 		Type: plugins.RuntimePluginV2, | ||||
| 		ID:   "shim", | ||||
| 		InitFn: func(ic *plugin.InitContext) (interface{}, error) { | ||||
| 			taskManagerI, err := ic.GetByID(plugin.RuntimePluginV2, "task") | ||||
| 			taskManagerI, err := ic.GetByID(plugins.RuntimePluginV2, "task") | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| @@ -176,7 +177,7 @@ type ShimManager struct { | ||||
|  | ||||
| // ID of the shim manager | ||||
| func (m *ShimManager) ID() string { | ||||
| 	return plugin.RuntimePluginV2.String() + ".shim" | ||||
| 	return plugins.RuntimePluginV2.String() + ".shim" | ||||
| } | ||||
|  | ||||
| // Start launches a new shim instance | ||||
| @@ -400,7 +401,7 @@ func NewTaskManager(shims *ShimManager) *TaskManager { | ||||
|  | ||||
| // ID of the task manager | ||||
| func (m *TaskManager) ID() string { | ||||
| 	return plugin.RuntimePluginV2.String() + ".task" | ||||
| 	return plugins.RuntimePluginV2.String() + ".task" | ||||
| } | ||||
|  | ||||
| // Create launches new shim instance and creates new task | ||||
|   | ||||
| @@ -24,6 +24,7 @@ import ( | ||||
|  | ||||
| 	"github.com/containerd/containerd/api/types" | ||||
| 	"github.com/containerd/containerd/pkg/shutdown" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	"github.com/containerd/containerd/runtime/v2/shim" | ||||
| 	"github.com/containerd/log" | ||||
| 	"github.com/containerd/ttrpc" | ||||
| @@ -34,13 +35,13 @@ import ( | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type: plugin.TTRPCPlugin, | ||||
| 		Type: plugins.TTRPCPlugin, | ||||
| 		ID:   "pause", | ||||
| 		Requires: []plugin.Type{ | ||||
| 			plugin.InternalPlugin, | ||||
| 			plugins.InternalPlugin, | ||||
| 		}, | ||||
| 		InitFn: func(ic *plugin.InitContext) (interface{}, error) { | ||||
| 			ss, err := ic.GetByID(plugin.InternalPlugin, "shutdown") | ||||
| 			ss, err := ic.GetByID(plugins.InternalPlugin, "shutdown") | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
|   | ||||
| @@ -19,24 +19,25 @@ package plugin | ||||
| import ( | ||||
| 	"github.com/containerd/containerd/pkg/shutdown" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	"github.com/containerd/containerd/runtime/v2/runc/task" | ||||
| 	"github.com/containerd/containerd/runtime/v2/shim" | ||||
| ) | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type: plugin.TTRPCPlugin, | ||||
| 		Type: plugins.TTRPCPlugin, | ||||
| 		ID:   "task", | ||||
| 		Requires: []plugin.Type{ | ||||
| 			plugin.EventPlugin, | ||||
| 			plugin.InternalPlugin, | ||||
| 			plugins.EventPlugin, | ||||
| 			plugins.InternalPlugin, | ||||
| 		}, | ||||
| 		InitFn: func(ic *plugin.InitContext) (interface{}, error) { | ||||
| 			pp, err := ic.GetByID(plugin.EventPlugin, "publisher") | ||||
| 			pp, err := ic.GetByID(plugins.EventPlugin, "publisher") | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			ss, err := ic.GetByID(plugin.InternalPlugin, "shutdown") | ||||
| 			ss, err := ic.GetByID(plugins.InternalPlugin, "shutdown") | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
|   | ||||
| @@ -34,6 +34,7 @@ import ( | ||||
| 	"github.com/containerd/containerd/namespaces" | ||||
| 	"github.com/containerd/containerd/pkg/shutdown" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	"github.com/containerd/containerd/protobuf" | ||||
| 	"github.com/containerd/containerd/protobuf/proto" | ||||
| 	"github.com/containerd/containerd/version" | ||||
| @@ -284,7 +285,7 @@ func run(ctx context.Context, manager Manager, name string, config Config) error | ||||
| 	} | ||||
|  | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type: plugin.InternalPlugin, | ||||
| 		Type: plugins.InternalPlugin, | ||||
| 		ID:   "shutdown", | ||||
| 		InitFn: func(ic *plugin.InitContext) (interface{}, error) { | ||||
| 			return sd, nil | ||||
| @@ -293,7 +294,7 @@ func run(ctx context.Context, manager Manager, name string, config Config) error | ||||
|  | ||||
| 	// Register event plugin | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type: plugin.EventPlugin, | ||||
| 		Type: plugins.EventPlugin, | ||||
| 		ID:   "publisher", | ||||
| 		InitFn: func(ic *plugin.InitContext) (interface{}, error) { | ||||
| 			return publisher, nil | ||||
|   | ||||
							
								
								
									
										11
									
								
								services.go
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								services.go
									
									
									
									
									
								
							| @@ -31,6 +31,7 @@ import ( | ||||
| 	"github.com/containerd/containerd/leases" | ||||
| 	"github.com/containerd/containerd/namespaces" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	"github.com/containerd/containerd/sandbox" | ||||
| 	srv "github.com/containerd/containerd/services" | ||||
| 	"github.com/containerd/containerd/services/introspection" | ||||
| @@ -183,16 +184,16 @@ func WithInMemoryServices(ic *plugin.InitContext) ClientOpt { | ||||
| 	return func(c *clientOpts) error { | ||||
| 		var opts []ServicesOpt | ||||
| 		for t, fn := range map[plugin.Type]func(interface{}) ServicesOpt{ | ||||
| 			plugin.EventPlugin: func(i interface{}) ServicesOpt { | ||||
| 			plugins.EventPlugin: func(i interface{}) ServicesOpt { | ||||
| 				return WithEventService(i.(EventService)) | ||||
| 			}, | ||||
| 			plugin.LeasePlugin: func(i interface{}) ServicesOpt { | ||||
| 			plugins.LeasePlugin: func(i interface{}) ServicesOpt { | ||||
| 				return WithLeasesService(i.(leases.Manager)) | ||||
| 			}, | ||||
| 			plugin.SandboxStorePlugin: func(i interface{}) ServicesOpt { | ||||
| 			plugins.SandboxStorePlugin: func(i interface{}) ServicesOpt { | ||||
| 				return WithSandboxStore(i.(sandbox.Store)) | ||||
| 			}, | ||||
| 			plugin.SandboxControllerPlugin: func(i interface{}) ServicesOpt { | ||||
| 			plugins.SandboxControllerPlugin: func(i interface{}) ServicesOpt { | ||||
| 				return WithSandboxController(i.(sandbox.Controller)) | ||||
| 			}, | ||||
| 		} { | ||||
| @@ -203,7 +204,7 @@ func WithInMemoryServices(ic *plugin.InitContext) ClientOpt { | ||||
| 			opts = append(opts, fn(i)) | ||||
| 		} | ||||
|  | ||||
| 		plugins, err := ic.GetByType(plugin.ServicePlugin) | ||||
| 		plugins, err := ic.GetByType(plugins.ServicePlugin) | ||||
| 		if err != nil { | ||||
| 			return fmt.Errorf("failed to get service plugin: %w", err) | ||||
| 		} | ||||
|   | ||||
| @@ -27,6 +27,7 @@ import ( | ||||
| 	"github.com/containerd/containerd/events" | ||||
| 	"github.com/containerd/containerd/metadata" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	ptypes "github.com/containerd/containerd/protobuf/types" | ||||
| 	"github.com/containerd/containerd/services" | ||||
| 	bolt "go.etcd.io/bbolt" | ||||
| @@ -38,18 +39,18 @@ import ( | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type: plugin.ServicePlugin, | ||||
| 		Type: plugins.ServicePlugin, | ||||
| 		ID:   services.ContainersService, | ||||
| 		Requires: []plugin.Type{ | ||||
| 			plugin.EventPlugin, | ||||
| 			plugin.MetadataPlugin, | ||||
| 			plugins.EventPlugin, | ||||
| 			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 | ||||
| 			} | ||||
| 			ep, err := ic.Get(plugin.EventPlugin) | ||||
| 			ep, err := ic.Get(plugins.EventPlugin) | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
|   | ||||
| @@ -23,6 +23,7 @@ import ( | ||||
|  | ||||
| 	api "github.com/containerd/containerd/api/services/containers/v1" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	ptypes "github.com/containerd/containerd/protobuf/types" | ||||
| 	"github.com/containerd/containerd/services" | ||||
| 	"google.golang.org/grpc" | ||||
| @@ -30,17 +31,17 @@ import ( | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type: plugin.GRPCPlugin, | ||||
| 		Type: plugins.GRPCPlugin, | ||||
| 		ID:   "containers", | ||||
| 		Requires: []plugin.Type{ | ||||
| 			plugin.ServicePlugin, | ||||
| 			plugins.ServicePlugin, | ||||
| 		}, | ||||
| 		InitFn: func(ic *plugin.InitContext) (interface{}, error) { | ||||
| 			plugins, err := ic.GetByType(plugin.ServicePlugin) | ||||
| 			sps, err := ic.GetByType(plugins.ServicePlugin) | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			p, ok := plugins[services.ContainersService] | ||||
| 			p, ok := sps[services.ContainersService] | ||||
| 			if !ok { | ||||
| 				return nil, errors.New("containers service not found") | ||||
| 			} | ||||
|   | ||||
| @@ -21,19 +21,20 @@ import ( | ||||
|  | ||||
| 	"github.com/containerd/containerd/content" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	"github.com/containerd/containerd/services" | ||||
| 	"github.com/containerd/containerd/services/content/contentserver" | ||||
| ) | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type: plugin.GRPCPlugin, | ||||
| 		Type: plugins.GRPCPlugin, | ||||
| 		ID:   "content", | ||||
| 		Requires: []plugin.Type{ | ||||
| 			plugin.ServicePlugin, | ||||
| 			plugins.ServicePlugin, | ||||
| 		}, | ||||
| 		InitFn: func(ic *plugin.InitContext) (interface{}, error) { | ||||
| 			plugins, err := ic.GetByType(plugin.ServicePlugin) | ||||
| 			plugins, err := ic.GetByType(plugins.ServicePlugin) | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
|   | ||||
| @@ -24,6 +24,7 @@ import ( | ||||
| 	"github.com/containerd/containerd/events" | ||||
| 	"github.com/containerd/containerd/metadata" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	"github.com/containerd/containerd/services" | ||||
| 	digest "github.com/opencontainers/go-digest" | ||||
| ) | ||||
| @@ -36,18 +37,18 @@ type store struct { | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type: plugin.ServicePlugin, | ||||
| 		Type: plugins.ServicePlugin, | ||||
| 		ID:   services.ContentService, | ||||
| 		Requires: []plugin.Type{ | ||||
| 			plugin.EventPlugin, | ||||
| 			plugin.MetadataPlugin, | ||||
| 			plugins.EventPlugin, | ||||
| 			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 | ||||
| 			} | ||||
| 			ep, err := ic.Get(plugin.EventPlugin) | ||||
| 			ep, err := ic.Get(plugins.EventPlugin) | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
|   | ||||
| @@ -26,6 +26,7 @@ import ( | ||||
| 	"github.com/containerd/containerd/mount" | ||||
| 	"github.com/containerd/containerd/oci" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	"github.com/containerd/containerd/services" | ||||
| 	"github.com/containerd/typeurl/v2" | ||||
| 	ocispec "github.com/opencontainers/image-spec/specs-go/v1" | ||||
| @@ -49,14 +50,14 @@ type differ interface { | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type: plugin.ServicePlugin, | ||||
| 		Type: plugins.ServicePlugin, | ||||
| 		ID:   services.DiffService, | ||||
| 		Requires: []plugin.Type{ | ||||
| 			plugin.DiffPlugin, | ||||
| 			plugins.DiffPlugin, | ||||
| 		}, | ||||
| 		Config: defaultDifferConfig, | ||||
| 		InitFn: func(ic *plugin.InitContext) (interface{}, error) { | ||||
| 			differs, err := ic.GetByType(plugin.DiffPlugin) | ||||
| 			differs, err := ic.GetByType(plugins.DiffPlugin) | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
|   | ||||
| @@ -22,23 +22,24 @@ import ( | ||||
|  | ||||
| 	diffapi "github.com/containerd/containerd/api/services/diff/v1" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	"github.com/containerd/containerd/services" | ||||
| 	"google.golang.org/grpc" | ||||
| ) | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type: plugin.GRPCPlugin, | ||||
| 		Type: plugins.GRPCPlugin, | ||||
| 		ID:   "diff", | ||||
| 		Requires: []plugin.Type{ | ||||
| 			plugin.ServicePlugin, | ||||
| 			plugins.ServicePlugin, | ||||
| 		}, | ||||
| 		InitFn: func(ic *plugin.InitContext) (interface{}, error) { | ||||
| 			plugins, err := ic.GetByType(plugin.ServicePlugin) | ||||
| 			sps, err := ic.GetByType(plugins.ServicePlugin) | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			p, ok := plugins[services.DiffService] | ||||
| 			p, ok := sps[services.DiffService] | ||||
| 			if !ok { | ||||
| 				return nil, errors.New("diff service not found") | ||||
| 			} | ||||
|   | ||||
| @@ -26,6 +26,7 @@ import ( | ||||
| 	"github.com/containerd/containerd/events" | ||||
| 	"github.com/containerd/containerd/events/exchange" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	"github.com/containerd/containerd/protobuf" | ||||
| 	ptypes "github.com/containerd/containerd/protobuf/types" | ||||
| 	"github.com/containerd/ttrpc" | ||||
| @@ -34,13 +35,13 @@ import ( | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type: plugin.GRPCPlugin, | ||||
| 		Type: plugins.GRPCPlugin, | ||||
| 		ID:   "events", | ||||
| 		Requires: []plugin.Type{ | ||||
| 			plugin.EventPlugin, | ||||
| 			plugins.EventPlugin, | ||||
| 		}, | ||||
| 		InitFn: func(ic *plugin.InitContext) (interface{}, error) { | ||||
| 			ep, err := ic.GetByID(plugin.EventPlugin, "exchange") | ||||
| 			ep, err := ic.GetByID(plugins.EventPlugin, "exchange") | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
|   | ||||
| @@ -18,6 +18,7 @@ package healthcheck | ||||
|  | ||||
| import ( | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
|  | ||||
| 	"google.golang.org/grpc" | ||||
| 	"google.golang.org/grpc/health" | ||||
| @@ -30,7 +31,7 @@ type service struct { | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type: plugin.GRPCPlugin, | ||||
| 		Type: plugins.GRPCPlugin, | ||||
| 		ID:   "healthcheck", | ||||
| 		InitFn: func(*plugin.InitContext) (interface{}, error) { | ||||
| 			return newService() | ||||
|   | ||||
| @@ -28,6 +28,7 @@ import ( | ||||
| 	"github.com/containerd/containerd/metadata" | ||||
| 	"github.com/containerd/containerd/pkg/epoch" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	ptypes "github.com/containerd/containerd/protobuf/types" | ||||
| 	"github.com/containerd/containerd/services" | ||||
| 	"github.com/containerd/log" | ||||
| @@ -38,24 +39,24 @@ import ( | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type: plugin.ServicePlugin, | ||||
| 		Type: plugins.ServicePlugin, | ||||
| 		ID:   services.ImagesService, | ||||
| 		Requires: []plugin.Type{ | ||||
| 			plugin.EventPlugin, | ||||
| 			plugin.MetadataPlugin, | ||||
| 			plugin.GCPlugin, | ||||
| 			plugins.EventPlugin, | ||||
| 			plugins.MetadataPlugin, | ||||
| 			plugins.GCPlugin, | ||||
| 		}, | ||||
| 		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 | ||||
| 			} | ||||
| 			g, err := ic.Get(plugin.GCPlugin) | ||||
| 			g, err := ic.Get(plugins.GCPlugin) | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
|  | ||||
| 			ep, err := ic.Get(plugin.EventPlugin) | ||||
| 			ep, err := ic.Get(plugins.EventPlugin) | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
|   | ||||
| @@ -22,6 +22,7 @@ import ( | ||||
|  | ||||
| 	imagesapi "github.com/containerd/containerd/api/services/images/v1" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	ptypes "github.com/containerd/containerd/protobuf/types" | ||||
| 	"github.com/containerd/containerd/services" | ||||
| 	"google.golang.org/grpc" | ||||
| @@ -29,17 +30,17 @@ import ( | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type: plugin.GRPCPlugin, | ||||
| 		Type: plugins.GRPCPlugin, | ||||
| 		ID:   "images", | ||||
| 		Requires: []plugin.Type{ | ||||
| 			plugin.ServicePlugin, | ||||
| 			plugins.ServicePlugin, | ||||
| 		}, | ||||
| 		InitFn: func(ic *plugin.InitContext) (interface{}, error) { | ||||
| 			plugins, err := ic.GetByType(plugin.ServicePlugin) | ||||
| 			sps, err := ic.GetByType(plugins.ServicePlugin) | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			p, ok := plugins[services.ImagesService] | ||||
| 			p, ok := sps[services.ImagesService] | ||||
| 			if !ok { | ||||
| 				return nil, errors.New("images service not found") | ||||
| 			} | ||||
|   | ||||
| @@ -28,6 +28,7 @@ import ( | ||||
| 	"github.com/containerd/containerd/errdefs" | ||||
| 	"github.com/containerd/containerd/filters" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	ptypes "github.com/containerd/containerd/protobuf/types" | ||||
| 	"github.com/containerd/containerd/services" | ||||
| 	"github.com/google/uuid" | ||||
| @@ -39,7 +40,7 @@ import ( | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type:     plugin.ServicePlugin, | ||||
| 		Type:     plugins.ServicePlugin, | ||||
| 		ID:       services.IntrospectionService, | ||||
| 		Requires: []plugin.Type{}, | ||||
| 		InitFn: func(ic *plugin.InitContext) (interface{}, error) { | ||||
|   | ||||
| @@ -22,6 +22,7 @@ import ( | ||||
|  | ||||
| 	api "github.com/containerd/containerd/api/services/introspection/v1" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	ptypes "github.com/containerd/containerd/protobuf/types" | ||||
| 	"github.com/containerd/containerd/services" | ||||
| 	"google.golang.org/grpc" | ||||
| @@ -29,15 +30,15 @@ import ( | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type:     plugin.GRPCPlugin, | ||||
| 		Type:     plugins.GRPCPlugin, | ||||
| 		ID:       "introspection", | ||||
| 		Requires: []plugin.Type{plugin.ServicePlugin}, | ||||
| 		Requires: []plugin.Type{plugins.ServicePlugin}, | ||||
| 		InitFn: func(ic *plugin.InitContext) (interface{}, error) { | ||||
| 			plugins, err := ic.GetByType(plugin.ServicePlugin) | ||||
| 			sps, err := ic.GetByType(plugins.ServicePlugin) | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			p, ok := plugins[services.IntrospectionService] | ||||
| 			p, ok := sps[services.IntrospectionService] | ||||
| 			if !ok { | ||||
| 				return nil, errors.New("introspection service not found") | ||||
| 			} | ||||
|   | ||||
| @@ -23,6 +23,7 @@ import ( | ||||
| 	"github.com/containerd/containerd/errdefs" | ||||
| 	"github.com/containerd/containerd/leases" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	"github.com/containerd/containerd/protobuf" | ||||
| 	ptypes "github.com/containerd/containerd/protobuf/types" | ||||
| 	"google.golang.org/grpc" | ||||
| @@ -30,13 +31,13 @@ import ( | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type: plugin.GRPCPlugin, | ||||
| 		Type: plugins.GRPCPlugin, | ||||
| 		ID:   "leases", | ||||
| 		Requires: []plugin.Type{ | ||||
| 			plugin.LeasePlugin, | ||||
| 			plugins.LeasePlugin, | ||||
| 		}, | ||||
| 		InitFn: func(ic *plugin.InitContext) (interface{}, error) { | ||||
| 			i, err := ic.GetByID(plugin.LeasePlugin, "manager") | ||||
| 			i, err := ic.GetByID(plugins.LeasePlugin, "manager") | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
|   | ||||
| @@ -27,6 +27,7 @@ import ( | ||||
| 	"github.com/containerd/containerd/metadata" | ||||
| 	"github.com/containerd/containerd/namespaces" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	ptypes "github.com/containerd/containerd/protobuf/types" | ||||
| 	"github.com/containerd/containerd/services" | ||||
| 	bolt "go.etcd.io/bbolt" | ||||
| @@ -37,18 +38,18 @@ import ( | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type: plugin.ServicePlugin, | ||||
| 		Type: plugins.ServicePlugin, | ||||
| 		ID:   services.NamespacesService, | ||||
| 		Requires: []plugin.Type{ | ||||
| 			plugin.EventPlugin, | ||||
| 			plugin.MetadataPlugin, | ||||
| 			plugins.EventPlugin, | ||||
| 			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 | ||||
| 			} | ||||
| 			ep, err := ic.Get(plugin.EventPlugin) | ||||
| 			ep, err := ic.Get(plugins.EventPlugin) | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
|   | ||||
| @@ -22,6 +22,7 @@ import ( | ||||
|  | ||||
| 	api "github.com/containerd/containerd/api/services/namespaces/v1" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	ptypes "github.com/containerd/containerd/protobuf/types" | ||||
| 	"github.com/containerd/containerd/services" | ||||
| 	"google.golang.org/grpc" | ||||
| @@ -29,17 +30,17 @@ import ( | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type: plugin.GRPCPlugin, | ||||
| 		Type: plugins.GRPCPlugin, | ||||
| 		ID:   "namespaces", | ||||
| 		Requires: []plugin.Type{ | ||||
| 			plugin.ServicePlugin, | ||||
| 			plugins.ServicePlugin, | ||||
| 		}, | ||||
| 		InitFn: func(ic *plugin.InitContext) (interface{}, error) { | ||||
| 			plugins, err := ic.GetByType(plugin.ServicePlugin) | ||||
| 			sps, err := ic.GetByType(plugins.ServicePlugin) | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			p, ok := plugins[services.NamespacesService] | ||||
| 			p, ok := sps[services.NamespacesService] | ||||
| 			if !ok { | ||||
| 				return nil, errors.New("namespaces service not found") | ||||
| 			} | ||||
|   | ||||
| @@ -22,6 +22,7 @@ import ( | ||||
| 	"path/filepath" | ||||
|  | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| ) | ||||
|  | ||||
| // Config for the opt manager | ||||
| @@ -32,7 +33,7 @@ type Config struct { | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type: plugin.InternalPlugin, | ||||
| 		Type: plugins.InternalPlugin, | ||||
| 		ID:   "opt", | ||||
| 		Config: &Config{ | ||||
| 			Path: defaultPath, | ||||
|   | ||||
| @@ -27,6 +27,7 @@ import ( | ||||
| 	"github.com/containerd/containerd/errdefs" | ||||
| 	"github.com/containerd/containerd/events" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	"github.com/containerd/containerd/protobuf" | ||||
| 	"github.com/containerd/containerd/sandbox" | ||||
| 	"github.com/containerd/log" | ||||
| @@ -34,19 +35,19 @@ import ( | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type: plugin.GRPCPlugin, | ||||
| 		Type: plugins.GRPCPlugin, | ||||
| 		ID:   "sandbox-controllers", | ||||
| 		Requires: []plugin.Type{ | ||||
| 			plugin.SandboxControllerPlugin, | ||||
| 			plugin.EventPlugin, | ||||
| 			plugins.SandboxControllerPlugin, | ||||
| 			plugins.EventPlugin, | ||||
| 		}, | ||||
| 		InitFn: func(ic *plugin.InitContext) (interface{}, error) { | ||||
| 			sc, err := ic.GetByID(plugin.SandboxControllerPlugin, "local") | ||||
| 			sc, err := ic.GetByID(plugins.SandboxControllerPlugin, "local") | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
|  | ||||
| 			ep, err := ic.Get(plugin.EventPlugin) | ||||
| 			ep, err := ic.Get(plugins.EventPlugin) | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
|   | ||||
| @@ -25,19 +25,20 @@ import ( | ||||
| 	"github.com/containerd/containerd/api/types" | ||||
| 	"github.com/containerd/containerd/errdefs" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	"github.com/containerd/containerd/sandbox" | ||||
| 	"github.com/containerd/log" | ||||
| ) | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type: plugin.GRPCPlugin, | ||||
| 		Type: plugins.GRPCPlugin, | ||||
| 		ID:   "sandboxes", | ||||
| 		Requires: []plugin.Type{ | ||||
| 			plugin.SandboxStorePlugin, | ||||
| 			plugins.SandboxStorePlugin, | ||||
| 		}, | ||||
| 		InitFn: func(ic *plugin.InitContext) (interface{}, error) { | ||||
| 			sp, err := ic.GetByID(plugin.SandboxStorePlugin, "local") | ||||
| 			sp, err := ic.GetByID(plugins.SandboxStorePlugin, "local") | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
|   | ||||
| @@ -46,6 +46,7 @@ import ( | ||||
| 	"github.com/containerd/containerd/pkg/timeout" | ||||
| 	"github.com/containerd/containerd/platforms" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	srvconfig "github.com/containerd/containerd/services/server/config" | ||||
| 	ssproxy "github.com/containerd/containerd/snapshots/proxy" | ||||
| 	"github.com/containerd/containerd/sys" | ||||
| @@ -127,7 +128,7 @@ func New(ctx context.Context, config *srvconfig.Config) (*Server, error) { | ||||
| 		} | ||||
| 		timeout.Set(key, d) | ||||
| 	} | ||||
| 	plugins, err := LoadPlugins(ctx, config) | ||||
| 	loaded, err := LoadPlugins(ctx, config) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| @@ -223,7 +224,7 @@ func New(ctx context.Context, config *srvconfig.Config) (*Server, error) { | ||||
| 		// Run each plugin migration for each version to ensure that migration logic is simple and | ||||
| 		// focused on upgrading from one version at a time. | ||||
| 		for v := version; v < srvconfig.CurrentConfigVersion; v++ { | ||||
| 			for _, p := range plugins { | ||||
| 			for _, p := range loaded { | ||||
| 				if p.ConfigMigration != nil { | ||||
| 					if err := p.ConfigMigration(ctx, v, config.Plugins); err != nil { | ||||
| 						return nil, err | ||||
| @@ -237,7 +238,7 @@ func New(ctx context.Context, config *srvconfig.Config) (*Server, error) { | ||||
| 		log.G(ctx).WithField("t", migrationT).Warnf("Configuration migrated from version %d, use `containerd config migrate` to avoid migration", version) | ||||
| 	} | ||||
|  | ||||
| 	for _, p := range plugins { | ||||
| 	for _, p := range loaded { | ||||
| 		id := p.URI() | ||||
| 		log.G(ctx).WithField("type", p.Type).Infof("loading plugin %q...", id) | ||||
| 		var mustSucceed int32 | ||||
| @@ -436,7 +437,7 @@ func LoadPlugins(ctx context.Context, config *srvconfig.Config) ([]*plugin.Regis | ||||
| 	} | ||||
| 	// load additional plugins that don't automatically register themselves | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type: plugin.ContentPlugin, | ||||
| 		Type: plugins.ContentPlugin, | ||||
| 		ID:   "content", | ||||
| 		InitFn: func(ic *plugin.InitContext) (interface{}, error) { | ||||
| 			ic.Meta.Exports["root"] = ic.Root | ||||
| @@ -456,20 +457,20 @@ func LoadPlugins(ctx context.Context, config *srvconfig.Config) ([]*plugin.Regis | ||||
| 		) | ||||
|  | ||||
| 		switch pp.Type { | ||||
| 		case string(plugin.SnapshotPlugin), "snapshot": | ||||
| 			t = plugin.SnapshotPlugin | ||||
| 		case string(plugins.SnapshotPlugin), "snapshot": | ||||
| 			t = plugins.SnapshotPlugin | ||||
| 			ssname := name | ||||
| 			f = func(conn *grpc.ClientConn) interface{} { | ||||
| 				return ssproxy.NewSnapshotter(ssapi.NewSnapshotsClient(conn), ssname) | ||||
| 			} | ||||
|  | ||||
| 		case string(plugin.ContentPlugin), "content": | ||||
| 			t = plugin.ContentPlugin | ||||
| 		case string(plugins.ContentPlugin), "content": | ||||
| 			t = plugins.ContentPlugin | ||||
| 			f = func(conn *grpc.ClientConn) interface{} { | ||||
| 				return csproxy.NewContentStore(csapi.NewContentClient(conn)) | ||||
| 			} | ||||
| 		case string(plugin.DiffPlugin), "diff": | ||||
| 			t = plugin.DiffPlugin | ||||
| 		case string(plugins.DiffPlugin), "diff": | ||||
| 			t = plugins.DiffPlugin | ||||
| 			f = func(conn *grpc.ClientConn) interface{} { | ||||
| 				return diffproxy.NewDiffApplier(diffapi.NewDiffClient(conn)) | ||||
| 			} | ||||
|   | ||||
| @@ -24,6 +24,7 @@ import ( | ||||
| 	"github.com/containerd/containerd/errdefs" | ||||
| 	"github.com/containerd/containerd/mount" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	ptypes "github.com/containerd/containerd/protobuf/types" | ||||
| 	"github.com/containerd/containerd/services" | ||||
| 	"github.com/containerd/containerd/snapshots" | ||||
| @@ -33,10 +34,10 @@ import ( | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type: plugin.GRPCPlugin, | ||||
| 		Type: plugins.GRPCPlugin, | ||||
| 		ID:   "snapshots", | ||||
| 		Requires: []plugin.Type{ | ||||
| 			plugin.ServicePlugin, | ||||
| 			plugins.ServicePlugin, | ||||
| 		}, | ||||
| 		InitFn: newService, | ||||
| 	}) | ||||
| @@ -50,11 +51,11 @@ type service struct { | ||||
| } | ||||
|  | ||||
| func newService(ic *plugin.InitContext) (interface{}, error) { | ||||
| 	plugins, err := ic.GetByType(plugin.ServicePlugin) | ||||
| 	sps, err := ic.GetByType(plugins.ServicePlugin) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	p, ok := plugins[services.SnapshotsService] | ||||
| 	p, ok := sps[services.SnapshotsService] | ||||
| 	if !ok { | ||||
| 		return nil, errors.New("snapshots service not found") | ||||
| 	} | ||||
|   | ||||
| @@ -19,18 +19,19 @@ package snapshots | ||||
| import ( | ||||
| 	"github.com/containerd/containerd/metadata" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	"github.com/containerd/containerd/services" | ||||
| ) | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type: plugin.ServicePlugin, | ||||
| 		Type: plugins.ServicePlugin, | ||||
| 		ID:   services.SnapshotsService, | ||||
| 		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 | ||||
| 			} | ||||
|   | ||||
| @@ -24,6 +24,7 @@ import ( | ||||
| 	"github.com/containerd/containerd/errdefs" | ||||
| 	"github.com/containerd/containerd/pkg/streaming" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	"github.com/containerd/containerd/protobuf" | ||||
| 	ptypes "github.com/containerd/containerd/protobuf/types" | ||||
| 	"github.com/containerd/log" | ||||
| @@ -42,13 +43,13 @@ func init() { | ||||
| 	} | ||||
|  | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type: plugin.GRPCPlugin, | ||||
| 		Type: plugins.GRPCPlugin, | ||||
| 		ID:   "streaming", | ||||
| 		Requires: []plugin.Type{ | ||||
| 			plugin.StreamingPlugin, | ||||
| 			plugins.StreamingPlugin, | ||||
| 		}, | ||||
| 		InitFn: func(ic *plugin.InitContext) (interface{}, error) { | ||||
| 			i, err := ic.GetByID(plugin.StreamingPlugin, "manager") | ||||
| 			i, err := ic.GetByID(plugins.StreamingPlugin, "manager") | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
|   | ||||
| @@ -41,6 +41,7 @@ import ( | ||||
| 	"github.com/containerd/containerd/pkg/rdt" | ||||
| 	"github.com/containerd/containerd/pkg/timeout" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	"github.com/containerd/containerd/protobuf" | ||||
| 	"github.com/containerd/containerd/protobuf/proto" | ||||
| 	ptypes "github.com/containerd/containerd/protobuf/types" | ||||
| @@ -75,7 +76,7 @@ type Config struct { | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type:     plugin.ServicePlugin, | ||||
| 		Type:     plugins.ServicePlugin, | ||||
| 		ID:       services.TasksService, | ||||
| 		Requires: tasksServiceRequires, | ||||
| 		Config:   &Config{}, | ||||
| @@ -88,22 +89,22 @@ func init() { | ||||
| func initFunc(ic *plugin.InitContext) (interface{}, error) { | ||||
| 	config := ic.Config.(*Config) | ||||
|  | ||||
| 	v2r, err := ic.GetByID(plugin.RuntimePluginV2, "task") | ||||
| 	v2r, err := ic.GetByID(plugins.RuntimePluginV2, "task") | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
| 	m, err := ic.Get(plugin.MetadataPlugin) | ||||
| 	m, err := ic.Get(plugins.MetadataPlugin) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
| 	ep, err := ic.Get(plugin.EventPlugin) | ||||
| 	ep, err := ic.Get(plugins.EventPlugin) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
| 	monitor, err := ic.Get(plugin.TaskMonitorPlugin) | ||||
| 	monitor, err := ic.Get(plugins.TaskMonitorPlugin) | ||||
| 	if err != nil { | ||||
| 		if !errdefs.IsNotFound(err) { | ||||
| 			return nil, err | ||||
|   | ||||
| @@ -20,10 +20,11 @@ package tasks | ||||
|  | ||||
| import ( | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| ) | ||||
|  | ||||
| var tasksServiceRequires = []plugin.Type{ | ||||
| 	plugin.RuntimePluginV2, | ||||
| 	plugin.MetadataPlugin, | ||||
| 	plugin.TaskMonitorPlugin, | ||||
| 	plugins.RuntimePluginV2, | ||||
| 	plugins.MetadataPlugin, | ||||
| 	plugins.TaskMonitorPlugin, | ||||
| } | ||||
|   | ||||
| @@ -18,11 +18,12 @@ package tasks | ||||
|  | ||||
| import ( | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| ) | ||||
|  | ||||
| var tasksServiceRequires = []plugin.Type{ | ||||
| 	plugin.EventPlugin, | ||||
| 	plugin.RuntimePluginV2, | ||||
| 	plugin.MetadataPlugin, | ||||
| 	plugin.TaskMonitorPlugin, | ||||
| 	plugins.EventPlugin, | ||||
| 	plugins.RuntimePluginV2, | ||||
| 	plugins.MetadataPlugin, | ||||
| 	plugins.TaskMonitorPlugin, | ||||
| } | ||||
|   | ||||
| @@ -20,12 +20,13 @@ package tasks | ||||
|  | ||||
| import ( | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| ) | ||||
|  | ||||
| var tasksServiceRequires = []plugin.Type{ | ||||
| 	plugin.EventPlugin, | ||||
| 	plugin.RuntimePlugin, | ||||
| 	plugin.RuntimePluginV2, | ||||
| 	plugin.MetadataPlugin, | ||||
| 	plugin.TaskMonitorPlugin, | ||||
| 	plugins.EventPlugin, | ||||
| 	plugins.RuntimePlugin, | ||||
| 	plugins.RuntimePluginV2, | ||||
| 	plugins.MetadataPlugin, | ||||
| 	plugins.TaskMonitorPlugin, | ||||
| } | ||||
|   | ||||
| @@ -18,11 +18,12 @@ package tasks | ||||
|  | ||||
| import ( | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| ) | ||||
|  | ||||
| var tasksServiceRequires = []plugin.Type{ | ||||
| 	plugin.EventPlugin, | ||||
| 	plugin.RuntimePluginV2, | ||||
| 	plugin.MetadataPlugin, | ||||
| 	plugin.TaskMonitorPlugin, | ||||
| 	plugins.EventPlugin, | ||||
| 	plugins.RuntimePluginV2, | ||||
| 	plugins.MetadataPlugin, | ||||
| 	plugins.TaskMonitorPlugin, | ||||
| } | ||||
|   | ||||
| @@ -22,6 +22,7 @@ import ( | ||||
|  | ||||
| 	api "github.com/containerd/containerd/api/services/tasks/v1" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	ptypes "github.com/containerd/containerd/protobuf/types" | ||||
| 	"github.com/containerd/containerd/services" | ||||
| 	"google.golang.org/grpc" | ||||
| @@ -33,17 +34,17 @@ var ( | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type: plugin.GRPCPlugin, | ||||
| 		Type: plugins.GRPCPlugin, | ||||
| 		ID:   "tasks", | ||||
| 		Requires: []plugin.Type{ | ||||
| 			plugin.ServicePlugin, | ||||
| 			plugins.ServicePlugin, | ||||
| 		}, | ||||
| 		InitFn: func(ic *plugin.InitContext) (interface{}, error) { | ||||
| 			plugins, err := ic.GetByType(plugin.ServicePlugin) | ||||
| 			sps, err := ic.GetByType(plugins.ServicePlugin) | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			p, ok := plugins[services.TasksService] | ||||
| 			p, ok := sps[services.TasksService] | ||||
| 			if !ok { | ||||
| 				return nil, errors.New("tasks service not found") | ||||
| 			} | ||||
|   | ||||
| @@ -24,8 +24,9 @@ import ( | ||||
| 	"github.com/containerd/containerd/errdefs" | ||||
| 	"github.com/containerd/containerd/pkg/streaming" | ||||
| 	"github.com/containerd/containerd/pkg/transfer" | ||||
| 	"github.com/containerd/containerd/pkg/transfer/plugins" | ||||
| 	tplugins "github.com/containerd/containerd/pkg/transfer/plugins" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	ptypes "github.com/containerd/containerd/protobuf/types" | ||||
| 	"github.com/containerd/log" | ||||
| 	"github.com/containerd/typeurl/v2" | ||||
| @@ -37,11 +38,11 @@ import ( | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type: plugin.GRPCPlugin, | ||||
| 		Type: plugins.GRPCPlugin, | ||||
| 		ID:   "transfer", | ||||
| 		Requires: []plugin.Type{ | ||||
| 			plugin.TransferPlugin, | ||||
| 			plugin.StreamingPlugin, | ||||
| 			plugins.TransferPlugin, | ||||
| 			plugins.StreamingPlugin, | ||||
| 		}, | ||||
| 		InitFn: newService, | ||||
| 	}) | ||||
| @@ -54,21 +55,21 @@ type service struct { | ||||
| } | ||||
|  | ||||
| func newService(ic *plugin.InitContext) (interface{}, error) { | ||||
| 	plugins, err := ic.GetByType(plugin.TransferPlugin) | ||||
| 	sps, err := ic.GetByType(plugins.TransferPlugin) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
| 	// TODO: how to determine order? | ||||
| 	t := make([]transfer.Transferrer, 0, len(plugins)) | ||||
| 	for _, p := range plugins { | ||||
| 	t := make([]transfer.Transferrer, 0, len(sps)) | ||||
| 	for _, p := range sps { | ||||
| 		i, err := p.Instance() | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		t = append(t, i.(transfer.Transferrer)) | ||||
| 	} | ||||
| 	sp, err := ic.GetByID(plugin.StreamingPlugin, "manager") | ||||
| 	sp, err := ic.GetByID(plugins.StreamingPlugin, "manager") | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| @@ -134,7 +135,7 @@ func (s *service) Transfer(ctx context.Context, req *transferapi.TransferRequest | ||||
| } | ||||
|  | ||||
| func (s *service) convertAny(ctx context.Context, a typeurl.Any) (interface{}, error) { | ||||
| 	obj, err := plugins.ResolveType(a) | ||||
| 	obj, err := tplugins.ResolveType(a) | ||||
| 	if err != nil { | ||||
| 		if errdefs.IsNotFound(err) { | ||||
| 			return typeurl.UnmarshalAny(a) | ||||
|   | ||||
| @@ -21,6 +21,7 @@ import ( | ||||
|  | ||||
| 	api "github.com/containerd/containerd/api/services/version/v1" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	ptypes "github.com/containerd/containerd/protobuf/types" | ||||
| 	ctrdversion "github.com/containerd/containerd/version" | ||||
| 	"google.golang.org/grpc" | ||||
| @@ -30,7 +31,7 @@ var _ api.VersionServer = &service{} | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type:   plugin.GRPCPlugin, | ||||
| 		Type:   plugins.GRPCPlugin, | ||||
| 		ID:     "version", | ||||
| 		InitFn: initFunc, | ||||
| 	}) | ||||
|   | ||||
| @@ -21,6 +21,7 @@ import ( | ||||
|  | ||||
| 	"github.com/containerd/containerd/platforms" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	"github.com/containerd/containerd/snapshots/blockfile" | ||||
| ) | ||||
|  | ||||
| @@ -45,7 +46,7 @@ type Config struct { | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type:   plugin.SnapshotPlugin, | ||||
| 		Type:   plugins.SnapshotPlugin, | ||||
| 		ID:     "blockfile", | ||||
| 		Config: &Config{}, | ||||
| 		InitFn: func(ic *plugin.InitContext) (interface{}, error) { | ||||
|   | ||||
| @@ -25,6 +25,7 @@ import ( | ||||
|  | ||||
| 	"github.com/containerd/containerd/platforms" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	"github.com/containerd/containerd/snapshots/btrfs" | ||||
| ) | ||||
|  | ||||
| @@ -37,7 +38,7 @@ type Config struct { | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		ID:     "btrfs", | ||||
| 		Type:   plugin.SnapshotPlugin, | ||||
| 		Type:   plugins.SnapshotPlugin, | ||||
| 		Config: &Config{}, | ||||
| 		InitFn: func(ic *plugin.InitContext) (interface{}, error) { | ||||
| 			ic.Meta.Platforms = []ocispec.Platform{platforms.DefaultSpec()} | ||||
|   | ||||
| @@ -24,12 +24,13 @@ import ( | ||||
|  | ||||
| 	"github.com/containerd/containerd/platforms" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	"github.com/containerd/containerd/snapshots/devmapper" | ||||
| ) | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type:   plugin.SnapshotPlugin, | ||||
| 		Type:   plugins.SnapshotPlugin, | ||||
| 		ID:     "devmapper", | ||||
| 		Config: &devmapper.Config{}, | ||||
| 		InitFn: func(ic *plugin.InitContext) (interface{}, error) { | ||||
|   | ||||
| @@ -37,6 +37,7 @@ import ( | ||||
| 	"github.com/containerd/containerd/errdefs" | ||||
| 	"github.com/containerd/containerd/mount" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	"github.com/containerd/containerd/snapshots" | ||||
| 	"github.com/containerd/containerd/snapshots/storage" | ||||
| 	"github.com/containerd/continuity/fs" | ||||
| @@ -46,7 +47,7 @@ import ( | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type: plugin.SnapshotPlugin, | ||||
| 		Type: plugins.SnapshotPlugin, | ||||
| 		ID:   "windows-lcow", | ||||
| 		InitFn: func(ic *plugin.InitContext) (interface{}, error) { | ||||
| 			ic.Meta.Platforms = append(ic.Meta.Platforms, ocispec.Platform{ | ||||
|   | ||||
| @@ -21,6 +21,7 @@ import ( | ||||
|  | ||||
| 	"github.com/containerd/containerd/platforms" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	"github.com/containerd/containerd/snapshots/native" | ||||
| ) | ||||
|  | ||||
| @@ -32,7 +33,7 @@ type Config struct { | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type:   plugin.SnapshotPlugin, | ||||
| 		Type:   plugins.SnapshotPlugin, | ||||
| 		ID:     "native", | ||||
| 		Config: &Config{}, | ||||
| 		InitFn: func(ic *plugin.InitContext) (interface{}, error) { | ||||
|   | ||||
| @@ -23,6 +23,7 @@ import ( | ||||
|  | ||||
| 	"github.com/containerd/containerd/platforms" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"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{ | ||||
| 		Type:   plugin.SnapshotPlugin, | ||||
| 		Type:   plugins.SnapshotPlugin, | ||||
| 		ID:     "overlayfs", | ||||
| 		Config: &Config{}, | ||||
| 		InitFn: func(ic *plugin.InitContext) (interface{}, error) { | ||||
|   | ||||
| @@ -38,6 +38,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/snapshots" | ||||
| 	"github.com/containerd/containerd/snapshots/storage" | ||||
| 	"github.com/containerd/continuity/fs" | ||||
| @@ -47,7 +48,7 @@ import ( | ||||
|  | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		Type: plugin.SnapshotPlugin, | ||||
| 		Type: plugins.SnapshotPlugin, | ||||
| 		ID:   "windows", | ||||
| 		InitFn: func(ic *plugin.InitContext) (interface{}, error) { | ||||
| 			ic.Meta.Platforms = []ocispec.Platform{platforms.DefaultSpec()} | ||||
|   | ||||
							
								
								
									
										8
									
								
								task.go
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								task.go
									
									
									
									
									
								
							| @@ -35,7 +35,7 @@ import ( | ||||
| 	"github.com/containerd/containerd/images" | ||||
| 	"github.com/containerd/containerd/mount" | ||||
| 	"github.com/containerd/containerd/oci" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	"github.com/containerd/containerd/protobuf" | ||||
| 	google_protobuf "github.com/containerd/containerd/protobuf/types" | ||||
| 	"github.com/containerd/containerd/rootfs" | ||||
| @@ -309,7 +309,7 @@ func (t *task) Delete(ctx context.Context, opts ...ProcessDeleteOpts) (*ExitStat | ||||
| 	switch status.Status { | ||||
| 	case Stopped, Unknown, "": | ||||
| 	case Created: | ||||
| 		if t.client.runtime == plugin.RuntimePlugin.String()+".windows" { | ||||
| 		if t.client.runtime == plugins.RuntimePlugin.String()+".windows" { | ||||
| 			// On windows Created is akin to Stopped | ||||
| 			break | ||||
| 		} | ||||
| @@ -326,7 +326,7 @@ func (t *task) Delete(ctx context.Context, opts ...ProcessDeleteOpts) (*ExitStat | ||||
| 		// io.Wait locks for restored tasks on Windows unless we call | ||||
| 		// io.Close first (https://github.com/containerd/containerd/issues/5621) | ||||
| 		// in other cases, preserve the contract and let IO finish before closing | ||||
| 		if t.client.runtime == plugin.RuntimePlugin.String()+".windows" { | ||||
| 		if t.client.runtime == plugins.RuntimePlugin.String()+".windows" { | ||||
| 			t.io.Close() | ||||
| 		} | ||||
| 		// io.Cancel is used to cancel the io goroutine while it is in | ||||
| @@ -690,7 +690,7 @@ func isCheckpointPathExist(runtime string, v interface{}) bool { | ||||
| 	} | ||||
|  | ||||
| 	switch runtime { | ||||
| 	case plugin.RuntimeRuncV2: | ||||
| 	case plugins.RuntimeRuncV2: | ||||
| 		if opts, ok := v.(*options.CheckpointOptions); ok && opts.ImagePath != "" { | ||||
| 			return true | ||||
| 		} | ||||
|   | ||||
| @@ -25,6 +25,7 @@ import ( | ||||
|  | ||||
| 	"github.com/containerd/containerd/errdefs" | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	"github.com/containerd/containerd/plugins" | ||||
| 	"github.com/containerd/containerd/tracing" | ||||
| 	"github.com/containerd/log" | ||||
| 	"github.com/sirupsen/logrus" | ||||
| @@ -43,7 +44,7 @@ const exporterPlugin = "otlp" | ||||
| func init() { | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		ID:     exporterPlugin, | ||||
| 		Type:   plugin.TracingProcessorPlugin, | ||||
| 		Type:   plugins.TracingProcessorPlugin, | ||||
| 		Config: &OTLPConfig{}, | ||||
| 		InitFn: func(ic *plugin.InitContext) (interface{}, error) { | ||||
| 			cfg := ic.Config.(*OTLPConfig) | ||||
| @@ -55,13 +56,18 @@ func init() { | ||||
| 		}, | ||||
| 	}) | ||||
| 	plugin.Register(&plugin.Registration{ | ||||
| 		ID:       "tracing", | ||||
| 		Type:     plugin.InternalPlugin, | ||||
| 		Requires: []plugin.Type{plugin.TracingProcessorPlugin}, | ||||
| 		Config:   &TraceConfig{ServiceName: "containerd", TraceSamplingRatio: 1.0}, | ||||
| 		ID:   "tracing", | ||||
| 		Type: plugins.InternalPlugin, | ||||
| 		Requires: []plugin.Type{ | ||||
| 			plugins.TracingProcessorPlugin, | ||||
| 		}, | ||||
| 		Config: &TraceConfig{ | ||||
| 			ServiceName:        "containerd", | ||||
| 			TraceSamplingRatio: 1.0, | ||||
| 		}, | ||||
| 		InitFn: func(ic *plugin.InitContext) (interface{}, error) { | ||||
| 			//get TracingProcessorPlugin which is a dependency | ||||
| 			plugins, err := ic.GetByType(plugin.TracingProcessorPlugin) | ||||
| 			plugins, err := ic.GetByType(plugins.TracingProcessorPlugin) | ||||
| 			if err != nil { | ||||
| 				return nil, fmt.Errorf("failed to get tracing processors: %w", err) | ||||
| 			} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Derek McGowan
					Derek McGowan