WithInMemoryServices is suitable for cases when there is need to use containerd's client from another (in-memory) containerd plugin (such as CRI).
(ic *plugin.InitContext)
| 184 | // WithInMemoryServices is suitable for cases when there is need to use containerd's client from |
| 185 | // another (in-memory) containerd plugin (such as CRI). |
| 186 | func WithInMemoryServices(ic *plugin.InitContext) Opt { |
| 187 | return func(c *clientOpts) error { |
| 188 | var opts []ServicesOpt |
| 189 | for t, fn := range map[plugin.Type]func(any) ServicesOpt{ |
| 190 | plugins.EventPlugin: func(i any) ServicesOpt { |
| 191 | return WithEventService(i.(EventService)) |
| 192 | }, |
| 193 | plugins.LeasePlugin: func(i any) ServicesOpt { |
| 194 | return WithLeasesService(i.(leases.Manager)) |
| 195 | }, |
| 196 | plugins.SandboxStorePlugin: func(i any) ServicesOpt { |
| 197 | return WithSandboxStore(i.(sandbox.Store)) |
| 198 | }, |
| 199 | plugins.TransferPlugin: func(i any) ServicesOpt { |
| 200 | return WithTransferService(i.(transfer.Transferrer)) |
| 201 | }, |
| 202 | plugins.MountManagerPlugin: func(i any) ServicesOpt { |
| 203 | return WithMountManager(i.(mount.Manager)) |
| 204 | }, |
| 205 | } { |
| 206 | i, err := ic.GetSingle(t) |
| 207 | if err != nil { |
| 208 | return fmt.Errorf("failed to get %q plugin: %w", t, err) |
| 209 | } |
| 210 | opts = append(opts, fn(i)) |
| 211 | } |
| 212 | |
| 213 | plugins, err := ic.GetByType(plugins.ServicePlugin) |
| 214 | if err != nil { |
| 215 | return fmt.Errorf("failed to get service plugin: %w", err) |
| 216 | } |
| 217 | for s, fn := range map[string]func(any) ServicesOpt{ |
| 218 | srv.ContentService: func(s any) ServicesOpt { |
| 219 | return WithContentStore(s.(content.Store)) |
| 220 | }, |
| 221 | srv.ImagesService: func(s any) ServicesOpt { |
| 222 | return WithImageClient(s.(imagesapi.ImagesClient)) |
| 223 | }, |
| 224 | srv.SnapshotsService: func(s any) ServicesOpt { |
| 225 | return WithSnapshotters(s.(map[string]snapshots.Snapshotter)) |
| 226 | }, |
| 227 | srv.ContainersService: func(s any) ServicesOpt { |
| 228 | return WithContainerClient(s.(containersapi.ContainersClient)) |
| 229 | }, |
| 230 | srv.TasksService: func(s any) ServicesOpt { |
| 231 | return WithTaskClient(s.(tasks.TasksClient)) |
| 232 | }, |
| 233 | srv.DiffService: func(s any) ServicesOpt { |
| 234 | return WithDiffClient(s.(diff.DiffClient)) |
| 235 | }, |
| 236 | srv.NamespacesService: func(s any) ServicesOpt { |
| 237 | return WithNamespaceClient(s.(namespacesapi.NamespacesClient)) |
| 238 | }, |
| 239 | srv.IntrospectionService: func(s any) ServicesOpt { |
| 240 | return WithIntrospectionService(s.(introspection.Service)) |
| 241 | }, |
| 242 | } { |
| 243 | i := plugins[s] |
nothing calls this directly
no test coverage detected
searching dependent graphs…