Add container attach support.

Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
Lantao Liu
2017-08-10 21:27:31 +00:00
parent 77b703f1e7
commit 45ee2e554a
24 changed files with 840 additions and 371 deletions

View File

@@ -20,6 +20,7 @@ import (
"bytes"
"fmt"
"io"
"io/ioutil"
"time"
"github.com/containerd/containerd"
@@ -115,9 +116,14 @@ func (c *criContainerdService) execInContainer(ctx context.Context, id string, o
pspec.Terminal = opts.tty
if opts.stdin == nil {
// Create empty buffer if stdin is nil.
opts.stdin = new(bytes.Buffer)
}
if opts.stdout == nil {
opts.stdout = ioutil.Discard
}
if opts.stderr == nil {
opts.stderr = ioutil.Discard
}
execID := util.GenerateID()
process, err := task.Exec(ctx, execID, pspec, containerd.NewIOWithTerminal(
opts.stdin,