summaryrefslogtreecommitdiff
path: root/libpod/container.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2017-11-01 13:59:11 -0500
committerbaude <bbaude@redhat.com>2017-11-01 14:19:19 -0500
commit8cf07b2ad1ed8c6646c48a74e9ecbb2bfeecb322 (patch)
tree625fdeaf51ffced387b4ba2e48d93288f3f1b9b2 /libpod/container.go
parentf5019df3f5da9030ce21e5c8ad3d3921a6585e7f (diff)
downloadpodman-8cf07b2ad1ed8c6646c48a74e9ecbb2bfeecb322.tar.gz
podman-8cf07b2ad1ed8c6646c48a74e9ecbb2bfeecb322.tar.bz2
podman-8cf07b2ad1ed8c6646c48a74e9ecbb2bfeecb322.zip
libpod create and run
patched version of the same code that went into crio Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'libpod/container.go')
-rw-r--r--libpod/container.go31
1 files changed, 29 insertions, 2 deletions
diff --git a/libpod/container.go b/libpod/container.go
index 1f5be9477..50fe18939 100644
--- a/libpod/container.go
+++ b/libpod/container.go
@@ -15,6 +15,9 @@ import (
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/ulule/deepcopier"
+ "github.com/docker/docker/pkg/term"
+ "k8s.io/client-go/tools/remotecommand"
+
)
// ContainerState represents the current state of a container
@@ -391,8 +394,32 @@ func (c *Container) Exec(cmd []string, tty bool, stdin bool) (string, error) {
// Attach attaches to a container
// Returns fully qualified URL of streaming server for the container
-func (c *Container) Attach(stdin, tty bool) (string, error) {
- return "", ErrNotImplemented
+func (c *Container) Attach(noStdin bool, keys string) error {
+ // Check the validity of the provided keys first
+ var err error
+ detachKeys := []byte{}
+ if len(keys) > 0 {
+ detachKeys, err = term.ToBytes(keys)
+ if err != nil {
+ return errors.Wrapf(err, "invalid detach keys")
+ }
+ }
+ cStatus := c.state.State
+
+ if !(cStatus == ContainerStateRunning || cStatus == ContainerStateCreated) {
+ return errors.Errorf("%s is not created or running", c.Name())
+ }
+ resize := make(chan remotecommand.TerminalSize)
+ defer close(resize)
+ err = c.attachContainerSocket(resize, noStdin, detachKeys)
+ if err != nil {
+ return err
+ }
+ // TODO
+ // Re-enable this when mheon is done wth it
+ //c.ContainerStateToDisk(c)
+
+ return nil
}
// Mount mounts a container's filesystem on the host