Quellcode durchsuchen

builder: remove daemon dependency in ContainerAttach

Signed-off-by: Tibor Vass <tibor@docker.com>
Tibor Vass vor 9 Jahren
Ursprung
Commit
b0d9476153
3 geänderte Dateien mit 13 neuen und 7 gelöschten Zeilen
  1. 2 2
      builder/builder.go
  2. 1 5
      builder/dockerfile/internals.go
  3. 10 0
      daemon/daemonbuilder/builder.go

+ 2 - 2
builder/builder.go

@@ -113,8 +113,8 @@ type Backend interface {
 	GetImage(name string) (Image, error)
 	// Pull tells Docker to pull image referenced by `name`.
 	Pull(name string) (Image, error)
-	// ContainerWsAttachWithLogs attaches to container.
-	ContainerWsAttachWithLogs(name string, cfg *daemon.ContainerWsAttachWithLogsConfig) 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(types.ContainerCreateConfig) (types.ContainerCreateResponse, error)
 	// ContainerRm removes a container specified by `id`.

+ 1 - 5
builder/dockerfile/internals.go

@@ -534,11 +534,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)
 		}()
 	}
 

+ 10 - 0
daemon/daemonbuilder/builder.go

@@ -92,6 +92,16 @@ func (d Docker) ContainerUpdateCmd(cID string, cmd []string) error {
 	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
 // specified by a container object.
 // TODO: make sure callers don't unnecessarily convert destPath with filepath.FromSlash (Copy does it already).