-
Notifications
You must be signed in to change notification settings - Fork 18.7k
/
resize.go
53 lines (48 loc) · 1.23 KB
/
resize.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package daemon
import (
"strconv"
"github.com/docker/docker/engine"
)
func (daemon *Daemon) ContainerResize(job *engine.Job) engine.Status {
if len(job.Args) != 3 {
return job.Errorf("Not enough arguments. Usage: %s CONTAINER HEIGHT WIDTH\n", job.Name)
}
name := job.Args[0]
height, err := strconv.Atoi(job.Args[1])
if err != nil {
return job.Error(err)
}
width, err := strconv.Atoi(job.Args[2])
if err != nil {
return job.Error(err)
}
if container := daemon.Get(name); container != nil {
if err := container.Resize(height, width); err != nil {
return job.Error(err)
}
return engine.StatusOK
}
return job.Errorf("No such container: %s", name)
}
func (daemon *Daemon) ContainerExecResize(job *engine.Job) engine.Status {
if len(job.Args) != 3 {
return job.Errorf("Not enough arguments. Usage: %s EXEC HEIGHT WIDTH\n", job.Name)
}
name := job.Args[0]
height, err := strconv.Atoi(job.Args[1])
if err != nil {
return job.Error(err)
}
width, err := strconv.Atoi(job.Args[2])
if err != nil {
return job.Error(err)
}
execConfig, err := daemon.getExecConfig(name)
if err != nil {
return job.Error(err)
}
if err := execConfig.Resize(height, width); err != nil {
return job.Error(err)
}
return engine.StatusOK
}