Reduce the number of IO constructors
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
package tasks
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/containerd/console"
|
||||
"github.com/containerd/containerd/cio"
|
||||
"github.com/containerd/containerd/cmd/ctr/commands"
|
||||
@@ -39,7 +37,7 @@ var attachCommand = cli.Command{
|
||||
return err
|
||||
}
|
||||
}
|
||||
task, err := container.Task(ctx, cio.WithAttach(os.Stdin, os.Stdout, os.Stderr))
|
||||
task, err := container.Task(ctx, cio.NewAttach(cio.WithStdio))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@@ -60,9 +60,9 @@ var execCommand = cli.Command{
|
||||
pspec.Terminal = tty
|
||||
pspec.Args = args
|
||||
|
||||
ioCreator := cio.Stdio
|
||||
ioCreator := cio.NewCreator(cio.WithStdio)
|
||||
if tty {
|
||||
ioCreator = cio.StdioTerminal
|
||||
ioCreator = cio.NewCreator(cio.WithStdio, cio.WithTerminal)
|
||||
}
|
||||
process, err := task.Exec(ctx, context.String("exec-id"), pspec, ioCreator)
|
||||
if err != nil {
|
||||
|
@@ -44,10 +44,11 @@ func HandleConsoleResize(ctx gocontext.Context, task resizer, con console.Consol
|
||||
|
||||
// NewTask creates a new task
|
||||
func NewTask(ctx gocontext.Context, client *containerd.Client, container containerd.Container, checkpoint string, tty, nullIO bool) (containerd.Task, error) {
|
||||
stdio := cio.NewCreator(cio.WithStdio)
|
||||
if checkpoint == "" {
|
||||
ioCreator := cio.Stdio
|
||||
ioCreator := stdio
|
||||
if tty {
|
||||
ioCreator = cio.StdioTerminal
|
||||
ioCreator = cio.NewCreator(cio.WithStdio, cio.WithTerminal)
|
||||
}
|
||||
if nullIO {
|
||||
if tty {
|
||||
@@ -61,5 +62,5 @@ func NewTask(ctx gocontext.Context, client *containerd.Client, container contain
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return container.NewTask(ctx, cio.Stdio, containerd.WithTaskCheckpoint(im))
|
||||
return container.NewTask(ctx, stdio, containerd.WithTaskCheckpoint(im))
|
||||
}
|
||||
|
@@ -42,9 +42,9 @@ func HandleConsoleResize(ctx gocontext.Context, task resizer, con console.Consol
|
||||
|
||||
// NewTask creates a new task
|
||||
func NewTask(ctx gocontext.Context, client *containerd.Client, container containerd.Container, _ string, tty, nullIO bool) (containerd.Task, error) {
|
||||
ioCreator := cio.Stdio
|
||||
ioCreator := cio.NewCreator(cio.WithStdio)
|
||||
if tty {
|
||||
ioCreator = cio.StdioTerminal
|
||||
ioCreator = cio.NewCreator(cio.WithStdio, cio.WithTerminal)
|
||||
}
|
||||
if nullIO {
|
||||
if tty {
|
||||
|
Reference in New Issue
Block a user