@@ -37,7 +37,7 @@ type DockerAdapter struct {
37
37
}
38
38
39
39
func (d * DockerAdapter ) GetContainerStatus (basePath string , name string ) (CloudControlStatus , error ) {
40
- containerName := fmt .Sprintf ("%s_cli_1 " , name )
40
+ containerName := fmt .Sprintf ("%s%scli%s1 " , name , api . Separator , api . Separator )
41
41
c := d .getClient ()
42
42
notFound := regexp .MustCompile ("No such container" )
43
43
if i , err := c .ContainerInspect (context .Background (), containerName ); err != nil {
@@ -86,7 +86,7 @@ func (d *DockerAdapter) GetContainerStatus(basePath string, name string) (CloudC
86
86
}
87
87
88
88
func (d * DockerAdapter ) RunCloudControl (_ string , name string , consoleWidth uint , consoleHeight uint ) (* ContainerExec , error ) {
89
- containerName := fmt .Sprintf ("%s_cli_1 " , name )
89
+ containerName := fmt .Sprintf ("%s%scli%s1 " , name , api . Separator , api . Separator )
90
90
consoleSize := [2 ]uint {consoleHeight , consoleWidth }
91
91
return & ContainerExec {
92
92
exec : func (stdin io.Reader , stdout io.Writer ) error {
@@ -135,65 +135,74 @@ func (d *DockerAdapter) RunCloudControl(_ string, name string, consoleWidth uint
135
135
}
136
136
137
137
go func (c net.Conn ) {
138
+ active := true
138
139
s := bufio .NewReader (c )
139
140
for {
140
141
select {
141
142
case <- quitWriter :
142
143
return
143
144
default :
144
- if b , err := s .ReadByte (); err != nil {
145
- logrus .Errorf ("error reading from Docker: %s" , err )
146
- return
147
- } else {
148
- if _ , err := stdout .Write ([]byte {b }); err != nil {
149
- logrus .Errorf ("error writing to stdout: %s" , err )
145
+ if active {
146
+ if b , err := s .ReadByte (); err != nil {
147
+ logrus .Errorf ("error reading from Docker: %s" , err )
148
+ active = false
149
+ } else {
150
+ if _ , err := stdout .Write ([]byte {b }); err != nil {
151
+ logrus .Errorf ("error writing to stdout: %s" , err )
152
+ }
150
153
}
151
154
}
152
155
}
153
156
}
154
157
}(execResponse .Conn )
155
158
156
159
go func (c net.Conn ) {
160
+ active := true
157
161
s := bufio .NewReader (stdin )
158
162
for {
159
163
select {
160
164
case <- quitReader :
161
165
return
162
166
default :
163
- if b , err := s .ReadByte (); err != nil {
164
- logrus .Errorf ("error reading from Docker: %s" , err )
165
- return
166
- } else {
167
- if _ , err := c .Write ([]byte {b }); err != nil {
168
- logrus .Errorf ("error writing to Docker: %s" , err )
169
- return
167
+ if active {
168
+ if b , err := s .ReadByte (); err != nil {
169
+ logrus .Errorf ("error reading from Docker: %s" , err )
170
+ active = false
171
+ } else {
172
+ if _ , err := c .Write ([]byte {b }); err != nil {
173
+ logrus .Errorf ("error writing to Docker: %s" , err )
174
+ active = false
175
+ }
170
176
}
171
177
}
172
178
}
173
179
}
174
180
}(execResponse .Conn )
175
181
176
182
go func () {
183
+ active := true
177
184
width := consoleWidth
178
185
height := consoleHeight
179
186
for {
180
187
select {
181
188
case <- quitTermResize :
182
189
return
183
190
default :
184
- if w , err := term .GetWinsize (fd ); err != nil {
185
- logrus .Errorf ("error getting terminal size: %s" , err )
186
- return
187
- } else {
188
- if w .Width != uint16 (width ) || w .Height != uint16 (height ) {
189
- width = uint (w .Width )
190
- height = uint (w .Height )
191
- if err := dockerCli .ContainerExecResize (context .Background (), executeID , types.ResizeOptions {
192
- Width : width ,
193
- Height : height ,
194
- }); err != nil {
195
- logrus .Errorf ("error resizing container terminal: %s" , err )
196
- return
191
+ if active {
192
+ if w , err := term .GetWinsize (fd ); err != nil {
193
+ logrus .Errorf ("error getting terminal size: %s" , err )
194
+ active = false
195
+ } else {
196
+ if w .Width != uint16 (width ) || w .Height != uint16 (height ) {
197
+ width = uint (w .Width )
198
+ height = uint (w .Height )
199
+ if err := dockerCli .ContainerExecResize (context .Background (), executeID , types.ResizeOptions {
200
+ Width : width ,
201
+ Height : height ,
202
+ }); err != nil {
203
+ logrus .Errorf ("error resizing container terminal: %s" , err )
204
+ active = false
205
+ }
197
206
}
198
207
}
199
208
}
@@ -270,8 +279,6 @@ func (d *DockerAdapter) getClient() client.Client {
270
279
func (d * DockerAdapter ) getComposeBackend () api.Service {
271
280
if d .composeBackend == nil {
272
281
cl := d .getClient ()
273
- // ensure old docker-compose compatibility
274
- api .Separator = "_"
275
282
if c , err := command .NewDockerCli (command .WithAPIClient (& cl ), command .WithDefaultContextStoreConfig ()); err != nil {
276
283
panic (fmt .Sprintf ("Can not connect to Docker API: %s" , err .Error ()))
277
284
} else {
0 commit comments