MCPcopy Index your code
hub / github.com/containerd/containerd / init

Function init

plugins/sandbox/controller.go:45–93  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

43)
44
45func init() {
46 registry.Register(&plugin.Registration{
47 Type: plugins.SandboxControllerPlugin,
48 ID: "shim",
49 Requires: []plugin.Type{
50 plugins.ShimPlugin,
51 plugins.EventPlugin,
52 },
53 InitFn: func(ic *plugin.InitContext) (any, error) {
54 shimPlugin, err := ic.GetSingle(plugins.ShimPlugin)
55 if err != nil {
56 return nil, err
57 }
58
59 exchangePlugin, err := ic.GetByID(plugins.EventPlugin, "exchange")
60 if err != nil {
61 return nil, err
62 }
63
64 var (
65 shims = shimPlugin.(*v2.ShimManager)
66 publisher = exchangePlugin.(*exchange.Exchange)
67 )
68 state := ic.Properties[plugins.PropertyStateDir]
69 root := ic.Properties[plugins.PropertyRootDir]
70 for _, d := range []string{root, state} {
71 if err := os.MkdirAll(d, 0700); err != nil {
72 return nil, err
73 }
74 // chmod is needed for upgrading from an older release that created the dir with 0o711
75 if err := os.Chmod(d, 0o700); err != nil {
76 return nil, err
77 }
78 }
79
80 if err := shims.LoadExistingShims(ic.Context, state, root); err != nil {
81 return nil, fmt.Errorf("failed to load existing shim sandboxes, %v", err)
82 }
83
84 c := &controllerLocal{
85 root: root,
86 state: state,
87 shims: shims,
88 publisher: publisher,
89 }
90 return c, nil
91 },
92 })
93}
94
95type controllerLocal struct {
96 root string

Callers

nothing calls this directly

Calls 3

LoadExistingShimsMethod · 0.80
RegisterMethod · 0.65
MkdirAllMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…