Skip to content

Commit ea36c3c

Browse files
committed
daemon: access to distribution internals
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
1 parent 6fcb36f commit ea36c3c

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

daemon/daemon.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,10 @@ func NewDaemon(config *config.Config, registryService registry.Service, containe
922922
return d, nil
923923
}
924924

925+
func (daemon *Daemon) DistributionServices() images.DistributionServices {
926+
return daemon.imageService.DistributionServices()
927+
}
928+
925929
func (daemon *Daemon) waitForStartupDone() {
926930
<-daemon.startupDone
927931
}

daemon/images/service.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ package images // import "github.com/docker/docker/daemon/images"
33
import (
44
"context"
55
"os"
6+
"runtime"
67

78
"github.com/docker/docker/container"
89
daemonevents "github.com/docker/docker/daemon/events"
10+
"github.com/docker/docker/distribution"
911
"github.com/docker/docker/distribution/metadata"
1012
"github.com/docker/docker/distribution/xfer"
1113
"github.com/docker/docker/image"
@@ -74,6 +76,24 @@ type ImageService struct {
7476
uploadManager *xfer.LayerUploadManager
7577
}
7678

79+
type DistributionServices struct {
80+
DownloadManager distribution.RootFSDownloadManager
81+
V2MetadataService metadata.V2MetadataService
82+
LayerStore layer.Store // TODO: lcow
83+
ImageStore image.Store
84+
ReferenceStore dockerreference.Store
85+
}
86+
87+
func (i *ImageService) DistributionServices() DistributionServices {
88+
return DistributionServices{
89+
DownloadManager: i.downloadManager,
90+
V2MetadataService: metadata.NewV2MetadataService(i.distributionMetadataStore),
91+
LayerStore: i.layerStores[runtime.GOOS],
92+
ImageStore: i.imageStore,
93+
ReferenceStore: i.referenceStore,
94+
}
95+
}
96+
7797
// CountImages returns the number of images stored by ImageService
7898
// called from info.go
7999
func (i *ImageService) CountImages() int {

layer/layer_store.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ func newStoreFromGraphDriver(root string, driver graphdriver.Driver, os string)
121121
return ls, nil
122122
}
123123

124+
func (ls *layerStore) Driver() graphdriver.Driver {
125+
return ls.driver
126+
}
127+
124128
func (ls *layerStore) loadLayer(layer ChainID) (*roLayer, error) {
125129
cl, ok := ls.layerMap[layer]
126130
if ok {

layer/ro_layer.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ func (rl *roLayer) TarStreamFrom(parent ChainID) (io.ReadCloser, error) {
5454
return rl.layerStore.driver.Diff(rl.cacheID, parentCacheID)
5555
}
5656

57+
func (rl *roLayer) CacheID() string {
58+
return rl.cacheID
59+
}
60+
5761
func (rl *roLayer) ChainID() ChainID {
5862
return rl.chainID
5963
}

0 commit comments

Comments
 (0)