2015-12-03 11:14:07 -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 11:14:07 -05:00
|
|
|
|
2015-12-04 17:02:06 -05:00
|
|
|
// ImageCreate creates a new image based in the parent options.
|
2015-12-03 11:14:07 -05:00
|
|
|
// It returns the JSON content in the response body.
|
2015-12-04 17:02:06 -05:00
|
|
|
func (cli *Client) ImageCreate(options types.ImageCreateOptions) (io.ReadCloser, error) {
|
2015-12-04 21:06:12 -05:00
|
|
|
query := url.Values{}
|
2015-12-03 11:14:07 -05:00
|
|
|
query.Set("fromImage", options.Parent)
|
|
|
|
query.Set("tag", options.Tag)
|
2015-12-06 15:17:34 -05:00
|
|
|
resp, err := cli.tryImageCreate(query, options.RegistryAuth)
|
2015-12-03 11:14:07 -05:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return resp.body, nil
|
|
|
|
}
|
2015-12-06 15:17:34 -05:00
|
|
|
|
|
|
|
func (cli *Client) tryImageCreate(query url.Values, registryAuth string) (*serverResponse, error) {
|
|
|
|
headers := map[string][]string{"X-Registry-Auth": {registryAuth}}
|
|
|
|
return cli.post("/images/create", query, nil, headers)
|
|
|
|
}
|