github.com/rish1988/moby@v25.0.2+incompatible/client/image_load.go (about)

     1  package client // import "github.com/docker/docker/client"
     2  
     3  import (
     4  	"context"
     5  	"io"
     6  	"net/http"
     7  	"net/url"
     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  	resp, err := cli.postRaw(ctx, "/images/load", v, input, http.Header{
    22  		"Content-Type": {"application/x-tar"},
    23  	})
    24  	if err != nil {
    25  		return types.ImageLoadResponse{}, err
    26  	}
    27  	return types.ImageLoadResponse{
    28  		Body: resp.body,
    29  		JSON: resp.header.Get("Content-Type") == "application/json",
    30  	}, nil
    31  }