github.com/walkingsparrow/docker@v1.4.2-0.20151218153551-b708a2249bfa/api/client/lib/resize.go (about)

     1  package lib
     2  
     3  import (
     4  	"net/url"
     5  	"strconv"
     6  
     7  	"github.com/docker/docker/api/types"
     8  )
     9  
    10  // ContainerResize changes the size of the tty for a container.
    11  func (cli *Client) ContainerResize(options types.ResizeOptions) error {
    12  	return cli.resize("/containers/"+options.ID, options.Height, options.Width)
    13  }
    14  
    15  // ContainerExecResize changes the size of the tty for an exec process running inside a container.
    16  func (cli *Client) ContainerExecResize(options types.ResizeOptions) error {
    17  	return cli.resize("/exec/"+options.ID, options.Height, options.Width)
    18  }
    19  
    20  func (cli *Client) resize(basePath string, height, width int) error {
    21  	query := url.Values{}
    22  	query.Set("h", strconv.Itoa(height))
    23  	query.Set("w", strconv.Itoa(width))
    24  
    25  	resp, err := cli.post(basePath+"/resize", query, nil, nil)
    26  	ensureReaderClosed(resp)
    27  	return err
    28  }