summaryrefslogtreecommitdiff
path: root/cmd/podman/utils.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2018-04-12 12:26:51 -0400
committerAtomic Bot <atomic-devel@projectatomic.io>2018-04-13 18:43:44 +0000
commit8d7635b1ac3eaea83fcf481994294eb137110e96 (patch)
tree9b78bbbeb9b33005c2f29b4fc248d3e7b2ddbf16 /cmd/podman/utils.go
parent6609d555f75568bb4f1394736a3e3b31e5f0d355 (diff)
downloadpodman-8d7635b1ac3eaea83fcf481994294eb137110e96.tar.gz
podman-8d7635b1ac3eaea83fcf481994294eb137110e96.tar.bz2
podman-8d7635b1ac3eaea83fcf481994294eb137110e96.zip
Change attach to accept a struct containing streams
Comparing Go interfaces, like io.Reader, to nil does not work. As such, we need to include a bool with each stream telling whether to attach to it. Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #608 Approved by: baude
Diffstat (limited to 'cmd/podman/utils.go')
-rw-r--r--cmd/podman/utils.go48
1 files changed, 45 insertions, 3 deletions
diff --git a/cmd/podman/utils.go b/cmd/podman/utils.go
index 0238fc9c2..925674474 100644
--- a/cmd/podman/utils.go
+++ b/cmd/podman/utils.go
@@ -73,7 +73,7 @@ func attachCtr(ctr *libpod.Container, stdout, stderr, stdin *os.File, detachKeys
// Check if we are attached to a terminal. If we are, generate resize
// events, and set the terminal to raw mode
- if haveTerminal {
+ if haveTerminal && ctr.Spec().Process.Terminal {
logrus.Debugf("Handling terminal attach")
resizeTty(resize)
@@ -88,11 +88,32 @@ func attachCtr(ctr *libpod.Container, stdout, stderr, stdin *os.File, detachKeys
defer term.RestoreTerminal(os.Stdin.Fd(), oldTermState)
}
+ streams := new(libpod.AttachStreams)
+ streams.OutputStream = stdout
+ streams.ErrorStream = stderr
+ streams.InputStream = stdin
+ streams.AttachOutput = true
+ streams.AttachError = true
+ streams.AttachInput = true
+
+ if stdout == nil {
+ logrus.Debugf("Not attaching to stdout")
+ streams.AttachOutput = false
+ }
+ if stderr == nil {
+ logrus.Debugf("Not attaching to stderr")
+ streams.AttachError = false
+ }
+ if stdin == nil {
+ logrus.Debugf("Not attaching to stdin")
+ streams.AttachInput = false
+ }
+
if sigProxy {
ProxySignals(ctr)
}
- return ctr.Attach(stdout, stderr, stdin, detachKeys, resize)
+ return ctr.Attach(streams, detachKeys, resize)
}
// Start and attach to a container
@@ -119,7 +140,28 @@ func startAttachCtr(ctr *libpod.Container, stdout, stderr, stdin *os.File, detac
defer term.RestoreTerminal(os.Stdin.Fd(), oldTermState)
}
- attachChan, err := ctr.StartAndAttach(stdout, stderr, stdin, detachKeys, resize)
+ streams := new(libpod.AttachStreams)
+ streams.OutputStream = stdout
+ streams.ErrorStream = stderr
+ streams.InputStream = stdin
+ streams.AttachOutput = true
+ streams.AttachError = true
+ streams.AttachInput = true
+
+ if stdout == nil {
+ logrus.Debugf("Not attaching to stdout")
+ streams.AttachOutput = false
+ }
+ if stderr == nil {
+ logrus.Debugf("Not attaching to stderr")
+ streams.AttachError = false
+ }
+ if stdin == nil {
+ logrus.Debugf("Not attaching to stdin")
+ streams.AttachInput = false
+ }
+
+ attachChan, err := ctr.StartAndAttach(streams, detachKeys, resize)
if err != nil {
return err
}