summaryrefslogtreecommitdiff
path: root/libpod/container_api.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2018-04-11 13:09:41 -0400
committerAtomic Bot <atomic-devel@projectatomic.io>2018-04-13 18:43:44 +0000
commit5e03cec7ec83f8ff8b31a89a6180dda203b04d9c (patch)
treeb32484a6c5d15f430fca12f07db974e354636ccc /libpod/container_api.go
parentb8394600d855a88b38f01feeadf5a63e703183cd (diff)
downloadpodman-5e03cec7ec83f8ff8b31a89a6180dda203b04d9c.tar.gz
podman-5e03cec7ec83f8ff8b31a89a6180dda203b04d9c.tar.bz2
podman-5e03cec7ec83f8ff8b31a89a6180dda203b04d9c.zip
Changes to attach to enable per-stream attaching
This allows us to attach to attach to just stdout or stderr or stdin, or any combination of these. Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #608 Approved by: baude
Diffstat (limited to 'libpod/container_api.go')
-rw-r--r--libpod/container_api.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/libpod/container_api.go b/libpod/container_api.go
index bfe20b184..fb6c70fd0 100644
--- a/libpod/container_api.go
+++ b/libpod/container_api.go
@@ -1,6 +1,7 @@
package libpod
import (
+ "io"
"io/ioutil"
"os"
"strconv"
@@ -14,6 +15,7 @@ import (
"github.com/projectatomic/libpod/pkg/inspect"
"github.com/sirupsen/logrus"
"k8s.io/apimachinery/pkg/util/wait"
+ "k8s.io/client-go/tools/remotecommand"
)
// Init creates a container in the OCI runtime
@@ -123,7 +125,7 @@ func (c *Container) Start() (err error) {
// attach call.
// The channel will be closed automatically after the result of attach has been
// sent
-func (c *Container) StartAndAttach(noStdin bool, keys string) (attachResChan <-chan error, err error) {
+func (c *Container) StartAndAttach(outputStream, errorStream io.WriteCloser, inputStream io.Reader, keys string, resize <-chan remotecommand.TerminalSize) (attachResChan <-chan error, err error) {
if !c.locked {
c.lock.Lock()
defer c.lock.Unlock()
@@ -176,7 +178,7 @@ func (c *Container) StartAndAttach(noStdin bool, keys string) (attachResChan <-c
// Attach to the container before starting it
go func() {
- if err := c.attach(noStdin, keys); err != nil {
+ if err := c.attach(outputStream, errorStream, inputStream, keys, resize); err != nil {
attachChan <- err
}
close(attachChan)
@@ -404,8 +406,7 @@ func (c *Container) Exec(tty, privileged bool, env, cmd []string, user string) e
}
// Attach attaches to a container
-// Returns fully qualified URL of streaming server for the container
-func (c *Container) Attach(noStdin bool, keys string) error {
+func (c *Container) Attach(outputStream, errorStream io.WriteCloser, inputStream io.Reader, keys string, resize <-chan remotecommand.TerminalSize) error {
if !c.locked {
c.lock.Lock()
if err := c.syncContainer(); err != nil {
@@ -420,7 +421,7 @@ func (c *Container) Attach(noStdin bool, keys string) error {
return errors.Wrapf(ErrCtrStateInvalid, "can only attach to created or running containers")
}
- return c.attach(noStdin, keys)
+ return c.attach(outputStream, errorStream, inputStream, keys, resize)
}
// Mount mounts a container's filesystem on the host