github.com/ssdev-go/moby@v17.12.1-ce-rc2+incompatible/client/image_load.go (about)

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