зеркало из https://github.com/microsoft/docker.git
fix api server resize&execResize
Signed-off-by: Antonio Murdaca <me@runcom.ninja>
This commit is contained in:
Родитель
a54fd325e6
Коммит
3341f3a355
|
@ -1036,11 +1036,11 @@ func postContainersResize(eng *engine.Engine, version version.Version, w http.Re
|
|||
|
||||
height, err := strconv.Atoi(r.Form.Get("h"))
|
||||
if err != nil {
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
width, err := strconv.Atoi(r.Form.Get("w"))
|
||||
if err != nil {
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
|
||||
d := getDaemon(eng)
|
||||
|
@ -1049,11 +1049,7 @@ func postContainersResize(eng *engine.Engine, version version.Version, w http.Re
|
|||
return err
|
||||
}
|
||||
|
||||
if err := cont.Resize(height, width); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return cont.Resize(height, width)
|
||||
}
|
||||
|
||||
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"))
|
||||
if err != nil {
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
width, err := strconv.Atoi(r.Form.Get("w"))
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
d := getDaemon(eng)
|
||||
if err := d.ContainerExecResize(vars["name"], height, width); err != nil {
|
||||
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 {
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
||||
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) {
|
||||
runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "true")
|
||||
out, _, err := runCommandWithOutput(runCmd)
|
||||
|
|
Загрузка…
Ссылка в новой задаче