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

Function init

plugins/cri/images/plugin.go:41–173  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

39)
40
41func init() {
42 config := criconfig.DefaultImageConfig()
43
44 registry.Register(&plugin.Registration{
45 Type: plugins.CRIServicePlugin,
46 ID: "images",
47 Config: &config,
48 Requires: []plugin.Type{
49 plugins.LeasePlugin,
50 plugins.MetadataPlugin,
51 plugins.SandboxStorePlugin,
52 plugins.ServicePlugin, // For client
53 plugins.SnapshotPlugin, // For root directory properties
54 plugins.TransferPlugin, // For pulling image using transfer service
55 plugins.WarningPlugin,
56 },
57 InitFn: func(ic *plugin.InitContext) (any, error) {
58 m, err := ic.GetSingle(plugins.MetadataPlugin)
59 if err != nil {
60 return nil, err
61 }
62 mdb := m.(*metadata.DB)
63
64 // only set the default value of config path, if both mirrors and
65 // config path are empty and we are on Linux.
66 // This also makes sure that if the loaded config already contains both config path and mirrors
67 // the validation will fail.
68 if runtime.GOOS == "linux" {
69 if config.Registry.ConfigPath == "" && len(config.Registry.Mirrors) == 0 {
70 config.Registry.ConfigPath = "/etc/containerd/certs.d:/etc/docker/certs.d"
71 }
72 }
73
74 if warnings, err := criconfig.ValidateImageConfig(ic.Context, &config); err != nil {
75 return nil, fmt.Errorf("invalid cri image config: %w", err)
76 } else if len(warnings) > 0 {
77 ws, err := ic.GetSingle(plugins.WarningPlugin)
78 if err != nil {
79 return nil, err
80 }
81 warn := ws.(warning.Service)
82 for _, w := range warnings {
83 warn.Emit(ic.Context, w)
84 }
85 }
86
87 if !config.UseLocalImagePull {
88 criconfig.CheckLocalImagePullConfigs(ic.Context, &config)
89 }
90
91 ts, err := ic.GetSingle(plugins.TransferPlugin)
92 if err != nil {
93 return nil, err
94 }
95
96 options := &images.CRIImageServiceOptions{
97 Content: mdb.ContentStore(),
98 RuntimePlatforms: map[string]images.ImagePlatform{},

Callers

nothing calls this directly

Calls 10

NewServiceFunction · 0.92
SnapshottersMethod · 0.80
DirMethod · 0.80
RegisterMethod · 0.65
EmitMethod · 0.65
ContentStoreMethod · 0.65
ImageServiceMethod · 0.65
GetMethod · 0.65
PluginsMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…