浏览代码

don't report error resizing tty, as container could stop any time

see https://github.com/docker/cli/blob/04dad42c3c82733c3c82b1f859829d62d8608128/cli/command/container/tty.go#L71 wich always return nil

Signed-off-by: Nicolas De Loof <[email protected]>
Nicolas De Loof 4 年之前
父节点
当前提交
0ab75d28ba
共有 3 个文件被更改,包括 4 次插入8 次删除
  1. 1 1
      local/compose/exec.go
  2. 2 3
      local/compose/resize.go
  3. 1 4
      local/compose/run.go

+ 1 - 1
local/compose/exec.go

@@ -83,7 +83,7 @@ func (s *composeService) Exec(ctx context.Context, project *types.Project, opts
 	defer resp.Close()
 
 	if opts.Tty {
-		err := s.monitorTTySize(ctx, exec.ID, s.apiClient.ContainerExecResize)
+		s.monitorTTySize(ctx, exec.ID, s.apiClient.ContainerExecResize)
 		if err != nil {
 			return err
 		}

+ 2 - 3
local/compose/resize.go

@@ -28,13 +28,13 @@ import (
 	"github.com/docker/docker/pkg/signal"
 )
 
-func (s *composeService) monitorTTySize(ctx context.Context, container string, resize func(context.Context, string, moby.ResizeOptions) error) error {
+func (s *composeService) monitorTTySize(ctx context.Context, container string, resize func(context.Context, string, moby.ResizeOptions) error) {
 	err := resize(ctx, container, moby.ResizeOptions{ // nolint:errcheck
 		Height: uint(goterm.Height()),
 		Width:  uint(goterm.Width()),
 	})
 	if err != nil {
-		return err
+		return
 	}
 
 	sigchan := make(chan os.Signal, 1)
@@ -71,5 +71,4 @@ func (s *composeService) monitorTTySize(ctx context.Context, container string, r
 			}
 		}
 	}()
-	return nil
 }

+ 1 - 4
local/compose/run.go

@@ -96,10 +96,7 @@ func (s *composeService) RunOneOffContainer(ctx context.Context, project *types.
 		return 0, err
 	}
 
-	err = s.monitorTTySize(ctx, containerID, s.apiClient.ContainerResize)
-	if err != nil {
-		return 0, err
-	}
+	s.monitorTTySize(ctx, containerID, s.apiClient.ContainerResize)
 
 	select {
 	case status := <-statusC: