| 1 |
/* |
| 2 |
Copyright The containerd Authors. |
| 3 |
|
| 4 |
Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 |
you may not use this file except in compliance with the License. |
| 6 |
You may obtain a copy of the License at |
| 7 |
|
| 8 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
|
| 10 |
Unless required by applicable law or agreed to in writing, software |
| 11 |
distributed under the License is distributed on an "AS IS" BASIS, |
| 12 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 |
See the License for the specific language governing permissions and |
| 14 |
limitations under the License. |
| 15 |
*/ |
| 16 |
|
| 17 |
package plugin |
| 18 |
|
| 19 |
import ( |
| 20 |
"github.com/containerd/containerd/v2/cmd/containerd-shim-runc-v2/task" |
| 21 |
"github.com/containerd/containerd/v2/pkg/shim" |
| 22 |
"github.com/containerd/containerd/v2/pkg/shutdown" |
| 23 |
"github.com/containerd/containerd/v2/plugins" |
| 24 |
"github.com/containerd/plugin" |
| 25 |
"github.com/containerd/plugin/registry" |
| 26 |
) |
| 27 |
|
| 28 |
func init() { |
| 29 |
registry.Register(&plugin.Registration{ |
| 30 |
Type: plugins.TTRPCPlugin, |
| 31 |
ID: "task", |
| 32 |
Requires: []plugin.Type{ |
| 33 |
plugins.EventPlugin, |
| 34 |
plugins.InternalPlugin, |
| 35 |
}, |
| 36 |
InitFn: func(ic *plugin.InitContext) (interface{}, error) { |
| 37 |
pp, err := ic.GetByID(plugins.EventPlugin, "publisher") |
| 38 |
if err != nil { |
| 39 |
return nil, err |
| 40 |
} |
| 41 |
ss, err := ic.GetByID(plugins.InternalPlugin, "shutdown") |
| 42 |
if err != nil { |
| 43 |
return nil, err |
| 44 |
} |
| 45 |
return task.NewTaskService(ic.Context, pp.(shim.Publisher), ss.(shutdown.Service)) |
| 46 |
}, |
| 47 |
}) |
| 48 |
|
| 49 |
} |