Signed-off-by: David Calavera <david.calavera@gmail.com>
| ... | ... |
@@ -23,6 +23,7 @@ type apiClient interface {
|
| 23 | 23 |
ContainerExecAttach(execID string, config runconfig.ExecConfig) (types.HijackedResponse, error) |
| 24 | 24 |
ContainerExecCreate(config runconfig.ExecConfig) (types.ContainerExecCreateResponse, error) |
| 25 | 25 |
ContainerExecInspect(execID string) (types.ContainerExecInspect, error) |
| 26 |
+ ContainerExecResize(options types.ResizeOptions) error |
|
| 26 | 27 |
ContainerExecStart(execID string, config types.ExecStartCheck) error |
| 27 | 28 |
ContainerExport(containerID string) (io.ReadCloser, error) |
| 28 | 29 |
ContainerInspect(containerID string) (types.ContainerJSON, error) |
| ... | ... |
@@ -33,6 +34,7 @@ type apiClient interface {
|
| 33 | 33 |
ContainerPause(containerID string) error |
| 34 | 34 |
ContainerRemove(options types.ContainerRemoveOptions) error |
| 35 | 35 |
ContainerRename(containerID, newContainerName string) error |
| 36 |
+ ContainerResize(options types.ResizeOptions) error |
|
| 36 | 37 |
ContainerRestart(containerID string, timeout int) error |
| 37 | 38 |
ContainerStatPath(containerID, path string) (types.ContainerPathStat, error) |
| 38 | 39 |
ContainerStats(containerID string, stream bool) (io.ReadCloser, error) |
| 39 | 40 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,28 @@ |
| 0 |
+package lib |
|
| 1 |
+ |
|
| 2 |
+import ( |
|
| 3 |
+ "net/url" |
|
| 4 |
+ "strconv" |
|
| 5 |
+ |
|
| 6 |
+ "github.com/docker/docker/api/types" |
|
| 7 |
+) |
|
| 8 |
+ |
|
| 9 |
+// ContainerResize changes the size of the tty for a container. |
|
| 10 |
+func (cli *Client) ContainerResize(options types.ResizeOptions) error {
|
|
| 11 |
+ return cli.resize("/containers/"+options.ID, options.Height, options.Width)
|
|
| 12 |
+} |
|
| 13 |
+ |
|
| 14 |
+// ContainerExecResize changes the size of the tty for an exec process running inside a container. |
|
| 15 |
+func (cli *Client) ContainerExecResize(options types.ResizeOptions) error {
|
|
| 16 |
+ return cli.resize("/exec/"+options.ID, options.Height, options.Width)
|
|
| 17 |
+} |
|
| 18 |
+ |
|
| 19 |
+func (cli *Client) resize(basePath string, height, width int) error {
|
|
| 20 |
+ query := url.Values{}
|
|
| 21 |
+ query.Set("h", strconv.Itoa(height))
|
|
| 22 |
+ query.Set("w", strconv.Itoa(width))
|
|
| 23 |
+ |
|
| 24 |
+ resp, err := cli.post(basePath+"/resize", query, nil, nil) |
|
| 25 |
+ ensureReaderClosed(resp) |
|
| 26 |
+ return err |
|
| 27 |
+} |
| ... | ... |
@@ -9,17 +9,16 @@ import ( |
| 9 | 9 |
"io" |
| 10 | 10 |
"io/ioutil" |
| 11 | 11 |
"net/http" |
| 12 |
- "net/url" |
|
| 13 | 12 |
"os" |
| 14 | 13 |
gosignal "os/signal" |
| 15 | 14 |
"runtime" |
| 16 |
- "strconv" |
|
| 17 | 15 |
"strings" |
| 18 | 16 |
"time" |
| 19 | 17 |
|
| 20 | 18 |
"github.com/Sirupsen/logrus" |
| 21 | 19 |
"github.com/docker/docker/api" |
| 22 | 20 |
"github.com/docker/docker/api/client/lib" |
| 21 |
+ "github.com/docker/docker/api/types" |
|
| 23 | 22 |
"github.com/docker/docker/cliconfig" |
| 24 | 23 |
"github.com/docker/docker/dockerversion" |
| 25 | 24 |
"github.com/docker/docker/pkg/jsonmessage" |
| ... | ... |
@@ -259,18 +258,21 @@ func (cli *DockerCli) resizeTty(id string, isExec bool) {
|
| 259 | 259 |
if height == 0 && width == 0 {
|
| 260 | 260 |
return |
| 261 | 261 |
} |
| 262 |
- v := url.Values{}
|
|
| 263 |
- v.Set("h", strconv.Itoa(height))
|
|
| 264 |
- v.Set("w", strconv.Itoa(width))
|
|
| 265 | 262 |
|
| 266 |
- path := "" |
|
| 263 |
+ options := types.ResizeOptions{
|
|
| 264 |
+ ID: id, |
|
| 265 |
+ Height: height, |
|
| 266 |
+ Width: width, |
|
| 267 |
+ } |
|
| 268 |
+ |
|
| 269 |
+ var err error |
|
| 267 | 270 |
if !isExec {
|
| 268 |
- path = "/containers/" + id + "/resize?" |
|
| 271 |
+ err = cli.client.ContainerExecResize(options) |
|
| 269 | 272 |
} else {
|
| 270 |
- path = "/exec/" + id + "/resize?" |
|
| 273 |
+ err = cli.client.ContainerResize(options) |
|
| 271 | 274 |
} |
| 272 | 275 |
|
| 273 |
- if _, _, err := readBody(cli.call("POST", path+v.Encode(), nil, nil)); err != nil {
|
|
| 276 |
+ if err != nil {
|
|
| 274 | 277 |
logrus.Debugf("Error resize: %s", err)
|
| 275 | 278 |
} |
| 276 | 279 |
} |
| ... | ... |
@@ -197,7 +197,13 @@ type ImageRemoveOptions struct {
|
| 197 | 197 |
PruneChildren bool |
| 198 | 198 |
} |
| 199 | 199 |
|
| 200 |
-// ImageTagOptions hold parameters to tag an image |
|
| 200 |
+// ImageSearchOptions holds parameters to search images with. |
|
| 201 |
+type ImageSearchOptions struct {
|
|
| 202 |
+ Term string |
|
| 203 |
+ RegistryAuth string |
|
| 204 |
+} |
|
| 205 |
+ |
|
| 206 |
+// ImageTagOptions holds parameters to tag an image |
|
| 201 | 207 |
type ImageTagOptions struct {
|
| 202 | 208 |
ImageID string |
| 203 | 209 |
RepositoryName string |
| ... | ... |
@@ -205,6 +211,15 @@ type ImageTagOptions struct {
|
| 205 | 205 |
Force bool |
| 206 | 206 |
} |
| 207 | 207 |
|
| 208 |
+// ResizeOptions holds parameters to resize a tty. |
|
| 209 |
+// It can be used to resize container ttys and |
|
| 210 |
+// exec process ttys too. |
|
| 211 |
+type ResizeOptions struct {
|
|
| 212 |
+ ID string |
|
| 213 |
+ Height int |
|
| 214 |
+ Width int |
|
| 215 |
+} |
|
| 216 |
+ |
|
| 208 | 217 |
// VersionResponse holds version information for the client and the server |
| 209 | 218 |
type VersionResponse struct {
|
| 210 | 219 |
Client *Version |