image_load.go 777 B

12345678910111213141516171819202122232425262728293031
  1. package client
  2. import (
  3. "io"
  4. "net/url"
  5. "golang.org/x/net/context"
  6. "github.com/docker/engine-api/types"
  7. )
  8. // ImageLoad loads an image in the docker host from the client host.
  9. // It's up to the caller to close the io.ReadCloser returned by
  10. // this function.
  11. func (cli *Client) ImageLoad(ctx context.Context, input io.Reader, quiet bool) (types.ImageLoadResponse, error) {
  12. v := url.Values{}
  13. v.Set("quiet", "0")
  14. if quiet {
  15. v.Set("quiet", "1")
  16. }
  17. headers := map[string][]string{"Content-Type": {"application/x-tar"}}
  18. resp, err := cli.postRaw(ctx, "/images/load", v, input, headers)
  19. if err != nil {
  20. return types.ImageLoadResponse{}, err
  21. }
  22. return types.ImageLoadResponse{
  23. Body: resp.body,
  24. JSON: resp.header.Get("Content-Type") == "application/json",
  25. }, nil
  26. }