@@ -43,7 +43,7 @@ import (
4343
4444// NewTask is from https://github.com/containerd/containerd/blob/v1.4.3/cmd/ctr/commands/tasks/tasks_unix.go#L70-L108
4545func NewTask (ctx context.Context , client * containerd.Client , container containerd.Container ,
46- attachStreamOpt []string , flagI , flagT , flagD bool , con console.Console , logURI , detachKeys , namespace string , detachC chan <- struct {}) (containerd.Task , error ) {
46+ attachStreamOpt []string , isInteractive , isTerminal , isDetach bool , con console.Console , logURI , detachKeys , namespace string , detachC chan <- struct {}) (containerd.Task , error ) {
4747
4848 var t containerd.Task
4949 closer := func () {
@@ -67,9 +67,9 @@ func NewTask(ctx context.Context, client *containerd.Client, container container
6767 if len (attachStreamOpt ) != 0 {
6868 log .G (ctx ).Debug ("attaching output instead of using the log-uri" )
6969 // when attaching a TTY we use writee for stdio and binary for log persistence
70- if flagT {
70+ if isTerminal {
7171 var in io.Reader
72- if flagI {
72+ if isInteractive {
7373 // FIXME: check IsTerminal on Windows too
7474 if runtime .GOOS != "windows" && ! term .IsTerminal (0 ) {
7575 return nil , errors .New ("the input device is not a TTY" )
@@ -86,7 +86,7 @@ func NewTask(ctx context.Context, client *containerd.Client, container container
8686 ioCreator = cioutil .NewContainerIO (namespace , logURI , false , streams .stdIn , streams .stdOut , streams .stdErr )
8787 }
8888
89- } else if flagT && flagD {
89+ } else if isTerminal && isDetach {
9090 u , err := url .Parse (logURI )
9191 if err != nil {
9292 return nil , err
@@ -113,12 +113,12 @@ func NewTask(ctx context.Context, client *containerd.Client, container container
113113 ioCreator = cio .TerminalBinaryIO (parsedPath , map [string ]string {
114114 args [0 ]: args [1 ],
115115 })
116- } else if flagT && ! flagD {
116+ } else if isTerminal && ! isDetach {
117117 if con == nil {
118- return nil , errors .New ("got nil con with flagT =true" )
118+ return nil , errors .New ("got nil con with isTerminal =true" )
119119 }
120120 var in io.Reader
121- if flagI {
121+ if isInteractive {
122122 // FIXME: check IsTerminal on Windows too
123123 if runtime .GOOS != "windows" && ! term .IsTerminal (0 ) {
124124 return nil , errors .New ("the input device is not a TTY" )
@@ -130,15 +130,15 @@ func NewTask(ctx context.Context, client *containerd.Client, container container
130130 }
131131 }
132132 ioCreator = cioutil .NewContainerIO (namespace , logURI , true , in , os .Stdout , os .Stderr )
133- } else if flagD && logURI != "" && logURI != "none" {
133+ } else if isDetach && logURI != "" && logURI != "none" {
134134 u , err := url .Parse (logURI )
135135 if err != nil {
136136 return nil , err
137137 }
138138 ioCreator = cio .LogURI (u )
139139 } else {
140140 var in io.Reader
141- if flagI {
141+ if isInteractive {
142142 if sv , err := infoutil .ServerSemVer (ctx , client ); err != nil {
143143 log .G (ctx ).Warn (err )
144144 } else if sv .LessThan (semver .MustParse ("1.6.0-0" )) {
0 commit comments