github.com/ld86/docker@v1.7.1-rc3/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 Multiplex bool 15 } 16 17 func (daemon *Daemon) ContainerAttachWithLogs(container *Container, c *ContainerAttachWithLogsConfig) error { 18 var errStream io.Writer 19 20 if !container.Config.Tty && c.Multiplex { 21 errStream = stdcopy.NewStdWriter(c.OutStream, stdcopy.Stderr) 22 c.OutStream = stdcopy.NewStdWriter(c.OutStream, stdcopy.Stdout) 23 } else { 24 errStream = c.OutStream 25 } 26 27 var stdin io.ReadCloser 28 var stdout, stderr io.Writer 29 30 if c.UseStdin { 31 stdin = c.InStream 32 } 33 if c.UseStdout { 34 stdout = c.OutStream 35 } 36 if c.UseStderr { 37 stderr = errStream 38 } 39 40 return container.AttachWithLogs(stdin, stdout, stderr, c.Logs, c.Stream) 41 } 42 43 type ContainerWsAttachWithLogsConfig struct { 44 InStream io.ReadCloser 45 OutStream, ErrStream io.Writer 46 Logs, Stream bool 47 } 48 49 func (daemon *Daemon) ContainerWsAttachWithLogs(container *Container, c *ContainerWsAttachWithLogsConfig) error { 50 return container.AttachWithLogs(c.InStream, c.OutStream, c.ErrStream, c.Logs, c.Stream) 51 }