@@ -43,7 +43,7 @@ import (
43
43
44
44
// NewTask is from https://github.com/containerd/containerd/blob/v1.4.3/cmd/ctr/commands/tasks/tasks_unix.go#L70-L108
45
45
func 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 ) {
47
47
48
48
var t containerd.Task
49
49
closer := func () {
@@ -67,9 +67,9 @@ func NewTask(ctx context.Context, client *containerd.Client, container container
67
67
if len (attachStreamOpt ) != 0 {
68
68
log .G (ctx ).Debug ("attaching output instead of using the log-uri" )
69
69
// when attaching a TTY we use writee for stdio and binary for log persistence
70
- if flagT {
70
+ if isTerminal {
71
71
var in io.Reader
72
- if flagI {
72
+ if isInteractive {
73
73
// FIXME: check IsTerminal on Windows too
74
74
if runtime .GOOS != "windows" && ! term .IsTerminal (0 ) {
75
75
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
86
86
ioCreator = cioutil .NewContainerIO (namespace , logURI , false , streams .stdIn , streams .stdOut , streams .stdErr )
87
87
}
88
88
89
- } else if flagT && flagD {
89
+ } else if isTerminal && isDetach {
90
90
u , err := url .Parse (logURI )
91
91
if err != nil {
92
92
return nil , err
@@ -113,12 +113,12 @@ func NewTask(ctx context.Context, client *containerd.Client, container container
113
113
ioCreator = cio .TerminalBinaryIO (parsedPath , map [string ]string {
114
114
args [0 ]: args [1 ],
115
115
})
116
- } else if flagT && ! flagD {
116
+ } else if isTerminal && ! isDetach {
117
117
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" )
119
119
}
120
120
var in io.Reader
121
- if flagI {
121
+ if isInteractive {
122
122
// FIXME: check IsTerminal on Windows too
123
123
if runtime .GOOS != "windows" && ! term .IsTerminal (0 ) {
124
124
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
130
130
}
131
131
}
132
132
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" {
134
134
u , err := url .Parse (logURI )
135
135
if err != nil {
136
136
return nil , err
137
137
}
138
138
ioCreator = cio .LogURI (u )
139
139
} else {
140
140
var in io.Reader
141
- if flagI {
141
+ if isInteractive {
142
142
if sv , err := infoutil .ServerSemVer (ctx , client ); err != nil {
143
143
log .G (ctx ).Warn (err )
144
144
} else if sv .LessThan (semver .MustParse ("1.6.0-0" )) {
0 commit comments