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

Function LoadPlugins

cmd/containerd/server/server.go:301–375  ·  view source on GitHub ↗

LoadPlugins loads all plugins into containerd and generates an ordered graph of all plugins.

(ctx context.Context, config *srvconfig.Config)

Source from the content-addressed store, hash-verified

299// LoadPlugins loads all plugins into containerd and generates an ordered graph
300// of all plugins.
301func LoadPlugins(ctx context.Context, config *srvconfig.Config) ([]plugin.Registration, error) {
302 // load all plugins into containerd
303 clients := &proxyClients{}
304 for name, pp := range config.ProxyPlugins {
305 var (
306 t plugin.Type
307 f func(*grpc.ClientConn) any
308
309 address = pp.Address
310 p v1.Platform
311 err error
312 )
313
314 switch pp.Type {
315 case string(plugins.SnapshotPlugin), "snapshot":
316 t = plugins.SnapshotPlugin
317 ssname := name
318 f = func(conn *grpc.ClientConn) any {
319 return ssproxy.NewSnapshotter(ssapi.NewSnapshotsClient(conn), ssname)
320 }
321
322 case string(plugins.ContentPlugin), "content":
323 t = plugins.ContentPlugin
324 f = func(conn *grpc.ClientConn) any {
325 return csproxy.NewContentStore(conn)
326 }
327 case string(plugins.SandboxControllerPlugin), "sandbox":
328 t = plugins.SandboxControllerPlugin
329 f = func(conn *grpc.ClientConn) any {
330 return sbproxy.NewSandboxController(sbapi.NewControllerClient(conn), name)
331 }
332 case string(plugins.DiffPlugin), "diff":
333 t = plugins.DiffPlugin
334 f = func(conn *grpc.ClientConn) any {
335 return diffproxy.NewDiffApplier(diffapi.NewDiffClient(conn))
336 }
337 default:
338 log.G(ctx).WithField("type", pp.Type).Warn("unknown proxy plugin type")
339 }
340 if pp.Platform != "" {
341 p, err = platforms.Parse(pp.Platform)
342 if err != nil {
343 log.G(ctx).WithFields(log.Fields{"error": err, "plugin": name}).Warn("skipping proxy platform with bad platform")
344 }
345 } else {
346 p = platforms.DefaultSpec()
347 }
348
349 exports := pp.Exports
350 if exports == nil {
351 exports = map[string]string{}
352 }
353 exports["address"] = address
354
355 registry.Register(&plugin.Registration{
356 Type: t,
357 ID: name,
358 InitFn: func(ic *plugin.InitContext) (any, error) {

Callers 2

outputConfigFunction · 0.92
NewFunction · 0.85

Calls 2

getClientMethod · 0.95
RegisterMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…