diff --git a/builder/builder.go b/builder/builder.go index caff35aead..06b151911a 100644 --- a/builder/builder.go +++ b/builder/builder.go @@ -11,7 +11,6 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/daemon" - "github.com/docker/docker/image" "github.com/docker/docker/runconfig" ) @@ -112,9 +111,9 @@ type Backend interface { // TODO: use digest reference instead of name // GetImage looks up a Docker image referenced by `name`. - GetImage(name string) (*image.Image, error) + GetImage(name string) (Image, error) // Pull tells Docker to pull image referenced by `name`. - Pull(name string) (*image.Image, error) + Pull(name string) (Image, error) // ContainerWsAttachWithLogs attaches to container. ContainerWsAttachWithLogs(name string, cfg *daemon.ContainerWsAttachWithLogsConfig) error // ContainerCreate creates a new Docker container and returns potential warnings diff --git a/builder/dockerfile/dispatchers.go b/builder/dockerfile/dispatchers.go index 97f50bb4e9..693bd8684c 100644 --- a/builder/dockerfile/dispatchers.go +++ b/builder/dockerfile/dispatchers.go @@ -18,8 +18,8 @@ import ( "strings" "github.com/Sirupsen/logrus" + "github.com/docker/docker/builder" derr "github.com/docker/docker/errors" - "github.com/docker/docker/image" flag "github.com/docker/docker/pkg/mflag" "github.com/docker/docker/pkg/nat" "github.com/docker/docker/pkg/signal" @@ -210,7 +210,7 @@ func from(b *Builder, args []string, attributes map[string]bool, original string } var ( - image *image.Image + image builder.Image err error ) // TODO: don't use `name`, instead resolve it to a digest diff --git a/builder/dockerfile/internals.go b/builder/dockerfile/internals.go index 0d87c12b04..1f82879244 100644 --- a/builder/dockerfile/internals.go +++ b/builder/dockerfile/internals.go @@ -24,7 +24,6 @@ import ( "github.com/docker/docker/builder" "github.com/docker/docker/builder/dockerfile/parser" "github.com/docker/docker/daemon" - "github.com/docker/docker/image" "github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/httputils" "github.com/docker/docker/pkg/ioutils" @@ -403,11 +402,11 @@ func containsWildcards(name string) bool { return false } -func (b *Builder) processImageFrom(img *image.Image) error { - b.image = img.ID().String() +func (b *Builder) processImageFrom(img builder.Image) error { + b.image = img.ID() if img.Config != nil { - b.runConfig = img.Config + b.runConfig = img.Config() } // The default path will be blank on Windows (set by HCS) diff --git a/builder/image.go b/builder/image.go new file mode 100644 index 0000000000..c8d5fc15d9 --- /dev/null +++ b/builder/image.go @@ -0,0 +1,9 @@ +package builder + +import "github.com/docker/docker/runconfig" + +// Image represents a Docker image used by the builder. +type Image interface { + ID() string + Config() *runconfig.Config +} diff --git a/daemon/daemonbuilder/builder.go b/daemon/daemonbuilder/builder.go index 6da9896301..d50cd7255e 100644 --- a/daemon/daemonbuilder/builder.go +++ b/daemon/daemonbuilder/builder.go @@ -36,7 +36,7 @@ type Docker struct { var _ builder.Backend = Docker{} // Pull tells Docker to pull image referenced by `name`. -func (d Docker) Pull(name string) (*image.Image, error) { +func (d Docker) Pull(name string) (builder.Image, error) { ref, err := reference.ParseNamed(name) if err != nil { return nil, err @@ -69,8 +69,16 @@ func (d Docker) Pull(name string) (*image.Image, error) { if err := d.Daemon.PullImage(ref, nil, pullRegistryAuth, ioutils.NopWriteCloser(d.OutOld)); err != nil { return nil, err } + return d.GetImage(name) +} - return d.Daemon.GetImage(name) +// GetImage looks up a Docker image referenced by `name`. +func (d Docker) GetImage(name string) (builder.Image, error) { + img, err := d.Daemon.GetImage(name) + if err != nil { + return nil, err + } + return imgWrap{img}, nil } // ContainerUpdateCmd updates Path and Args for the container with ID cID. @@ -84,18 +92,6 @@ func (d Docker) ContainerUpdateCmd(cID string, cmd []string) error { return nil } -// Retain retains an image avoiding it to be removed or overwritten until a corresponding Release() call. -func (d Docker) Retain(sessionID, imgID string) { - // FIXME: This will be solved with tags in client-side builder - //d.Daemon.Graph().Retain(sessionID, imgID) -} - -// Release releases a list of images that were retained for the time of a build. -func (d Docker) Release(sessionID string, activeImages []string) { - // FIXME: This will be solved with tags in client-side builder - //d.Daemon.Graph().Release(sessionID, activeImages...) -} - // BuilderCopy copies/extracts a source FileInfo to a destination path inside a container // specified by a container object. // TODO: make sure callers don't unnecessarily convert destPath with filepath.FromSlash (Copy does it already). diff --git a/daemon/daemonbuilder/image.go b/daemon/daemonbuilder/image.go new file mode 100644 index 0000000000..ab5ab9a322 --- /dev/null +++ b/daemon/daemonbuilder/image.go @@ -0,0 +1,18 @@ +package daemonbuilder + +import ( + "github.com/docker/docker/image" + "github.com/docker/docker/runconfig" +) + +type imgWrap struct { + inner *image.Image +} + +func (img imgWrap) ID() string { + return string(img.inner.ID()) +} + +func (img imgWrap) Config() *runconfig.Config { + return img.inner.Config +}