Alpine base image and some dependencies upgraded
Details in the reweave CHANGELOG
This commit is contained in:
1 parent
1ceeca80e6
commit
0d58e17954
368 files changed
+23406
-9163
No files matched your search
+121
-71
@@ -5,7 +5,7 @@
|
||||
package docker
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
@@ -16,8 +16,6 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// APIImages represent an image returned in the ListImages call.
|
||||
@@ -90,7 +88,7 @@ var (
|
||||
// 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
|
||||
// ErrMustSpecifyNames is the error returned when the Names field on
|
||||
// ExportImagesOptions is nil or empty
|
||||
ErrMustSpecifyNames = errors.New("must specify at least one name to export")
|
||||
)
|
||||
@@ -111,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
|
||||
}
|
||||
@@ -131,15 +129,17 @@ 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 {
|
||||
var e *Error
|
||||
if errors.As(err, &e) && e.Status == http.StatusNotFound {
|
||||
return nil, ErrNoSuchImage
|
||||
}
|
||||
return nil, err
|
||||
@@ -156,9 +156,10 @@ 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 {
|
||||
var e *Error
|
||||
if errors.As(err, &e) && e.Status == http.StatusNotFound {
|
||||
return ErrNoSuchImage
|
||||
}
|
||||
return err
|
||||
@@ -183,9 +184,10 @@ 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 {
|
||||
var e *Error
|
||||
if errors.As(err, &e) && e.Status == http.StatusNotFound {
|
||||
return ErrNoSuchImage
|
||||
}
|
||||
return err
|
||||
@@ -198,9 +200,10 @@ 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 {
|
||||
var e *Error
|
||||
if errors.As(err, &e) && e.Status == http.StatusNotFound {
|
||||
return nil, ErrNoSuchImage
|
||||
}
|
||||
return nil, err
|
||||
@@ -273,7 +276,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,
|
||||
@@ -288,8 +291,10 @@ func (c *Client) PushImage(opts PushImageOptions, auth AuthConfiguration) error
|
||||
//
|
||||
// See https://goo.gl/qkoSsn for more details.
|
||||
type PullImageOptions struct {
|
||||
All bool
|
||||
Repository string `qs:"fromImage"`
|
||||
Tag string
|
||||
Platform string `ver:"1.32"`
|
||||
|
||||
// Only required for Docker Engine 1.9 or 1.10 w/ Remote API < 1.21
|
||||
// and Docker Engine < 1.9
|
||||
@@ -320,12 +325,15 @@ func (c *Client) PullImage(opts PullImageOptions, auth AuthConfiguration) error
|
||||
opts.Repository = parts[0]
|
||||
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.RawJSONStream, opts.InactivityTimeout, opts.Context)
|
||||
}
|
||||
|
||||
func (c *Client) createImage(qs string, headers map[string]string, in io.Reader, w io.Writer, rawJSONStream bool, timeout time.Duration, context context.Context) error {
|
||||
path := "/images/create?" + qs
|
||||
return c.stream("POST", path, streamOptions{
|
||||
func (c *Client) createImage(opts any, 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(http.MethodPost, url, streamOptions{
|
||||
setRawTerminal: true,
|
||||
headers: headers,
|
||||
in: in,
|
||||
@@ -349,7 +357,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,
|
||||
@@ -371,7 +379,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,
|
||||
@@ -396,7 +404,28 @@ 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{
|
||||
// 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) {
|
||||
str := 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(http.MethodGet, exporturl, streamOptions{
|
||||
setRawTerminal: true,
|
||||
stdout: opts.OutputStream,
|
||||
inactivityTimeout: opts.InactivityTimeout,
|
||||
@@ -437,44 +466,58 @@ func (c *Client) ImportImage(opts ImportImageOptions) error {
|
||||
opts.InputStream = f
|
||||
opts.Source = "-"
|
||||
}
|
||||
return c.createImage(queryString(&opts), nil, opts.InputStream, opts.OutputStream, opts.RawJSONStream, opts.InactivityTimeout, opts.Context)
|
||||
return c.createImage(&opts, nil, opts.InputStream, opts.OutputStream, opts.RawJSONStream, opts.InactivityTimeout, opts.Context)
|
||||
}
|
||||
|
||||
// BuilderVersion represents either the BuildKit or V1 ("classic") builder.
|
||||
type BuilderVersion string
|
||||
|
||||
const (
|
||||
BuilderV1 BuilderVersion = "1"
|
||||
BuilderBuildKit BuilderVersion = "2"
|
||||
)
|
||||
|
||||
// BuildImageOptions present the set of informations available for building an
|
||||
// image from a tarfile with a Dockerfile in it.
|
||||
//
|
||||
// For more details about the Docker building process, see
|
||||
// https://goo.gl/4nYHwV.
|
||||
type BuildImageOptions struct {
|
||||
Name string `qs:"t"`
|
||||
Dockerfile string `qs:"dockerfile"`
|
||||
NoCache bool `qs:"nocache"`
|
||||
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"`
|
||||
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"`
|
||||
Context context.Context
|
||||
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"`
|
||||
Context context.Context
|
||||
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:"-"`
|
||||
Version BuilderVersion `qs:"version" ver:"1.39"`
|
||||
}
|
||||
|
||||
// BuildArg represents arguments that can be passed to the image when building
|
||||
@@ -517,13 +560,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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -532,6 +578,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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -544,10 +593,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,
|
||||
@@ -558,7 +615,7 @@ func (c *Client) BuildImage(opts BuildImageOptions) error {
|
||||
})
|
||||
}
|
||||
|
||||
func (c *Client) versionedAuthConfigs(authConfigs AuthConfigurations) interface{} {
|
||||
func (c *Client) versionedAuthConfigs(authConfigs AuthConfigurations) registryAuth {
|
||||
if c.serverAPIVersion == nil {
|
||||
c.checkAPIVersion()
|
||||
}
|
||||
@@ -585,10 +642,9 @@ 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 {
|
||||
return err
|
||||
}
|
||||
@@ -610,24 +666,18 @@ func isURL(u string) bool {
|
||||
return p.Scheme == "http" || p.Scheme == "https"
|
||||
}
|
||||
|
||||
func headersWithAuth(auths ...interface{}) (map[string]string, error) {
|
||||
var headers = make(map[string]string)
|
||||
func headersWithAuth(auths ...registryAuth) (map[string]string, error) {
|
||||
headers := make(map[string]string)
|
||||
|
||||
for _, auth := range auths {
|
||||
switch auth.(type) {
|
||||
case AuthConfiguration:
|
||||
var buf bytes.Buffer
|
||||
if err := json.NewEncoder(&buf).Encode(auth); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
headers["X-Registry-Auth"] = base64.URLEncoding.EncodeToString(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.EncodeToString(buf.Bytes())
|
||||
if auth.isEmpty() {
|
||||
continue
|
||||
}
|
||||
data, err := json.Marshal(auth)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
headers[auth.headerKey()] = base64.URLEncoding.EncodeToString(data)
|
||||
}
|
||||
|
||||
return headers, nil
|
||||
@@ -648,7 +698,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
|
||||
}
|
||||
@@ -669,7 +719,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 {
|
||||
@@ -707,7 +757,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
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user