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