resize.go 820 B

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