builder: lint fixes
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
parent
1f09adbe16
commit
157b0b30db
|
@ -118,6 +118,7 @@ func (b *Backend) PruneCache(ctx context.Context) (*types.BuildCachePruneReport,
|
||||||
return &types.BuildCachePruneReport{SpaceReclaimed: fsCacheSize + uint64(buildCacheSize)}, nil
|
return &types.BuildCachePruneReport{SpaceReclaimed: fsCacheSize + uint64(buildCacheSize)}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cancel cancels the build by ID
|
||||||
func (b *Backend) Cancel(ctx context.Context, id string) error {
|
func (b *Backend) Cancel(ctx context.Context, id string) error {
|
||||||
return b.buildkit.Cancel(ctx, id)
|
return b.buildkit.Cancel(ctx, id)
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,10 +76,7 @@ func (s *systemRouter) getDiskUsage(ctx context.Context, w http.ResponseWriter,
|
||||||
eg.Go(func() error {
|
eg.Go(func() error {
|
||||||
var err error
|
var err error
|
||||||
du, err = s.backend.SystemDiskUsage(ctx)
|
du, err = s.backend.SystemDiskUsage(ctx)
|
||||||
if err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
|
||||||
return nil
|
|
||||||
})
|
})
|
||||||
|
|
||||||
var builderSize int64 // legacy
|
var builderSize int64 // legacy
|
||||||
|
|
|
@ -189,7 +189,9 @@ type ImageBuildOptions struct {
|
||||||
type BuilderVersion string
|
type BuilderVersion string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// BuilderV1 is the first generation builder in docker daemon
|
||||||
BuilderV1 BuilderVersion = "1"
|
BuilderV1 BuilderVersion = "1"
|
||||||
|
// BuilderBuildKit is builder based on moby/buildkit project
|
||||||
BuilderBuildKit = "2"
|
BuilderBuildKit = "2"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@ import (
|
||||||
|
|
||||||
const preferLocal = true // FIXME: make this optional from the op
|
const preferLocal = true // FIXME: make this optional from the op
|
||||||
|
|
||||||
|
// SourceOpt is options for creating the image source
|
||||||
type SourceOpt struct {
|
type SourceOpt struct {
|
||||||
SessionManager *session.Manager
|
SessionManager *session.Manager
|
||||||
ContentStore content.Store
|
ContentStore content.Store
|
||||||
|
@ -58,6 +59,7 @@ type imageSource struct {
|
||||||
g flightcontrol.Group
|
g flightcontrol.Group
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewSource creates a new image source
|
||||||
func NewSource(opt SourceOpt) (source.Source, error) {
|
func NewSource(opt SourceOpt) (source.Source, error) {
|
||||||
is := &imageSource{
|
is := &imageSource{
|
||||||
SourceOpt: opt,
|
SourceOpt: opt,
|
||||||
|
|
|
@ -69,10 +69,7 @@ func (s *snapshotter) EnsureLayer(ctx context.Context, key string) ([]layer.Diff
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
diffID, size, err = s.reg.ChecksumForGraphID(id, parent, "", tarSplitPath)
|
diffID, size, err = s.reg.ChecksumForGraphID(id, parent, "", tarSplitPath)
|
||||||
if err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
|
||||||
return nil
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if err := eg.Wait(); err != nil {
|
if err := eg.Wait(); err != nil {
|
||||||
|
|
|
@ -23,6 +23,7 @@ var keyCommitted = []byte("committed")
|
||||||
var keyChainID = []byte("chainid")
|
var keyChainID = []byte("chainid")
|
||||||
var keySize = []byte("size")
|
var keySize = []byte("size")
|
||||||
|
|
||||||
|
// Opt defines options for creating the snapshotter
|
||||||
type Opt struct {
|
type Opt struct {
|
||||||
GraphDriver graphdriver.Driver
|
GraphDriver graphdriver.Driver
|
||||||
LayerStore layer.Store
|
LayerStore layer.Store
|
||||||
|
@ -50,6 +51,7 @@ type snapshotter struct {
|
||||||
|
|
||||||
var _ snapshot.SnapshotterBase = &snapshotter{}
|
var _ snapshot.SnapshotterBase = &snapshotter{}
|
||||||
|
|
||||||
|
// NewSnapshotter creates a new snapshotter
|
||||||
func NewSnapshotter(opt Opt) (snapshot.SnapshotterBase, error) {
|
func NewSnapshotter(opt Opt) (snapshot.SnapshotterBase, error) {
|
||||||
dbPath := filepath.Join(opt.Root, "snapshots.db")
|
dbPath := filepath.Join(opt.Root, "snapshots.db")
|
||||||
db, err := bolt.Open(dbPath, 0600, nil)
|
db, err := bolt.Open(dbPath, 0600, nil)
|
||||||
|
@ -196,7 +198,7 @@ func (s *snapshotter) Stat(ctx context.Context, key string) (snapshots.Info, err
|
||||||
inf.Parent = p.ChainID().String()
|
inf.Parent = p.ChainID().String()
|
||||||
}
|
}
|
||||||
inf.Kind = snapshots.KindCommitted
|
inf.Kind = snapshots.KindCommitted
|
||||||
inf.Name = string(key)
|
inf.Name = key
|
||||||
return inf, nil
|
return inf, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,7 +217,7 @@ func (s *snapshotter) Stat(ctx context.Context, key string) (snapshots.Info, err
|
||||||
if b == nil && l == nil {
|
if b == nil && l == nil {
|
||||||
return errors.Errorf("snapshot %s not found", id) // TODO: typed
|
return errors.Errorf("snapshot %s not found", id) // TODO: typed
|
||||||
}
|
}
|
||||||
inf.Name = string(key)
|
inf.Name = key
|
||||||
if b != nil {
|
if b != nil {
|
||||||
v := b.Get(keyParent)
|
v := b.Get(keyParent)
|
||||||
if v != nil {
|
if v != nil {
|
||||||
|
@ -322,7 +324,7 @@ func (s *snapshotter) Remove(ctx context.Context, key string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *snapshotter) Commit(ctx context.Context, name, key string, opts ...snapshots.Opt) error {
|
func (s *snapshotter) Commit(ctx context.Context, name, key string, opts ...snapshots.Opt) error {
|
||||||
if err := s.db.Update(func(tx *bolt.Tx) error {
|
return s.db.Update(func(tx *bolt.Tx) error {
|
||||||
b, err := tx.CreateBucketIfNotExists([]byte(name))
|
b, err := tx.CreateBucketIfNotExists([]byte(name))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -331,10 +333,7 @@ func (s *snapshotter) Commit(ctx context.Context, name, key string, opts ...snap
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}); err != nil {
|
})
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *snapshotter) View(ctx context.Context, key, parent string, opts ...snapshots.Opt) (snapshot.Mountable, error) {
|
func (s *snapshotter) View(ctx context.Context, key, parent string, opts ...snapshots.Opt) (snapshot.Mountable, error) {
|
||||||
|
@ -421,7 +420,7 @@ func (s *snapshotter) Usage(ctx context.Context, key string) (us snapshots.Usage
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return usage, err
|
return usage, err
|
||||||
}
|
}
|
||||||
usage.Size = int64(diffSize)
|
usage.Size = diffSize
|
||||||
return usage, nil
|
return usage, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,12 +24,14 @@ import (
|
||||||
grpcmetadata "google.golang.org/grpc/metadata"
|
grpcmetadata "google.golang.org/grpc/metadata"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Opt is option struct required for creating the builder
|
||||||
type Opt struct {
|
type Opt struct {
|
||||||
SessionManager *session.Manager
|
SessionManager *session.Manager
|
||||||
Root string
|
Root string
|
||||||
Dist images.DistributionServices
|
Dist images.DistributionServices
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Builder can build using BuildKit backend
|
||||||
type Builder struct {
|
type Builder struct {
|
||||||
controller *control.Controller
|
controller *control.Controller
|
||||||
reqBodyHandler *reqBodyHandler
|
reqBodyHandler *reqBodyHandler
|
||||||
|
@ -38,6 +40,7 @@ type Builder struct {
|
||||||
jobs map[string]*buildJob
|
jobs map[string]*buildJob
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// New creates a new builder
|
||||||
func New(opt Opt) (*Builder, error) {
|
func New(opt Opt) (*Builder, error) {
|
||||||
reqHandler := newReqBodyHandler(tracing.DefaultTransport)
|
reqHandler := newReqBodyHandler(tracing.DefaultTransport)
|
||||||
|
|
||||||
|
@ -53,6 +56,7 @@ func New(opt Opt) (*Builder, error) {
|
||||||
return b, nil
|
return b, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cancel cancels a build using ID
|
||||||
func (b *Builder) Cancel(ctx context.Context, id string) error {
|
func (b *Builder) Cancel(ctx context.Context, id string) error {
|
||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
if j, ok := b.jobs[id]; ok && j.cancel != nil {
|
if j, ok := b.jobs[id]; ok && j.cancel != nil {
|
||||||
|
@ -62,6 +66,7 @@ func (b *Builder) Cancel(ctx context.Context, id string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DiskUsage returns a report about space used by build cache
|
||||||
func (b *Builder) DiskUsage(ctx context.Context) ([]*types.BuildCache, error) {
|
func (b *Builder) DiskUsage(ctx context.Context) ([]*types.BuildCache, error) {
|
||||||
duResp, err := b.controller.DiskUsage(ctx, &controlapi.DiskUsageRequest{})
|
duResp, err := b.controller.DiskUsage(ctx, &controlapi.DiskUsageRequest{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -86,6 +91,7 @@ func (b *Builder) DiskUsage(ctx context.Context) ([]*types.BuildCache, error) {
|
||||||
return items, nil
|
return items, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Prune clears all reclaimable build cache
|
||||||
func (b *Builder) Prune(ctx context.Context) (int64, error) {
|
func (b *Builder) Prune(ctx context.Context) (int64, error) {
|
||||||
ch := make(chan *controlapi.UsageRecord)
|
ch := make(chan *controlapi.UsageRecord)
|
||||||
|
|
||||||
|
@ -114,6 +120,7 @@ func (b *Builder) Prune(ctx context.Context) (int64, error) {
|
||||||
return size, nil
|
return size, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Build executes a build request
|
||||||
func (b *Builder) Build(ctx context.Context, opt backend.BuildConfig) (*builder.Result, error) {
|
func (b *Builder) Build(ctx context.Context, opt backend.BuildConfig) (*builder.Result, error) {
|
||||||
var rc = opt.Source
|
var rc = opt.Source
|
||||||
|
|
||||||
|
@ -181,10 +188,8 @@ func (b *Builder) Build(ctx context.Context, opt backend.BuildConfig) (*builder.
|
||||||
frontendAttrs["context"] = url
|
frontendAttrs["context"] = url
|
||||||
}
|
}
|
||||||
|
|
||||||
var cacheFrom []string
|
cacheFrom := append([]string{}, opt.Options.CacheFrom...)
|
||||||
for _, v := range opt.Options.CacheFrom {
|
|
||||||
cacheFrom = append(cacheFrom, v)
|
|
||||||
}
|
|
||||||
frontendAttrs["cache-from"] = strings.Join(cacheFrom, ",")
|
frontendAttrs["cache-from"] = strings.Join(cacheFrom, ",")
|
||||||
|
|
||||||
for k, v := range opt.Options.BuildArgs {
|
for k, v := range opt.Options.BuildArgs {
|
||||||
|
|
|
@ -117,7 +117,7 @@ func newController(rt http.RoundTripper, opt Opt) (*control.Controller, error) {
|
||||||
frontends["dockerfile.v0"] = dockerfile.NewDockerfileFrontend()
|
frontends["dockerfile.v0"] = dockerfile.NewDockerfileFrontend()
|
||||||
frontends["gateway.v0"] = gateway.NewGatewayFrontend()
|
frontends["gateway.v0"] = gateway.NewGatewayFrontend()
|
||||||
|
|
||||||
wopt := mobyworker.WorkerOpt{
|
wopt := mobyworker.Opt{
|
||||||
ID: "moby",
|
ID: "moby",
|
||||||
SessionManager: opt.SessionManager,
|
SessionManager: opt.SessionManager,
|
||||||
MetadataStore: md,
|
MetadataStore: md,
|
||||||
|
|
|
@ -19,10 +19,12 @@ const (
|
||||||
exporterImageConfig = "containerimage.config"
|
exporterImageConfig = "containerimage.config"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Differ can make a moby layer from a snapshot
|
||||||
type Differ interface {
|
type Differ interface {
|
||||||
EnsureLayer(ctx context.Context, key string) ([]layer.DiffID, error)
|
EnsureLayer(ctx context.Context, key string) ([]layer.DiffID, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Opt defines a struct for creating new exporter
|
||||||
type Opt struct {
|
type Opt struct {
|
||||||
ImageStore image.Store
|
ImageStore image.Store
|
||||||
ReferenceStore reference.Store
|
ReferenceStore reference.Store
|
||||||
|
@ -33,6 +35,7 @@ type imageExporter struct {
|
||||||
opt Opt
|
opt Opt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// New creates a new moby imagestore exporter
|
||||||
func New(opt Opt) (exporter.Exporter, error) {
|
func New(opt Opt) (exporter.Exporter, error) {
|
||||||
im := &imageExporter{opt: opt}
|
im := &imageExporter{opt: opt}
|
||||||
return im, nil
|
return im, nil
|
||||||
|
|
|
@ -49,9 +49,8 @@ func patchImageConfig(dt []byte, dps []digest.Digest, history []ocispec.History)
|
||||||
|
|
||||||
var rootFS ocispec.RootFS
|
var rootFS ocispec.RootFS
|
||||||
rootFS.Type = "layers"
|
rootFS.Type = "layers"
|
||||||
for _, dp := range dps {
|
rootFS.DiffIDs = append(rootFS.DiffIDs, dps...)
|
||||||
rootFS.DiffIDs = append(rootFS.DiffIDs, dp)
|
|
||||||
}
|
|
||||||
dt, err := json.Marshal(rootFS)
|
dt, err := json.Marshal(rootFS)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "failed to marshal rootfs")
|
return nil, errors.Wrap(err, "failed to marshal rootfs")
|
||||||
|
@ -87,7 +86,7 @@ func normalizeLayersAndHistory(diffs []digest.Digest, history []ocispec.History,
|
||||||
var historyLayers int
|
var historyLayers int
|
||||||
for _, h := range history {
|
for _, h := range history {
|
||||||
if !h.EmptyLayer {
|
if !h.EmptyLayer {
|
||||||
historyLayers += 1
|
historyLayers++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if historyLayers > len(diffs) {
|
if historyLayers > len(diffs) {
|
||||||
|
|
|
@ -65,8 +65,3 @@ func (h *reqBodyHandler) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||||
}
|
}
|
||||||
return h.rt.RoundTrip(req)
|
return h.rt.RoundTrip(req)
|
||||||
}
|
}
|
||||||
|
|
||||||
type readCloser struct {
|
|
||||||
io.Reader
|
|
||||||
io.Closer
|
|
||||||
}
|
|
||||||
|
|
|
@ -39,9 +39,8 @@ import (
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
// WorkerOpt is specific to a worker.
|
// Opt defines a structure for creating a worker.
|
||||||
// See also CommonOpt.
|
type Opt struct {
|
||||||
type WorkerOpt struct {
|
|
||||||
ID string
|
ID string
|
||||||
Labels map[string]string
|
Labels map[string]string
|
||||||
SessionManager *session.Manager
|
SessionManager *session.Manager
|
||||||
|
@ -60,12 +59,12 @@ type WorkerOpt struct {
|
||||||
// Worker is a local worker instance with dedicated snapshotter, cache, and so on.
|
// Worker is a local worker instance with dedicated snapshotter, cache, and so on.
|
||||||
// TODO: s/Worker/OpWorker/g ?
|
// TODO: s/Worker/OpWorker/g ?
|
||||||
type Worker struct {
|
type Worker struct {
|
||||||
WorkerOpt
|
Opt
|
||||||
SourceManager *source.Manager
|
SourceManager *source.Manager
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewWorker instantiates a local worker
|
// NewWorker instantiates a local worker
|
||||||
func NewWorker(opt WorkerOpt) (*Worker, error) {
|
func NewWorker(opt Opt) (*Worker, error) {
|
||||||
sm, err := source.NewManager()
|
sm, err := source.NewManager()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -106,23 +105,27 @@ func NewWorker(opt WorkerOpt) (*Worker, error) {
|
||||||
sm.Register(ss)
|
sm.Register(ss)
|
||||||
|
|
||||||
return &Worker{
|
return &Worker{
|
||||||
WorkerOpt: opt,
|
Opt: opt,
|
||||||
SourceManager: sm,
|
SourceManager: sm,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ID returns worker ID
|
||||||
func (w *Worker) ID() string {
|
func (w *Worker) ID() string {
|
||||||
return w.WorkerOpt.ID
|
return w.Opt.ID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Labels returns map of all worker labels
|
||||||
func (w *Worker) Labels() map[string]string {
|
func (w *Worker) Labels() map[string]string {
|
||||||
return w.WorkerOpt.Labels
|
return w.Opt.Labels
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LoadRef loads a reference by ID
|
||||||
func (w *Worker) LoadRef(id string) (cache.ImmutableRef, error) {
|
func (w *Worker) LoadRef(id string) (cache.ImmutableRef, error) {
|
||||||
return w.CacheManager.Get(context.TODO(), id)
|
return w.CacheManager.Get(context.TODO(), id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ResolveOp converts a LLB vertex into a LLB operation
|
||||||
func (w *Worker) ResolveOp(v solver.Vertex, s frontend.FrontendLLBBridge) (solver.Op, error) {
|
func (w *Worker) ResolveOp(v solver.Vertex, s frontend.FrontendLLBBridge) (solver.Op, error) {
|
||||||
switch op := v.Sys().(type) {
|
switch op := v.Sys().(type) {
|
||||||
case *pb.Op_Source:
|
case *pb.Op_Source:
|
||||||
|
@ -136,6 +139,7 @@ func (w *Worker) ResolveOp(v solver.Vertex, s frontend.FrontendLLBBridge) (solve
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ResolveImageConfig returns image config for an image
|
||||||
func (w *Worker) ResolveImageConfig(ctx context.Context, ref string) (digest.Digest, []byte, error) {
|
func (w *Worker) ResolveImageConfig(ctx context.Context, ref string) (digest.Digest, []byte, error) {
|
||||||
// ImageSource is typically source/containerimage
|
// ImageSource is typically source/containerimage
|
||||||
resolveImageConfig, ok := w.ImageSource.(resolveImageConfig)
|
resolveImageConfig, ok := w.ImageSource.(resolveImageConfig)
|
||||||
|
@ -145,10 +149,7 @@ func (w *Worker) ResolveImageConfig(ctx context.Context, ref string) (digest.Dig
|
||||||
return resolveImageConfig.ResolveImageConfig(ctx, ref)
|
return resolveImageConfig.ResolveImageConfig(ctx, ref)
|
||||||
}
|
}
|
||||||
|
|
||||||
type resolveImageConfig interface {
|
// Exec executes a process directly on a worker
|
||||||
ResolveImageConfig(ctx context.Context, ref string) (digest.Digest, []byte, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Worker) Exec(ctx context.Context, meta executor.Meta, rootFS cache.ImmutableRef, stdin io.ReadCloser, stdout, stderr io.WriteCloser) error {
|
func (w *Worker) Exec(ctx context.Context, meta executor.Meta, rootFS cache.ImmutableRef, stdin io.ReadCloser, stdout, stderr io.WriteCloser) error {
|
||||||
active, err := w.CacheManager.New(ctx, rootFS)
|
active, err := w.CacheManager.New(ctx, rootFS)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -158,14 +159,17 @@ func (w *Worker) Exec(ctx context.Context, meta executor.Meta, rootFS cache.Immu
|
||||||
return w.Executor.Exec(ctx, meta, active, nil, stdin, stdout, stderr)
|
return w.Executor.Exec(ctx, meta, active, nil, stdin, stdout, stderr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DiskUsage returns disk usage report
|
||||||
func (w *Worker) DiskUsage(ctx context.Context, opt client.DiskUsageInfo) ([]*client.UsageInfo, error) {
|
func (w *Worker) DiskUsage(ctx context.Context, opt client.DiskUsageInfo) ([]*client.UsageInfo, error) {
|
||||||
return w.CacheManager.DiskUsage(ctx, opt)
|
return w.CacheManager.DiskUsage(ctx, opt)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Prune deletes reclaimable build cache
|
||||||
func (w *Worker) Prune(ctx context.Context, ch chan client.UsageInfo) error {
|
func (w *Worker) Prune(ctx context.Context, ch chan client.UsageInfo) error {
|
||||||
return w.CacheManager.Prune(ctx, ch)
|
return w.CacheManager.Prune(ctx, ch)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Exporter returns exporter by name
|
||||||
func (w *Worker) Exporter(name string) (exporter.Exporter, error) {
|
func (w *Worker) Exporter(name string) (exporter.Exporter, error) {
|
||||||
exp, ok := w.Exporters[name]
|
exp, ok := w.Exporters[name]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -174,10 +178,12 @@ func (w *Worker) Exporter(name string) (exporter.Exporter, error) {
|
||||||
return exp, nil
|
return exp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetRemote returns a remote snapshot reference for a local one
|
||||||
func (w *Worker) GetRemote(ctx context.Context, ref cache.ImmutableRef, createIfNeeded bool) (*solver.Remote, error) {
|
func (w *Worker) GetRemote(ctx context.Context, ref cache.ImmutableRef, createIfNeeded bool) (*solver.Remote, error) {
|
||||||
return nil, errors.Errorf("getremote not implemented")
|
return nil, errors.Errorf("getremote not implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FromRemote converts a remote snapshot reference to a local one
|
||||||
func (w *Worker) FromRemote(ctx context.Context, remote *solver.Remote) (cache.ImmutableRef, error) {
|
func (w *Worker) FromRemote(ctx context.Context, remote *solver.Remote) (cache.ImmutableRef, error) {
|
||||||
rootfs, err := getLayers(ctx, remote.Descriptors)
|
rootfs, err := getLayers(ctx, remote.Descriptors)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -219,7 +225,7 @@ func (w *Worker) FromRemote(ctx context.Context, remote *solver.Remote) (cache.I
|
||||||
|
|
||||||
type discardProgress struct{}
|
type discardProgress struct{}
|
||||||
|
|
||||||
func (_ *discardProgress) WriteProgress(_ pkgprogress.Progress) error {
|
func (*discardProgress) WriteProgress(_ pkgprogress.Progress) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,3 +315,7 @@ func oneOffProgress(ctx context.Context, id string) func(err error) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type resolveImageConfig interface {
|
||||||
|
ResolveImageConfig(ctx context.Context, ref string) (digest.Digest, []byte, error)
|
||||||
|
}
|
||||||
|
|
|
@ -922,6 +922,7 @@ func NewDaemon(config *config.Config, registryService registry.Service, containe
|
||||||
return d, nil
|
return d, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DistributionServices returns services controlling daemon storage
|
||||||
func (daemon *Daemon) DistributionServices() images.DistributionServices {
|
func (daemon *Daemon) DistributionServices() images.DistributionServices {
|
||||||
return daemon.imageService.DistributionServices()
|
return daemon.imageService.DistributionServices()
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,7 @@ type ImageService struct {
|
||||||
uploadManager *xfer.LayerUploadManager
|
uploadManager *xfer.LayerUploadManager
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DistributionServices provides daemon image storage services
|
||||||
type DistributionServices struct {
|
type DistributionServices struct {
|
||||||
DownloadManager distribution.RootFSDownloadManager
|
DownloadManager distribution.RootFSDownloadManager
|
||||||
V2MetadataService metadata.V2MetadataService
|
V2MetadataService metadata.V2MetadataService
|
||||||
|
@ -84,6 +85,7 @@ type DistributionServices struct {
|
||||||
ReferenceStore dockerreference.Store
|
ReferenceStore dockerreference.Store
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DistributionServices return services controlling daemon image storage
|
||||||
func (i *ImageService) DistributionServices() DistributionServices {
|
func (i *ImageService) DistributionServices() DistributionServices {
|
||||||
return DistributionServices{
|
return DistributionServices{
|
||||||
DownloadManager: i.downloadManager,
|
DownloadManager: i.downloadManager,
|
||||||
|
|
Loading…
Reference in New Issue