Files
docker-cli/components/engine/api/client/lib/image_create.go
David Calavera b2e5fbbc30 Implement docker import with the standalone client lib.
Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 6bf757500b404311cf24c6ce656d317f49b7cc37
Component: engine
2015-12-09 12:04:54 -05:00

32 lines
834 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
}