fix api server resize&execResize
Signed-off-by: Antonio Murdaca <me@runcom.ninja>
This commit is contained in:
parent
a54fd325e6
commit
3341f3a355
3 changed files with 50 additions and 14 deletions
|
@ -1036,11 +1036,11 @@ func postContainersResize(eng *engine.Engine, version version.Version, w http.Re
|
||||||
|
|
||||||
height, err := strconv.Atoi(r.Form.Get("h"))
|
height, err := strconv.Atoi(r.Form.Get("h"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return err
|
||||||
}
|
}
|
||||||
width, err := strconv.Atoi(r.Form.Get("w"))
|
width, err := strconv.Atoi(r.Form.Get("w"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
d := getDaemon(eng)
|
d := getDaemon(eng)
|
||||||
|
@ -1049,11 +1049,7 @@ func postContainersResize(eng *engine.Engine, version version.Version, w http.Re
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := cont.Resize(height, width); err != nil {
|
return cont.Resize(height, width)
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func postContainersAttach(eng *engine.Engine, version version.Version, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
func postContainersAttach(eng *engine.Engine, version version.Version, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
||||||
|
@ -1416,19 +1412,16 @@ func postContainerExecResize(eng *engine.Engine, version version.Version, w http
|
||||||
|
|
||||||
height, err := strconv.Atoi(r.Form.Get("h"))
|
height, err := strconv.Atoi(r.Form.Get("h"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return err
|
||||||
}
|
}
|
||||||
width, err := strconv.Atoi(r.Form.Get("w"))
|
width, err := strconv.Atoi(r.Form.Get("w"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
d := getDaemon(eng)
|
|
||||||
if err := d.ContainerExecResize(vars["name"], height, width); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
d := getDaemon(eng)
|
||||||
|
|
||||||
|
return d.ContainerExecResize(vars["name"], height, width)
|
||||||
}
|
}
|
||||||
|
|
||||||
func optionsHandler(eng *engine.Engine, version version.Version, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
func optionsHandler(eng *engine.Engine, version version.Version, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
||||||
|
|
25
integration-cli/docker_api_exec_resize_test.go
Normal file
25
integration-cli/docker_api_exec_resize_test.go
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os/exec"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestExecResizeApiHeightWidthNoInt(t *testing.T) {
|
||||||
|
runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "top")
|
||||||
|
out, _, err := runCommandWithOutput(runCmd)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf(out, err)
|
||||||
|
}
|
||||||
|
defer deleteAllContainers()
|
||||||
|
cleanedContainerID := strings.TrimSpace(out)
|
||||||
|
|
||||||
|
endpoint := "/exec/" + cleanedContainerID + "/resize?h=foo&w=bar"
|
||||||
|
_, err = sockRequest("POST", endpoint, nil)
|
||||||
|
if err == nil {
|
||||||
|
t.Fatal("Expected exec resize Request to fail")
|
||||||
|
}
|
||||||
|
|
||||||
|
logDone("container exec resize - height, width no int fail")
|
||||||
|
}
|
|
@ -24,6 +24,24 @@ func TestResizeApiResponse(t *testing.T) {
|
||||||
logDone("container resize - when started")
|
logDone("container resize - when started")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestResizeApiHeightWidthNoInt(t *testing.T) {
|
||||||
|
runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "top")
|
||||||
|
out, _, err := runCommandWithOutput(runCmd)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf(out, err)
|
||||||
|
}
|
||||||
|
defer deleteAllContainers()
|
||||||
|
cleanedContainerID := strings.TrimSpace(out)
|
||||||
|
|
||||||
|
endpoint := "/containers/" + cleanedContainerID + "/resize?h=foo&w=bar"
|
||||||
|
_, err = sockRequest("POST", endpoint, nil)
|
||||||
|
if err == nil {
|
||||||
|
t.Fatal("Expected resize Request to fail")
|
||||||
|
}
|
||||||
|
|
||||||
|
logDone("container resize - height, width no int fail")
|
||||||
|
}
|
||||||
|
|
||||||
func TestResizeApiResponseWhenContainerNotStarted(t *testing.T) {
|
func TestResizeApiResponseWhenContainerNotStarted(t *testing.T) {
|
||||||
runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "true")
|
runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "true")
|
||||||
out, _, err := runCommandWithOutput(runCmd)
|
out, _, err := runCommandWithOutput(runCmd)
|
||||||
|
|
Loading…
Add table
Reference in a new issue