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

builder: remove daemon dependency in ContainerAttach

Signed-off-by: Tibor Vass <tibor@docker.com>
This commit is contained in:
Tibor Vass 2015-12-16 19:19:12 +01:00
parent 03a170c48d
commit b0d9476153
3 changed files with 13 additions and 7 deletions

View file

@ -113,8 +113,8 @@ type Backend interface {
GetImage(name string) (Image, error) GetImage(name string) (Image, error)
// Pull tells Docker to pull image referenced by `name`. // Pull tells Docker to pull image referenced by `name`.
Pull(name string) (Image, error) Pull(name string) (Image, error)
// ContainerWsAttachWithLogs attaches to container. // ContainerAttach attaches to container.
ContainerWsAttachWithLogs(name string, cfg *daemon.ContainerWsAttachWithLogsConfig) error ContainerAttach(cID string, stdin io.ReadCloser, stdout, stderr io.Writer, stream bool) error
// ContainerCreate creates a new Docker container and returns potential warnings // ContainerCreate creates a new Docker container and returns potential warnings
ContainerCreate(types.ContainerCreateConfig) (types.ContainerCreateResponse, error) ContainerCreate(types.ContainerCreateConfig) (types.ContainerCreateResponse, error)
// ContainerRm removes a container specified by `id`. // ContainerRm removes a container specified by `id`.

View file

@ -534,11 +534,7 @@ func (b *Builder) run(cID string) (err error) {
errCh := make(chan error) errCh := make(chan error)
if b.Verbose { if b.Verbose {
go func() { go func() {
errCh <- b.docker.ContainerWsAttachWithLogs(cID, &daemon.ContainerWsAttachWithLogsConfig{ errCh <- b.docker.ContainerAttach(cID, nil, b.Stdout, b.Stderr, true)
OutStream: b.Stdout,
ErrStream: b.Stderr,
Stream: true,
})
}() }()
} }

View file

@ -92,6 +92,16 @@ func (d Docker) ContainerUpdateCmd(cID string, cmd []string) error {
return nil return nil
} }
// ContainerAttach attaches streams to the container cID. If stream is true, it streams the output.
func (d Docker) ContainerAttach(cID string, stdin io.ReadCloser, stdout, stderr io.Writer, stream bool) error {
return d.Daemon.ContainerWsAttachWithLogs(cID, &daemon.ContainerWsAttachWithLogsConfig{
InStream: stdin,
OutStream: stdout,
ErrStream: stderr,
Stream: stream,
})
}
// BuilderCopy copies/extracts a source FileInfo to a destination path inside a container // BuilderCopy copies/extracts a source FileInfo to a destination path inside a container
// specified by a container object. // specified by a container object.
// TODO: make sure callers don't unnecessarily convert destPath with filepath.FromSlash (Copy does it already). // TODO: make sure callers don't unnecessarily convert destPath with filepath.FromSlash (Copy does it already).