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

     1  package lib
     2  
     3  import (
     4  	"io"
     5  	"net/url"
     6  
     7  	"github.com/docker/docker/api/types"
     8  )
     9  
    10  // ImageImport creates a new image based in the source options.
    11  // It returns the JSON content in the response body.
    12  func (cli *Client) ImageImport(options types.ImageImportOptions) (io.ReadCloser, error) {
    13  	query := url.Values{}
    14  	query.Set("fromSrc", options.SourceName)
    15  	query.Set("repo", options.RepositoryName)
    16  	query.Set("tag", options.Tag)
    17  	query.Set("message", options.Message)
    18  	for _, change := range options.Changes {
    19  		query.Add("changes", change)
    20  	}
    21  
    22  	resp, err := cli.postRaw("/images/create", query, options.Source, nil)
    23  	if err != nil {
    24  		return nil, err
    25  	}
    26  	return resp.body, nil
    27  }