|
@@ -27,17 +27,18 @@ import (
|
|
|
|
|
|
// ImageService implements daemon.ImageService
|
|
// ImageService implements daemon.ImageService
|
|
type ImageService struct {
|
|
type ImageService struct {
|
|
- client *containerd.Client
|
|
|
|
- images images.Store
|
|
|
|
- content content.Store
|
|
|
|
- containers container.Store
|
|
|
|
- snapshotter string
|
|
|
|
- registryHosts docker.RegistryHosts
|
|
|
|
- registryService registryResolver
|
|
|
|
- eventsService *daemonevents.Events
|
|
|
|
- pruneRunning atomic.Bool
|
|
|
|
- refCountMounter snapshotter.Mounter
|
|
|
|
- idMapping idtools.IdentityMapping
|
|
|
|
|
|
+ client *containerd.Client
|
|
|
|
+ images images.Store
|
|
|
|
+ content content.Store
|
|
|
|
+ containers container.Store
|
|
|
|
+ snapshotterServices map[string]snapshots.Snapshotter
|
|
|
|
+ snapshotter string
|
|
|
|
+ registryHosts docker.RegistryHosts
|
|
|
|
+ registryService registryResolver
|
|
|
|
+ eventsService *daemonevents.Events
|
|
|
|
+ pruneRunning atomic.Bool
|
|
|
|
+ refCountMounter snapshotter.Mounter
|
|
|
|
+ idMapping idtools.IdentityMapping
|
|
}
|
|
}
|
|
|
|
|
|
type registryResolver interface {
|
|
type registryResolver interface {
|
|
@@ -61,9 +62,12 @@ type ImageServiceConfig struct {
|
|
// NewService creates a new ImageService.
|
|
// NewService creates a new ImageService.
|
|
func NewService(config ImageServiceConfig) *ImageService {
|
|
func NewService(config ImageServiceConfig) *ImageService {
|
|
return &ImageService{
|
|
return &ImageService{
|
|
- client: config.Client,
|
|
|
|
- images: config.Client.ImageService(),
|
|
|
|
- content: config.Client.ContentStore(),
|
|
|
|
|
|
+ client: config.Client,
|
|
|
|
+ images: config.Client.ImageService(),
|
|
|
|
+ content: config.Client.ContentStore(),
|
|
|
|
+ snapshotterServices: map[string]snapshots.Snapshotter{
|
|
|
|
+ config.Snapshotter: config.Client.SnapshotService(config.Snapshotter),
|
|
|
|
+ },
|
|
containers: config.Containers,
|
|
containers: config.Containers,
|
|
snapshotter: config.Snapshotter,
|
|
snapshotter: config.Snapshotter,
|
|
registryHosts: config.RegistryHosts,
|
|
registryHosts: config.RegistryHosts,
|
|
@@ -74,6 +78,16 @@ func NewService(config ImageServiceConfig) *ImageService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func (i *ImageService) snapshotterService(snapshotter string) snapshots.Snapshotter {
|
|
|
|
+ s, ok := i.snapshotterServices[snapshotter]
|
|
|
|
+ if !ok {
|
|
|
|
+ s = i.client.SnapshotService(snapshotter)
|
|
|
|
+ i.snapshotterServices[snapshotter] = s
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return s
|
|
|
|
+}
|
|
|
|
+
|
|
// DistributionServices return services controlling daemon image storage.
|
|
// DistributionServices return services controlling daemon image storage.
|
|
func (i *ImageService) DistributionServices() dimages.DistributionServices {
|
|
func (i *ImageService) DistributionServices() dimages.DistributionServices {
|
|
return dimages.DistributionServices{}
|
|
return dimages.DistributionServices{}
|