1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/api/client/lib/image_create.go
David Calavera 1698fe01f5 Implement docker image create with standalone client lib.
Signed-off-by: David Calavera <david.calavera@gmail.com>
2015-12-09 12:04:53 -05:00

31 lines
833 B
Go

package lib
import (
"io"
"net/url"
)
// CreateImageOptions holds information to create images
type CreateImageOptions struct {
// Parent is the image to create this image from
Parent string
// Tag is the name to tag this image
Tag string
// RegistryAuth is the base64 encoded credentials for this server
RegistryAuth string
}
// CreateImage creates a new image based in the parent options.
// It returns the JSON content in the response body.
func (cli *Client) CreateImage(options CreateImageOptions) (io.ReadCloser, error) {
var query url.Values
query.Set("fromImage", options.Parent)
query.Set("tag", options.Tag)
headers := map[string][]string{"X-Registry-Auth": {options.RegistryAuth}}
resp, err := cli.POST("/images/create", query, nil, headers)
if err != nil {
return nil, err
}
return resp.body, nil
}