Upgrade go-dockerclient dependency to support CgroupParent

This commit is contained in:
Tobi Knaup
2015-04-23 20:46:45 +00:00
parent f7831dcd93
commit 522d4c3b85
14 changed files with 329 additions and 123 deletions

View File

@@ -26,6 +26,7 @@ type APIImages struct {
Size int64 `json:"Size,omitempty" yaml:"Size,omitempty"`
VirtualSize int64 `json:"VirtualSize,omitempty" yaml:"VirtualSize,omitempty"`
ParentID string `json:"ParentId,omitempty" yaml:"ParentId,omitempty"`
RepoDigests []string `json:"RepoDigests,omitempty" yaml:"RepoDigests,omitempty"`
}
// Image is the type representing a docker image and its various properties
@@ -71,10 +72,11 @@ type ImagePre012 struct {
// ListImagesOptions specify parameters to the ListImages function.
//
// See http://goo.gl/2rOLFF for more details.
// See http://goo.gl/HRVN1Z for more details.
type ListImagesOptions struct {
All bool
Filters map[string][]string
Digests bool
}
var (
@@ -92,14 +94,19 @@ var (
// ErrMultipleContexts is the error returned when both a ContextDir and
// InputStream are provided in BuildImageOptions
ErrMultipleContexts = errors.New("image build may not be provided BOTH context dir and input stream")
// ErrMustSpecifyNames is the error rreturned when the Names field on
// ExportImagesOptions is nil or empty
ErrMustSpecifyNames = errors.New("must specify at least one name to export")
)
// ListImages returns the list of available images in the server.
//
// See http://goo.gl/2rOLFF for more details.
// See http://goo.gl/HRVN1Z for more details.
func (c *Client) ListImages(opts ListImagesOptions) ([]APIImages, error) {
// TODO(pedge): what happens if we specify the digest parameter when using API Version <1.18?
path := "/images/json?" + queryString(opts)
body, _, err := c.do("GET", path, nil, false)
body, _, err := c.do("GET", path, doOptions{})
if err != nil {
return nil, err
}
@@ -115,7 +122,7 @@ func (c *Client) ListImages(opts ListImagesOptions) ([]APIImages, error) {
//
// See http://goo.gl/2oJmNs for more details.
func (c *Client) ImageHistory(name string) ([]ImageHistory, error) {
body, status, err := c.do("GET", "/images/"+name+"/history", nil, false)
body, status, err := c.do("GET", "/images/"+name+"/history", doOptions{})
if status == http.StatusNotFound {
return nil, ErrNoSuchImage
}
@@ -134,7 +141,7 @@ func (c *Client) ImageHistory(name string) ([]ImageHistory, error) {
//
// See http://goo.gl/znj0wM for more details.
func (c *Client) RemoveImage(name string) error {
_, status, err := c.do("DELETE", "/images/"+name, nil, false)
_, status, err := c.do("DELETE", "/images/"+name, doOptions{})
if status == http.StatusNotFound {
return ErrNoSuchImage
}
@@ -156,7 +163,7 @@ type RemoveImageOptions struct {
// See http://goo.gl/znj0wM for more details.
func (c *Client) RemoveImageExtended(name string, opts RemoveImageOptions) error {
uri := fmt.Sprintf("/images/%s?%s", name, queryString(&opts))
_, status, err := c.do("DELETE", uri, nil, false)
_, status, err := c.do("DELETE", uri, doOptions{})
if status == http.StatusNotFound {
return ErrNoSuchImage
}
@@ -167,7 +174,7 @@ func (c *Client) RemoveImageExtended(name string, opts RemoveImageOptions) error
//
// See http://goo.gl/Q112NY for more details.
func (c *Client) InspectImage(name string) (*Image, error) {
body, status, err := c.do("GET", "/images/"+name+"/json", nil, false)
body, status, err := c.do("GET", "/images/"+name+"/json", doOptions{})
if status == http.StatusNotFound {
return nil, ErrNoSuchImage
}
@@ -236,8 +243,12 @@ func (c *Client) PushImage(opts PushImageOptions, auth AuthConfiguration) error
name := opts.Name
opts.Name = ""
path := "/images/" + name + "/push?" + queryString(&opts)
headers := headersWithAuth(auth)
return c.stream("POST", path, true, opts.RawJSONStream, headers, nil, opts.OutputStream, nil)
return c.stream("POST", path, streamOptions{
setRawTerminal: true,
rawJSONStream: opts.RawJSONStream,
headers: headersWithAuth(auth),
stdout: opts.OutputStream,
})
}
// PullImageOptions present the set of options available for pulling an image
@@ -266,7 +277,13 @@ func (c *Client) PullImage(opts PullImageOptions, auth AuthConfiguration) error
func (c *Client) createImage(qs string, headers map[string]string, in io.Reader, w io.Writer, rawJSONStream bool) error {
path := "/images/create?" + qs
return c.stream("POST", path, true, rawJSONStream, headers, in, w, nil)
return c.stream("POST", path, streamOptions{
setRawTerminal: true,
rawJSONStream: rawJSONStream,
headers: headers,
in: in,
stdout: w,
})
}
// LoadImageOptions represents the options for LoadImage Docker API Call
@@ -280,7 +297,10 @@ type LoadImageOptions struct {
//
// See http://goo.gl/Y8NNCq for more details.
func (c *Client) LoadImage(opts LoadImageOptions) error {
return c.stream("POST", "/images/load", true, false, nil, opts.InputStream, nil, nil)
return c.stream("POST", "/images/load", streamOptions{
setRawTerminal: true,
in: opts.InputStream,
})
}
// ExportImageOptions represent the options for ExportImage Docker API call
@@ -295,7 +315,31 @@ type ExportImageOptions struct {
//
// See http://goo.gl/mi6kvk for more details.
func (c *Client) ExportImage(opts ExportImageOptions) error {
return c.stream("GET", fmt.Sprintf("/images/%s/get", opts.Name), true, false, nil, nil, opts.OutputStream, nil)
return c.stream("GET", fmt.Sprintf("/images/%s/get", opts.Name), streamOptions{
setRawTerminal: true,
stdout: opts.OutputStream,
})
}
// ExportImagesOptions represent the options for ExportImages Docker API call
//
// See http://goo.gl/YeZzQK for more details.
type ExportImagesOptions struct {
Names []string
OutputStream io.Writer `qs:"-"`
}
// ExportImages exports one or more images (as a tar file) into the stream
//
// See http://goo.gl/YeZzQK for more details.
func (c *Client) ExportImages(opts ExportImagesOptions) error {
if opts.Names == nil || len(opts.Names) == 0 {
return ErrMustSpecifyNames
}
return c.stream("GET", "/images/get?"+queryString(&opts), streamOptions{
setRawTerminal: true,
stdout: opts.OutputStream,
})
}
// ImportImageOptions present the set of informations available for importing
@@ -382,8 +426,13 @@ func (c *Client) BuildImage(opts BuildImageOptions) error {
}
}
return c.stream("POST", fmt.Sprintf("/build?%s",
queryString(&opts)), true, opts.RawJSONStream, headers, opts.InputStream, opts.OutputStream, nil)
return c.stream("POST", fmt.Sprintf("/build?%s", queryString(&opts)), streamOptions{
setRawTerminal: true,
rawJSONStream: opts.RawJSONStream,
headers: headers,
in: opts.InputStream,
stdout: opts.OutputStream,
})
}
// TagImageOptions present the set of options to tag an image.
@@ -403,7 +452,7 @@ func (c *Client) TagImage(name string, opts TagImageOptions) error {
return ErrNoSuchImage
}
_, status, err := c.do("POST", fmt.Sprintf("/images/"+name+"/tag?%s",
queryString(&opts)), nil, false)
queryString(&opts)), doOptions{})
if status == http.StatusNotFound {
return ErrNoSuchImage
@@ -454,7 +503,7 @@ type APIImageSearch struct {
//
// See http://goo.gl/xI5lLZ for more details.
func (c *Client) SearchImages(term string) ([]APIImageSearch, error) {
body, _, err := c.do("GET", "/images/search?term="+term, nil, false)
body, _, err := c.do("GET", "/images/search?term="+term, doOptions{})
if err != nil {
return nil, err
}