summaryrefslogtreecommitdiff
path: root/vendor/github.com/fsouza/go-dockerclient/image.go
diff options
context:
space:
mode:
authorNalin Dahyabhai <nalin@redhat.com>2019-10-24 10:37:22 -0400
committerNalin Dahyabhai <nalin@redhat.com>2019-10-29 13:35:18 -0400
commita4a70b4506ec4abb8b3bbc3873ee5ca015a8ed08 (patch)
tree4e7a50576d4db83450c58054e276f33bbd2cdb3a /vendor/github.com/fsouza/go-dockerclient/image.go
parent59582c55b798f0a2d086981ca9a8ddd8314fd0c2 (diff)
downloadpodman-a4a70b4506ec4abb8b3bbc3873ee5ca015a8ed08.tar.gz
podman-a4a70b4506ec4abb8b3bbc3873ee5ca015a8ed08.tar.bz2
podman-a4a70b4506ec4abb8b3bbc3873ee5ca015a8ed08.zip
bump containers/image to v5.0.0, buildah to v1.11.4
Move to containers/image v5 and containers/buildah to v1.11.4. Replace an equality check with a type assertion when checking for a docker.ErrUnauthorizedForCredentials in `podman login`. Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Diffstat (limited to 'vendor/github.com/fsouza/go-dockerclient/image.go')
-rw-r--r--vendor/github.com/fsouza/go-dockerclient/image.go107
1 files changed, 63 insertions, 44 deletions
diff --git a/vendor/github.com/fsouza/go-dockerclient/image.go b/vendor/github.com/fsouza/go-dockerclient/image.go
index 31b6c53f4..5f72d6645 100644
--- a/vendor/github.com/fsouza/go-dockerclient/image.go
+++ b/vendor/github.com/fsouza/go-dockerclient/image.go
@@ -109,7 +109,7 @@ type ListImagesOptions struct {
// See https://goo.gl/BVzauZ for more details.
func (c *Client) ListImages(opts ListImagesOptions) ([]APIImages, error) {
path := "/images/json?" + queryString(opts)
- resp, err := c.do("GET", path, doOptions{context: opts.Context})
+ resp, err := c.do(http.MethodGet, path, doOptions{context: opts.Context})
if err != nil {
return nil, err
}
@@ -129,13 +129,14 @@ type ImageHistory struct {
Created int64 `json:"Created,omitempty" yaml:"Created,omitempty" toml:"Tags,omitempty"`
CreatedBy string `json:"CreatedBy,omitempty" yaml:"CreatedBy,omitempty" toml:"CreatedBy,omitempty"`
Size int64 `json:"Size,omitempty" yaml:"Size,omitempty" toml:"Size,omitempty"`
+ Comment string `json:"Comment,omitempty" yaml:"Comment,omitempty" toml:"Comment,omitempty"`
}
// ImageHistory returns the history of the image by its name or ID.
//
// See https://goo.gl/fYtxQa for more details.
func (c *Client) ImageHistory(name string) ([]ImageHistory, error) {
- resp, err := c.do("GET", "/images/"+name+"/history", doOptions{})
+ resp, err := c.do(http.MethodGet, "/images/"+name+"/history", doOptions{})
if err != nil {
if e, ok := err.(*Error); ok && e.Status == http.StatusNotFound {
return nil, ErrNoSuchImage
@@ -154,7 +155,7 @@ func (c *Client) ImageHistory(name string) ([]ImageHistory, error) {
//
// See https://goo.gl/Vd2Pck for more details.
func (c *Client) RemoveImage(name string) error {
- resp, err := c.do("DELETE", "/images/"+name, doOptions{})
+ resp, err := c.do(http.MethodDelete, "/images/"+name, doOptions{})
if err != nil {
if e, ok := err.(*Error); ok && e.Status == http.StatusNotFound {
return ErrNoSuchImage
@@ -181,7 +182,7 @@ type RemoveImageOptions struct {
// See https://goo.gl/Vd2Pck for more details.
func (c *Client) RemoveImageExtended(name string, opts RemoveImageOptions) error {
uri := fmt.Sprintf("/images/%s?%s", name, queryString(&opts))
- resp, err := c.do("DELETE", uri, doOptions{context: opts.Context})
+ resp, err := c.do(http.MethodDelete, uri, doOptions{context: opts.Context})
if err != nil {
if e, ok := err.(*Error); ok && e.Status == http.StatusNotFound {
return ErrNoSuchImage
@@ -196,7 +197,7 @@ func (c *Client) RemoveImageExtended(name string, opts RemoveImageOptions) error
//
// See https://goo.gl/ncLTG8 for more details.
func (c *Client) InspectImage(name string) (*Image, error) {
- resp, err := c.do("GET", "/images/"+name+"/json", doOptions{})
+ resp, err := c.do(http.MethodGet, "/images/"+name+"/json", doOptions{})
if err != nil {
if e, ok := err.(*Error); ok && e.Status == http.StatusNotFound {
return nil, ErrNoSuchImage
@@ -271,7 +272,7 @@ func (c *Client) PushImage(opts PushImageOptions, auth AuthConfiguration) error
name := opts.Name
opts.Name = ""
path := "/images/" + name + "/push?" + queryString(&opts)
- return c.stream("POST", path, streamOptions{
+ return c.stream(http.MethodPost, path, streamOptions{
setRawTerminal: true,
rawJSONStream: opts.RawJSONStream,
headers: headers,
@@ -322,12 +323,13 @@ func (c *Client) PullImage(opts PullImageOptions, auth AuthConfiguration) error
return c.createImage(&opts, headers, nil, opts.OutputStream, opts.RawJSONStream, opts.InactivityTimeout, opts.Context)
}
+//nolint:golint
func (c *Client) createImage(opts interface{}, headers map[string]string, in io.Reader, w io.Writer, rawJSONStream bool, timeout time.Duration, context context.Context) error {
url, err := c.getPath("/images/create", opts)
if err != nil {
return err
}
- return c.streamUrl("POST", url, streamOptions{
+ return c.streamURL(http.MethodPost, url, streamOptions{
setRawTerminal: true,
headers: headers,
in: in,
@@ -351,7 +353,7 @@ type LoadImageOptions struct {
//
// See https://goo.gl/rEsBV3 for more details.
func (c *Client) LoadImage(opts LoadImageOptions) error {
- return c.stream("POST", "/images/load", streamOptions{
+ return c.stream(http.MethodPost, "/images/load", streamOptions{
setRawTerminal: true,
in: opts.InputStream,
stdout: opts.OutputStream,
@@ -373,7 +375,7 @@ type ExportImageOptions struct {
//
// See https://goo.gl/AuySaA for more details.
func (c *Client) ExportImage(opts ExportImageOptions) error {
- return c.stream("GET", fmt.Sprintf("/images/%s/get", opts.Name), streamOptions{
+ return c.stream(http.MethodGet, fmt.Sprintf("/images/%s/get", opts.Name), streamOptions{
setRawTerminal: true,
stdout: opts.OutputStream,
inactivityTimeout: opts.InactivityTimeout,
@@ -403,7 +405,7 @@ func (c *Client) ExportImages(opts ExportImagesOptions) error {
var err error
var exporturl string
if c.requestedAPIVersion.GreaterThanOrEqualTo(apiVersion125) {
- var str string = opts.Names[0]
+ str := opts.Names[0]
for _, val := range opts.Names[1:] {
str += "," + val
}
@@ -412,7 +414,6 @@ func (c *Client) ExportImages(opts ExportImagesOptions) error {
OutputStream: opts.OutputStream,
InactivityTimeout: opts.InactivityTimeout,
Context: opts.Context,
-
})
} else {
exporturl, err = c.getPath("/images/get", &opts)
@@ -420,7 +421,7 @@ func (c *Client) ExportImages(opts ExportImagesOptions) error {
if err != nil {
return err
}
- return c.streamUrl("GET", exporturl, streamOptions{
+ return c.streamURL(http.MethodGet, exporturl, streamOptions{
setRawTerminal: true,
stdout: opts.OutputStream,
inactivityTimeout: opts.InactivityTimeout,
@@ -471,35 +472,39 @@ func (c *Client) ImportImage(opts ImportImageOptions) error {
// https://goo.gl/4nYHwV.
type BuildImageOptions struct {
Context context.Context
- Name string `qs:"t"`
- Dockerfile string `qs:"dockerfile"`
- CacheFrom []string `qs:"-"`
- Memory int64 `qs:"memory"`
- Memswap int64 `qs:"memswap"`
- CPUShares int64 `qs:"cpushares"`
- CPUQuota int64 `qs:"cpuquota"`
- CPUPeriod int64 `qs:"cpuperiod"`
- CPUSetCPUs string `qs:"cpusetcpus"`
- Labels map[string]string `qs:"labels"`
- InputStream io.Reader `qs:"-"`
- OutputStream io.Writer `qs:"-"`
- Remote string `qs:"remote"`
+ Name string `qs:"t"`
+ Dockerfile string `ver:"1.25"`
+ ExtraHosts string `ver:"1.28"`
+ CacheFrom []string `qs:"-" ver:"1.25"`
+ Memory int64
+ Memswap int64
+ ShmSize int64
+ CPUShares int64
+ CPUQuota int64 `ver:"1.21"`
+ CPUPeriod int64 `ver:"1.21"`
+ CPUSetCPUs string
+ Labels map[string]string
+ InputStream io.Reader `qs:"-"`
+ OutputStream io.Writer `qs:"-"`
+ Remote string
Auth AuthConfiguration `qs:"-"` // for older docker X-Registry-Auth header
AuthConfigs AuthConfigurations `qs:"-"` // for newer docker X-Registry-Config header
ContextDir string `qs:"-"`
- Ulimits []ULimit `qs:"-"`
- BuildArgs []BuildArg `qs:"-"`
- NetworkMode string `qs:"networkmode"`
+ Ulimits []ULimit `qs:"-" ver:"1.18"`
+ BuildArgs []BuildArg `qs:"-" ver:"1.21"`
+ NetworkMode string `ver:"1.25"`
+ Platform string `ver:"1.32"`
InactivityTimeout time.Duration `qs:"-"`
- CgroupParent string `qs:"cgroupparent"`
- SecurityOpt []string `qs:"securityopt"`
- Target string `gs:"target"`
- NoCache bool `qs:"nocache"`
- SuppressOutput bool `qs:"q"`
- Pull bool `qs:"pull"`
- RmTmpContainer bool `qs:"rm"`
- ForceRmTmpContainer bool `qs:"forcerm"`
- RawJSONStream bool `qs:"-"`
+ CgroupParent string
+ SecurityOpt []string
+ Target string
+ Outputs string `ver:"1.40"`
+ NoCache bool
+ SuppressOutput bool `qs:"q"`
+ Pull bool `ver:"1.16"`
+ RmTmpContainer bool `qs:"rm"`
+ ForceRmTmpContainer bool `qs:"forcerm" ver:"1.12"`
+ RawJSONStream bool `qs:"-"`
}
// BuildArg represents arguments that can be passed to the image when building
@@ -542,13 +547,16 @@ func (c *Client) BuildImage(opts BuildImageOptions) error {
return err
}
}
- qs := queryString(&opts)
+ qs, ver := queryStringVersion(&opts)
- if c.serverAPIVersion.GreaterThanOrEqualTo(apiVersion125) && len(opts.CacheFrom) > 0 {
+ if len(opts.CacheFrom) > 0 {
if b, err := json.Marshal(opts.CacheFrom); err == nil {
item := url.Values(map[string][]string{})
item.Add("cachefrom", string(b))
qs = fmt.Sprintf("%s&%s", qs, item.Encode())
+ if ver == nil || apiVersion125.GreaterThan(ver) {
+ ver = apiVersion125
+ }
}
}
@@ -557,6 +565,9 @@ func (c *Client) BuildImage(opts BuildImageOptions) error {
item := url.Values(map[string][]string{})
item.Add("ulimits", string(b))
qs = fmt.Sprintf("%s&%s", qs, item.Encode())
+ if ver == nil || apiVersion118.GreaterThan(ver) {
+ ver = apiVersion118
+ }
}
}
@@ -569,10 +580,18 @@ func (c *Client) BuildImage(opts BuildImageOptions) error {
item := url.Values(map[string][]string{})
item.Add("buildargs", string(b))
qs = fmt.Sprintf("%s&%s", qs, item.Encode())
+ if ver == nil || apiVersion121.GreaterThan(ver) {
+ ver = apiVersion121
+ }
}
}
- return c.stream("POST", fmt.Sprintf("/build?%s", qs), streamOptions{
+ buildURL, err := c.pathVersionCheck("/build", qs, ver)
+ if err != nil {
+ return err
+ }
+
+ return c.streamURL(http.MethodPost, buildURL, streamOptions{
setRawTerminal: true,
rawJSONStream: opts.RawJSONStream,
headers: headers,
@@ -610,7 +629,7 @@ func (c *Client) TagImage(name string, opts TagImageOptions) error {
if name == "" {
return ErrNoSuchImage
}
- resp, err := c.do("POST", "/images/"+name+"/tag?"+queryString(&opts), doOptions{
+ resp, err := c.do(http.MethodPost, "/images/"+name+"/tag?"+queryString(&opts), doOptions{
context: opts.Context,
})
if err != nil {
@@ -666,7 +685,7 @@ type APIImageSearch struct {
//
// See https://goo.gl/KLO9IZ for more details.
func (c *Client) SearchImages(term string) ([]APIImageSearch, error) {
- resp, err := c.do("GET", "/images/search?term="+term, doOptions{})
+ resp, err := c.do(http.MethodGet, "/images/search?term="+term, doOptions{})
if err != nil {
return nil, err
}
@@ -687,7 +706,7 @@ func (c *Client) SearchImagesEx(term string, auth AuthConfiguration) ([]APIImage
return nil, err
}
- resp, err := c.do("GET", "/images/search?term="+term, doOptions{
+ resp, err := c.do(http.MethodGet, "/images/search?term="+term, doOptions{
headers: headers,
})
if err != nil {
@@ -725,7 +744,7 @@ type PruneImagesResults struct {
// See https://goo.gl/qfZlbZ for more details.
func (c *Client) PruneImages(opts PruneImagesOptions) (*PruneImagesResults, error) {
path := "/images/prune?" + queryString(opts)
- resp, err := c.do("POST", path, doOptions{context: opts.Context})
+ resp, err := c.do(http.MethodPost, path, doOptions{context: opts.Context})
if err != nil {
return nil, err
}