github.com/glycerine/docker@v1.8.2/daemon/attach.go (about) 1 package daemon 2 3 import ( 4 "io" 5 6 "github.com/docker/docker/pkg/stdcopy" 7 ) 8 9 type ContainerAttachWithLogsConfig struct { 10 InStream io.ReadCloser 11 OutStream io.Writer 12 UseStdin, UseStdout, UseStderr bool 13 Logs, Stream bool 14 } 15 16 func (daemon *Daemon) ContainerAttachWithLogs(container *Container, c *ContainerAttachWithLogsConfig) error { 17 var errStream io.Writer 18 19 if !container.Config.Tty { 20 errStream = stdcopy.NewStdWriter(c.OutStream, stdcopy.Stderr) 21 c.OutStream = stdcopy.NewStdWriter(c.OutStream, stdcopy.Stdout) 22 } else { 23 errStream = c.OutStream 24 } 25 26 var stdin io.ReadCloser 27 var stdout, stderr io.Writer 28 29 if c.UseStdin { 30 stdin = c.InStream 31 } 32 if c.UseStdout { 33 stdout = c.OutStream 34 } 35 if c.UseStderr { 36 stderr = errStream 37 } 38 39 return container.AttachWithLogs(stdin, stdout, stderr, c.Logs, c.Stream) 40 } 41 42 type ContainerWsAttachWithLogsConfig struct { 43 InStream io.ReadCloser 44 OutStream, ErrStream io.Writer 45 Logs, Stream bool 46 } 47 48 func (daemon *Daemon) ContainerWsAttachWithLogs(container *Container, c *ContainerWsAttachWithLogsConfig) error { 49 return container.AttachWithLogs(c.InStream, c.OutStream, c.ErrStream, c.Logs, c.Stream) 50 }