2015-12-03 17:11:37 -05:00
|
|
|
package lib
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
"net/url"
|
|
|
|
|
2015-12-04 17:02:06 -05:00
|
|
|
"github.com/docker/docker/api/types"
|
|
|
|
)
|
2015-12-03 17:11:37 -05:00
|
|
|
|
2015-12-04 17:02:06 -05:00
|
|
|
// ImageImport creates a new image based in the source options.
|
2015-12-03 17:11:37 -05:00
|
|
|
// It returns the JSON content in the response body.
|
2015-12-04 17:02:06 -05:00
|
|
|
func (cli *Client) ImageImport(options types.ImageImportOptions) (io.ReadCloser, error) {
|
2015-12-04 21:06:12 -05:00
|
|
|
query := url.Values{}
|
2015-12-03 17:11:37 -05:00
|
|
|
query.Set("fromSrc", options.SourceName)
|
|
|
|
query.Set("repo", options.RepositoryName)
|
|
|
|
query.Set("tag", options.Tag)
|
|
|
|
query.Set("message", options.Message)
|
|
|
|
for _, change := range options.Changes {
|
|
|
|
query.Add("changes", change)
|
|
|
|
}
|
|
|
|
|
2015-12-05 20:28:36 -05:00
|
|
|
resp, err := cli.postRaw("/images/create", query, options.Source, nil)
|
2015-12-03 17:11:37 -05:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resp.body, nil
|
|
|
|
}
|