1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

daemon: access to distribution internals

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi 2018-04-17 11:56:28 -07:00
parent 6fcb36ff14
commit ea36c3cbaf
4 changed files with 32 additions and 0 deletions

View file

@ -922,6 +922,10 @@ func NewDaemon(config *config.Config, registryService registry.Service, containe
return d, nil return d, nil
} }
func (daemon *Daemon) DistributionServices() images.DistributionServices {
return daemon.imageService.DistributionServices()
}
func (daemon *Daemon) waitForStartupDone() { func (daemon *Daemon) waitForStartupDone() {
<-daemon.startupDone <-daemon.startupDone
} }

View file

@ -3,9 +3,11 @@ package images // import "github.com/docker/docker/daemon/images"
import ( import (
"context" "context"
"os" "os"
"runtime"
"github.com/docker/docker/container" "github.com/docker/docker/container"
daemonevents "github.com/docker/docker/daemon/events" daemonevents "github.com/docker/docker/daemon/events"
"github.com/docker/docker/distribution"
"github.com/docker/docker/distribution/metadata" "github.com/docker/docker/distribution/metadata"
"github.com/docker/docker/distribution/xfer" "github.com/docker/docker/distribution/xfer"
"github.com/docker/docker/image" "github.com/docker/docker/image"
@ -74,6 +76,24 @@ type ImageService struct {
uploadManager *xfer.LayerUploadManager uploadManager *xfer.LayerUploadManager
} }
type DistributionServices struct {
DownloadManager distribution.RootFSDownloadManager
V2MetadataService metadata.V2MetadataService
LayerStore layer.Store // TODO: lcow
ImageStore image.Store
ReferenceStore dockerreference.Store
}
func (i *ImageService) DistributionServices() DistributionServices {
return DistributionServices{
DownloadManager: i.downloadManager,
V2MetadataService: metadata.NewV2MetadataService(i.distributionMetadataStore),
LayerStore: i.layerStores[runtime.GOOS],
ImageStore: i.imageStore,
ReferenceStore: i.referenceStore,
}
}
// CountImages returns the number of images stored by ImageService // CountImages returns the number of images stored by ImageService
// called from info.go // called from info.go
func (i *ImageService) CountImages() int { func (i *ImageService) CountImages() int {

View file

@ -121,6 +121,10 @@ func newStoreFromGraphDriver(root string, driver graphdriver.Driver, os string)
return ls, nil return ls, nil
} }
func (ls *layerStore) Driver() graphdriver.Driver {
return ls.driver
}
func (ls *layerStore) loadLayer(layer ChainID) (*roLayer, error) { func (ls *layerStore) loadLayer(layer ChainID) (*roLayer, error) {
cl, ok := ls.layerMap[layer] cl, ok := ls.layerMap[layer]
if ok { if ok {

View file

@ -54,6 +54,10 @@ func (rl *roLayer) TarStreamFrom(parent ChainID) (io.ReadCloser, error) {
return rl.layerStore.driver.Diff(rl.cacheID, parentCacheID) return rl.layerStore.driver.Diff(rl.cacheID, parentCacheID)
} }
func (rl *roLayer) CacheID() string {
return rl.cacheID
}
func (rl *roLayer) ChainID() ChainID { func (rl *roLayer) ChainID() ChainID {
return rl.chainID return rl.chainID
} }