()
| 39 | ) |
| 40 | |
| 41 | func 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{}, |
nothing calls this directly
no test coverage detected
searching dependent graphs…