-
Notifications
You must be signed in to change notification settings - Fork 944
bugfix: align with docker v1.24 API #1226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ import ( | |
| "sync" | ||
|
|
||
| "github.com/alibaba/pouch/apis/types" | ||
| "github.com/docker/docker/pkg/stdcopy" | ||
|
|
||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
@@ -62,7 +63,7 @@ func (e *ExecCommand) runExec(args []string) error { | |
|
|
||
| createExecConfig := &types.ExecCreateConfig{ | ||
| Cmd: command, | ||
| Tty: e.Terminal || e.Interactive, | ||
| Tty: e.Terminal, | ||
| Detach: e.Detach, | ||
| AttachStderr: !e.Detach, | ||
| AttachStdout: !e.Detach, | ||
|
|
@@ -79,7 +80,7 @@ func (e *ExecCommand) runExec(args []string) error { | |
| // start exec process. | ||
| startExecConfig := &types.ExecStartConfig{ | ||
| Detach: e.Detach, | ||
| Tty: e.Terminal && e.Interactive, | ||
| Tty: e.Terminal, | ||
| } | ||
|
|
||
| conn, reader, err := apiClient.ContainerStartExec(ctx, createResp.ID, startExecConfig) | ||
|
|
@@ -95,19 +96,26 @@ func (e *ExecCommand) runExec(args []string) error { | |
| wg.Add(1) | ||
| go func() { | ||
| defer wg.Done() | ||
| io.Copy(os.Stdout, reader) | ||
| if !e.Terminal { | ||
| stdcopy.StdCopy(os.Stdout, os.Stderr, reader) | ||
| } else { | ||
| io.Copy(os.Stdout, reader) | ||
| } | ||
| }() | ||
| } | ||
|
|
||
| if createExecConfig.AttachStdin { | ||
| in, out, err := setRawMode(true, false) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to set raw mode") | ||
| } | ||
| defer func() { | ||
| if err := restoreMode(in, out); err != nil { | ||
| fmt.Fprintf(os.Stderr, "failed to restore term mode") | ||
| if e.Terminal { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the command doesn't set tty, we don't need to set raw mode for terminal |
||
| in, out, err := setRawMode(true, false) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to set raw mode") | ||
| } | ||
| }() | ||
| defer func() { | ||
| if err := restoreMode(in, out); err != nil { | ||
| fmt.Fprintf(os.Stderr, "failed to restore term mode") | ||
| } | ||
| }() | ||
| } | ||
|
|
||
| go func() { | ||
| io.Copy(conn, os.Stdin) | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -493,6 +493,12 @@ | |
| "revision": "53a58da551e961b3710bbbdfabbc162c3f5f30f6", | ||
| "revisionTime": "2018-01-31T23:13:00Z" | ||
| }, | ||
| { | ||
| "checksumSHA1": "H1rrbVmeE1z2TnkF7tSrfh+qUOY=", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we let docker vendor pkg version be same ? :)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @HusterWan Yes. It's already "53a58da551e961b3710bbbdfabbc162c3f5f30f6" |
||
| "path": "github.com/docker/docker/pkg/stdcopy", | ||
| "revision": "53a58da551e961b3710bbbdfabbc162c3f5f30f6", | ||
| "revisionTime": "2018-01-31T23:13:00Z" | ||
| }, | ||
| { | ||
| "checksumSHA1": "1IPGX6/BnX7QN4DjbBk0UafTB2U=", | ||
| "path": "github.com/docker/go-connections/nat", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should add some test case for
execcommand-iand-itflagswe can add the test case later, because this feature is needed very hurry
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure thing.