"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "vendor/github.com/fsouza/go-dockerclient/image.go" between
buildah-1.11.2.tar.gz and buildah-1.11.3.tar.gz

About: Buildah is a tool that facilitates building Open Container Initiative (OCI) container images.

image.go  (buildah-1.11.2):image.go  (buildah-1.11.3)
// Copyright 2013 go-dockerclient authors. All rights reserved. // Copyright 2013 go-dockerclient authors. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package docker package docker
import ( import (
"bytes"
"context" "context"
"encoding/base64" "encoding/base64"
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io" "io"
"net/http" "net/http"
"net/url" "net/url"
"os" "os"
"strings" "strings"
skipping to change at line 92 skipping to change at line 91
ErrMissingRepo = errors.New("missing remote repository e.g. 'github.com/u ser/repo'") ErrMissingRepo = errors.New("missing remote repository e.g. 'github.com/u ser/repo'")
// ErrMissingOutputStream is the error returned when no output stream // ErrMissingOutputStream is the error returned when no output stream
// is provided to some calls, like BuildImage. // is provided to some calls, like BuildImage.
ErrMissingOutputStream = errors.New("missing output stream") ErrMissingOutputStream = errors.New("missing output stream")
// ErrMultipleContexts is the error returned when both a ContextDir and // ErrMultipleContexts is the error returned when both a ContextDir and
// InputStream are provided in BuildImageOptions // InputStream are provided in BuildImageOptions
ErrMultipleContexts = errors.New("image build may not be provided BOTH co ntext dir and input stream") ErrMultipleContexts = errors.New("image build may not be provided BOTH co ntext dir and input stream")
// ErrMustSpecifyNames is the error rreturned when the Names field on // ErrMustSpecifyNames is the error returned when the Names field on
// ExportImagesOptions is nil or empty // ExportImagesOptions is nil or empty
ErrMustSpecifyNames = errors.New("must specify at least one name to expor t") ErrMustSpecifyNames = errors.New("must specify at least one name to expor t")
) )
// ListImagesOptions specify parameters to the ListImages function. // ListImagesOptions specify parameters to the ListImages function.
// //
// See https://goo.gl/BVzauZ for more details. // See https://goo.gl/BVzauZ for more details.
type ListImagesOptions struct { type ListImagesOptions struct {
Filters map[string][]string Filters map[string][]string
All bool All bool
skipping to change at line 292 skipping to change at line 291
}) })
} }
// PullImageOptions present the set of options available for pulling an image // PullImageOptions present the set of options available for pulling an image
// from a registry. // from a registry.
// //
// See https://goo.gl/qkoSsn for more details. // See https://goo.gl/qkoSsn for more details.
type PullImageOptions struct { type PullImageOptions struct {
Repository string `qs:"fromImage"` Repository string `qs:"fromImage"`
Tag string Tag string
Platform string `ver:"1.32"`
// Only required for Docker Engine 1.9 or 1.10 w/ Remote API < 1.21 // Only required for Docker Engine 1.9 or 1.10 w/ Remote API < 1.21
// and Docker Engine < 1.9 // and Docker Engine < 1.9
// This parameter was removed in Docker Engine 1.11 // This parameter was removed in Docker Engine 1.11
Registry string Registry string
OutputStream io.Writer `qs:"-"` OutputStream io.Writer `qs:"-"`
RawJSONStream bool `qs:"-"` RawJSONStream bool `qs:"-"`
InactivityTimeout time.Duration `qs:"-"` InactivityTimeout time.Duration `qs:"-"`
Context context.Context Context context.Context
skipping to change at line 322 skipping to change at line 322
headers, err := headersWithAuth(auth) headers, err := headersWithAuth(auth)
if err != nil { if err != nil {
return err return err
} }
if opts.Tag == "" && strings.Contains(opts.Repository, "@") { if opts.Tag == "" && strings.Contains(opts.Repository, "@") {
parts := strings.SplitN(opts.Repository, "@", 2) parts := strings.SplitN(opts.Repository, "@", 2)
opts.Repository = parts[0] opts.Repository = parts[0]
opts.Tag = parts[1] opts.Tag = parts[1]
} }
return c.createImage(queryString(&opts), headers, nil, opts.OutputStream, opts.RawJSONStream, opts.InactivityTimeout, opts.Context) return c.createImage(&opts, headers, nil, opts.OutputStream, opts.RawJSON Stream, opts.InactivityTimeout, opts.Context)
} }
func (c *Client) createImage(qs string, headers map[string]string, in io.Reader, func (c *Client) createImage(opts interface{}, headers map[string]string, in io.
w io.Writer, rawJSONStream bool, timeout time.Duration, context context.Context Reader, w io.Writer, rawJSONStream bool, timeout time.Duration, context context.
) error { Context) error {
path := "/images/create?" + qs url, err := c.getPath("/images/create", opts)
return c.stream("POST", path, streamOptions{ if err != nil {
return err
}
return c.streamUrl("POST", url, streamOptions{
setRawTerminal: true, setRawTerminal: true,
headers: headers, headers: headers,
in: in, in: in,
stdout: w, stdout: w,
rawJSONStream: rawJSONStream, rawJSONStream: rawJSONStream,
inactivityTimeout: timeout, inactivityTimeout: timeout,
context: context, context: context,
}) })
} }
skipping to change at line 398 skipping to change at line 401
Context context.Context Context context.Context
} }
// ExportImages exports one or more images (as a tar file) into the stream // ExportImages exports one or more images (as a tar file) into the stream
// //
// See https://goo.gl/N9XlDn for more details. // See https://goo.gl/N9XlDn for more details.
func (c *Client) ExportImages(opts ExportImagesOptions) error { func (c *Client) ExportImages(opts ExportImagesOptions) error {
if opts.Names == nil || len(opts.Names) == 0 { if opts.Names == nil || len(opts.Names) == 0 {
return ErrMustSpecifyNames return ErrMustSpecifyNames
} }
return c.stream("GET", "/images/get?"+queryString(&opts), streamOptions{ // API < 1.25 allows multiple name values
// 1.25 says name must be a comma separated list
var err error
var exporturl string
if c.requestedAPIVersion.GreaterThanOrEqualTo(apiVersion125) {
var str string = opts.Names[0]
for _, val := range opts.Names[1:] {
str += "," + val
}
exporturl, err = c.getPath("/images/get", ExportImagesOptions{
Names: []string{str},
OutputStream: opts.OutputStream,
InactivityTimeout: opts.InactivityTimeout,
Context: opts.Context,
})
} else {
exporturl, err = c.getPath("/images/get", &opts)
}
if err != nil {
return err
}
return c.streamUrl("GET", exporturl, streamOptions{
setRawTerminal: true, setRawTerminal: true,
stdout: opts.OutputStream, stdout: opts.OutputStream,
inactivityTimeout: opts.InactivityTimeout, inactivityTimeout: opts.InactivityTimeout,
}) })
} }
// ImportImageOptions present the set of informations available for importing // ImportImageOptions present the set of informations available for importing
// an image from a source file or the stdin. // an image from a source file or the stdin.
// //
// See https://goo.gl/qkoSsn for more details. // See https://goo.gl/qkoSsn for more details.
skipping to change at line 439 skipping to change at line 464
opts.InputStream = nil opts.InputStream = nil
} }
if opts.Source != "-" && !isURL(opts.Source) { if opts.Source != "-" && !isURL(opts.Source) {
f, err := os.Open(opts.Source) f, err := os.Open(opts.Source)
if err != nil { if err != nil {
return err return err
} }
opts.InputStream = f opts.InputStream = f
opts.Source = "-" opts.Source = "-"
} }
return c.createImage(queryString(&opts), nil, opts.InputStream, opts.Outp utStream, opts.RawJSONStream, opts.InactivityTimeout, opts.Context) return c.createImage(&opts, nil, opts.InputStream, opts.OutputStream, opt s.RawJSONStream, opts.InactivityTimeout, opts.Context)
} }
// BuildImageOptions present the set of informations available for building an // BuildImageOptions present the set of informations available for building an
// image from a tarfile with a Dockerfile in it. // image from a tarfile with a Dockerfile in it.
// //
// For more details about the Docker building process, see // For more details about the Docker building process, see
// https://goo.gl/4nYHwV. // https://goo.gl/4nYHwV.
type BuildImageOptions struct { type BuildImageOptions struct {
Context context.Context
Name string `qs:"t"` Name string `qs:"t"`
Dockerfile string `qs:"dockerfile"` Dockerfile string `qs:"dockerfile"`
NoCache bool `qs:"nocache"`
CacheFrom []string `qs:"-"` CacheFrom []string `qs:"-"`
SuppressOutput bool `qs:"q"`
Pull bool `qs:"pull"`
RmTmpContainer bool `qs:"rm"`
ForceRmTmpContainer bool `qs:"forcerm"`
RawJSONStream bool `qs:"-"`
Memory int64 `qs:"memory"` Memory int64 `qs:"memory"`
Memswap int64 `qs:"memswap"` Memswap int64 `qs:"memswap"`
CPUShares int64 `qs:"cpushares"` CPUShares int64 `qs:"cpushares"`
CPUQuota int64 `qs:"cpuquota"` CPUQuota int64 `qs:"cpuquota"`
CPUPeriod int64 `qs:"cpuperiod"` CPUPeriod int64 `qs:"cpuperiod"`
CPUSetCPUs string `qs:"cpusetcpus"` CPUSetCPUs string `qs:"cpusetcpus"`
Labels map[string]string `qs:"labels"` Labels map[string]string `qs:"labels"`
InputStream io.Reader `qs:"-"` InputStream io.Reader `qs:"-"`
OutputStream io.Writer `qs:"-"` OutputStream io.Writer `qs:"-"`
Remote string `qs:"remote"` Remote string `qs:"remote"`
Auth AuthConfiguration `qs:"-"` // for older docker X-Reg istry-Auth header Auth AuthConfiguration `qs:"-"` // for older docker X-Reg istry-Auth header
AuthConfigs AuthConfigurations `qs:"-"` // for newer docker X-Reg istry-Config header AuthConfigs AuthConfigurations `qs:"-"` // for newer docker X-Reg istry-Config header
ContextDir string `qs:"-"` ContextDir string `qs:"-"`
Ulimits []ULimit `qs:"-"` Ulimits []ULimit `qs:"-"`
BuildArgs []BuildArg `qs:"-"` BuildArgs []BuildArg `qs:"-"`
NetworkMode string `qs:"networkmode"` NetworkMode string `qs:"networkmode"`
InactivityTimeout time.Duration `qs:"-"` InactivityTimeout time.Duration `qs:"-"`
CgroupParent string `qs:"cgroupparent"` CgroupParent string `qs:"cgroupparent"`
SecurityOpt []string `qs:"securityopt"` SecurityOpt []string `qs:"securityopt"`
Target string `gs:"target"` Target string `gs:"target"`
Context context.Context NoCache bool `qs:"nocache"`
SuppressOutput bool `qs:"q"`
Pull bool `qs:"pull"`
RmTmpContainer bool `qs:"rm"`
ForceRmTmpContainer bool `qs:"forcerm"`
RawJSONStream bool `qs:"-"`
} }
// BuildArg represents arguments that can be passed to the image when building // BuildArg represents arguments that can be passed to the image when building
// it from a Dockerfile. // it from a Dockerfile.
// //
// For more details about the Docker building process, see // For more details about the Docker building process, see
// https://goo.gl/4nYHwV. // https://goo.gl/4nYHwV.
type BuildArg struct { type BuildArg struct {
Name string `json:"Name,omitempty" yaml:"Name,omitempty" toml:"Name,omit empty"` Name string `json:"Name,omitempty" yaml:"Name,omitempty" toml:"Name,omit empty"`
Value string `json:"Value,omitempty" yaml:"Value,omitempty" toml:"Value,o mitempty"` Value string `json:"Value,omitempty" yaml:"Value,omitempty" toml:"Value,o mitempty"`
skipping to change at line 561 skipping to change at line 586
setRawTerminal: true, setRawTerminal: true,
rawJSONStream: opts.RawJSONStream, rawJSONStream: opts.RawJSONStream,
headers: headers, headers: headers,
in: opts.InputStream, in: opts.InputStream,
stdout: opts.OutputStream, stdout: opts.OutputStream,
inactivityTimeout: opts.InactivityTimeout, inactivityTimeout: opts.InactivityTimeout,
context: opts.Context, context: opts.Context,
}) })
} }
func (c *Client) versionedAuthConfigs(authConfigs AuthConfigurations) interface{ } { func (c *Client) versionedAuthConfigs(authConfigs AuthConfigurations) registryAu th {
if c.serverAPIVersion == nil { if c.serverAPIVersion == nil {
c.checkAPIVersion() c.checkAPIVersion()
} }
if c.serverAPIVersion != nil && c.serverAPIVersion.GreaterThanOrEqualTo(a piVersion119) { if c.serverAPIVersion != nil && c.serverAPIVersion.GreaterThanOrEqualTo(a piVersion119) {
return AuthConfigurations119(authConfigs.Configs) return AuthConfigurations119(authConfigs.Configs)
} }
return authConfigs return authConfigs
} }
// TagImageOptions present the set of options to tag an image. // TagImageOptions present the set of options to tag an image.
skipping to change at line 591 skipping to change at line 616
// TagImage adds a tag to the image identified by the given name. // TagImage adds a tag to the image identified by the given name.
// //
// See https://goo.gl/prHrvo for more details. // See https://goo.gl/prHrvo for more details.
func (c *Client) TagImage(name string, opts TagImageOptions) error { func (c *Client) TagImage(name string, opts TagImageOptions) error {
if name == "" { if name == "" {
return ErrNoSuchImage return ErrNoSuchImage
} }
resp, err := c.do("POST", "/images/"+name+"/tag?"+queryString(&opts), doO ptions{ resp, err := c.do("POST", "/images/"+name+"/tag?"+queryString(&opts), doO ptions{
context: opts.Context, context: opts.Context,
}) })
if err != nil { if err != nil {
return err return err
} }
defer resp.Body.Close() defer resp.Body.Close()
if resp.StatusCode == http.StatusNotFound { if resp.StatusCode == http.StatusNotFound {
return ErrNoSuchImage return ErrNoSuchImage
} }
skipping to change at line 613 skipping to change at line 637
} }
func isURL(u string) bool { func isURL(u string) bool {
p, err := url.Parse(u) p, err := url.Parse(u)
if err != nil { if err != nil {
return false return false
} }
return p.Scheme == "http" || p.Scheme == "https" return p.Scheme == "http" || p.Scheme == "https"
} }
func headersWithAuth(auths ...interface{}) (map[string]string, error) { func headersWithAuth(auths ...registryAuth) (map[string]string, error) {
var headers = make(map[string]string) headers := make(map[string]string)
for _, auth := range auths { for _, auth := range auths {
switch auth.(type) { if auth.isEmpty() {
case AuthConfiguration: continue
var buf bytes.Buffer }
if err := json.NewEncoder(&buf).Encode(auth); err != nil data, err := json.Marshal(auth)
{ if err != nil {
return nil, err return nil, err
}
headers["X-Registry-Auth"] = base64.URLEncoding.EncodeToS
tring(buf.Bytes())
case AuthConfigurations, AuthConfigurations119:
var buf bytes.Buffer
if err := json.NewEncoder(&buf).Encode(auth); err != nil
{
return nil, err
}
headers["X-Registry-Config"] = base64.URLEncoding.EncodeT
oString(buf.Bytes())
} }
headers[auth.headerKey()] = base64.URLEncoding.EncodeToString(dat a)
} }
return headers, nil return headers, nil
} }
// APIImageSearch reflect the result of a search on the Docker Hub. // APIImageSearch reflect the result of a search on the Docker Hub.
// //
// See https://goo.gl/KLO9IZ for more details. // See https://goo.gl/KLO9IZ for more details.
type APIImageSearch struct { type APIImageSearch struct {
Description string `json:"description,omitempty" yaml:"description,omitem pty" toml:"description,omitempty"` Description string `json:"description,omitempty" yaml:"description,omitem pty" toml:"description,omitempty"`
 End of changes. 16 change blocks. 
38 lines changed or deleted 52 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)