mirror of https://github.com/docker/cli.git
command/exec: Fill ConsoleSize
This makes the exec'd process console dimensions immediately match the users terminal. Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
parent
bb5c3575b3
commit
a141f1c267
|
@ -117,6 +117,8 @@ func RunExec(dockerCli command.Cli, options ExecOptions) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fillConsoleSize(execConfig, dockerCli)
|
||||||
|
|
||||||
response, err := client.ContainerExecCreate(ctx, options.Container, *execConfig)
|
response, err := client.ContainerExecCreate(ctx, options.Container, *execConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -131,12 +133,20 @@ func RunExec(dockerCli command.Cli, options ExecOptions) error {
|
||||||
execStartCheck := types.ExecStartCheck{
|
execStartCheck := types.ExecStartCheck{
|
||||||
Detach: execConfig.Detach,
|
Detach: execConfig.Detach,
|
||||||
Tty: execConfig.Tty,
|
Tty: execConfig.Tty,
|
||||||
|
ConsoleSize: execConfig.ConsoleSize,
|
||||||
}
|
}
|
||||||
return client.ContainerExecStart(ctx, execID, execStartCheck)
|
return client.ContainerExecStart(ctx, execID, execStartCheck)
|
||||||
}
|
}
|
||||||
return interactiveExec(ctx, dockerCli, execConfig, execID)
|
return interactiveExec(ctx, dockerCli, execConfig, execID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func fillConsoleSize(execConfig *types.ExecConfig, dockerCli command.Cli) {
|
||||||
|
if execConfig.Tty {
|
||||||
|
height, width := dockerCli.Out().GetTtySize()
|
||||||
|
execConfig.ConsoleSize = &[2]uint{height, width}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func interactiveExec(ctx context.Context, dockerCli command.Cli, execConfig *types.ExecConfig, execID string) error {
|
func interactiveExec(ctx context.Context, dockerCli command.Cli, execConfig *types.ExecConfig, execID string) error {
|
||||||
// Interactive exec requested.
|
// Interactive exec requested.
|
||||||
var (
|
var (
|
||||||
|
@ -157,10 +167,12 @@ func interactiveExec(ctx context.Context, dockerCli command.Cli, execConfig *typ
|
||||||
stderr = dockerCli.Err()
|
stderr = dockerCli.Err()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fillConsoleSize(execConfig, dockerCli)
|
||||||
|
|
||||||
client := dockerCli.Client()
|
client := dockerCli.Client()
|
||||||
execStartCheck := types.ExecStartCheck{
|
execStartCheck := types.ExecStartCheck{
|
||||||
Tty: execConfig.Tty,
|
Tty: execConfig.Tty,
|
||||||
|
ConsoleSize: execConfig.ConsoleSize,
|
||||||
}
|
}
|
||||||
resp, err := client.ContainerExecAttach(ctx, execID, execStartCheck)
|
resp, err := client.ContainerExecAttach(ctx, execID, execStartCheck)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue