Merge pull request #4529 from gongguan/creator
avoid unnecessary NewCreator calls
This commit is contained in:
commit
534be84c5d
@ -72,7 +72,6 @@ func NewTask(ctx gocontext.Context, client *containerd.Client, container contain
|
||||
stdinC := &stdinCloser{
|
||||
stdin: os.Stdin,
|
||||
}
|
||||
stdio := cio.NewCreator(append([]cio.Opt{cio.WithStreams(stdinC, os.Stdout, os.Stderr)}, ioOpts...)...)
|
||||
if checkpoint != "" {
|
||||
im, err := client.GetImage(ctx, checkpoint)
|
||||
if err != nil {
|
||||
@ -80,22 +79,22 @@ func NewTask(ctx gocontext.Context, client *containerd.Client, container contain
|
||||
}
|
||||
opts = append(opts, containerd.WithTaskCheckpoint(im))
|
||||
}
|
||||
ioCreator := stdio
|
||||
var ioCreator cio.Creator
|
||||
if con != nil {
|
||||
ioCreator = cio.NewCreator(append([]cio.Opt{cio.WithStreams(con, con, nil), cio.WithTerminal}, ioOpts...)...)
|
||||
}
|
||||
if nullIO {
|
||||
if con != nil {
|
||||
if nullIO {
|
||||
return nil, errors.New("tty and null-io cannot be used together")
|
||||
}
|
||||
ioCreator = cio.NewCreator(append([]cio.Opt{cio.WithStreams(con, con, nil), cio.WithTerminal}, ioOpts...)...)
|
||||
} else if nullIO {
|
||||
ioCreator = cio.NullIO
|
||||
}
|
||||
if logURI != "" {
|
||||
} else if logURI != "" {
|
||||
u, err := url.Parse(logURI)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ioCreator = cio.LogURI(u)
|
||||
} else {
|
||||
ioCreator = cio.NewCreator(append([]cio.Opt{cio.WithStreams(stdinC, os.Stdout, os.Stderr)}, ioOpts...)...)
|
||||
}
|
||||
t, err := container.NewTask(ctx, ioCreator, opts...)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user