Merge pull request #18721 from tiborvass/remove-dependencies-from-builder
Remove image and daemon dependencies from builder Upstream-commit: 64d70de0a2aa29f565336e896b76c23c879a9a98 Component: engine
This commit is contained in:
@ -10,8 +10,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/daemon"
|
||||
"github.com/docker/docker/image"
|
||||
"github.com/docker/docker/runconfig"
|
||||
)
|
||||
|
||||
@ -112,13 +110,13 @@ 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)
|
||||
// ContainerWsAttachWithLogs attaches to container.
|
||||
ContainerWsAttachWithLogs(name string, cfg *daemon.ContainerWsAttachWithLogsConfig) error
|
||||
Pull(name string) (Image, error)
|
||||
// ContainerAttach attaches to container.
|
||||
ContainerAttach(cID string, stdin io.ReadCloser, stdout, stderr io.Writer, stream bool) error
|
||||
// ContainerCreate creates a new Docker container and returns potential warnings
|
||||
ContainerCreate(params *daemon.ContainerCreateConfig) (types.ContainerCreateResponse, error)
|
||||
ContainerCreate(types.ContainerCreateConfig) (types.ContainerCreateResponse, error)
|
||||
// ContainerRm removes a container specified by `id`.
|
||||
ContainerRm(name string, config *types.ContainerRmConfig) error
|
||||
// Commit creates a new Docker image from an existing Docker container.
|
||||
|
||||
@ -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
|
||||
|
||||
@ -23,8 +23,6 @@ import (
|
||||
"github.com/docker/docker/api/types"
|
||||
"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"
|
||||
@ -185,7 +183,7 @@ func (b *Builder) runContextCommand(args []string, allowRemote bool, allowLocalD
|
||||
return nil
|
||||
}
|
||||
|
||||
container, err := b.docker.ContainerCreate(&daemon.ContainerCreateConfig{Config: b.runConfig})
|
||||
container, err := b.docker.ContainerCreate(types.ContainerCreateConfig{Config: b.runConfig})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -395,11 +393,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)
|
||||
@ -500,7 +498,7 @@ func (b *Builder) create() (string, error) {
|
||||
config := *b.runConfig
|
||||
|
||||
// Create the container
|
||||
c, err := b.docker.ContainerCreate(&daemon.ContainerCreateConfig{
|
||||
c, err := b.docker.ContainerCreate(types.ContainerCreateConfig{
|
||||
Config: b.runConfig,
|
||||
HostConfig: hostConfig,
|
||||
})
|
||||
@ -528,11 +526,7 @@ func (b *Builder) run(cID string) (err error) {
|
||||
errCh := make(chan error)
|
||||
if b.Verbose {
|
||||
go func() {
|
||||
errCh <- b.docker.ContainerWsAttachWithLogs(cID, &daemon.ContainerWsAttachWithLogsConfig{
|
||||
OutStream: b.Stdout,
|
||||
ErrStream: b.Stderr,
|
||||
Stream: true,
|
||||
})
|
||||
errCh <- b.docker.ContainerAttach(cID, nil, b.Stdout, b.Stderr, true)
|
||||
}()
|
||||
}
|
||||
|
||||
|
||||
9
components/engine/builder/image.go
Normal file
9
components/engine/builder/image.go
Normal file
@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user