Jelajahi Sumber

Vendor engine-api to allow docker daemon reload event.

This fix updated the vendored engine-api to version
e374c4fb5b121a8fd4295ec5eb91a8068c6304f4, which defines a new event
type of `DaemonEventType`. The purpose is to allow emitting`
`daemon reload` event as is raised in #22463.

This fix is related to #22463 and #22590.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Yong Tang 9 tahun lalu
induk
melakukan
0f57f47ac3

+ 1 - 1
hack/vendor.sh

@@ -24,7 +24,7 @@ clone git golang.org/x/net 78cb2c067747f08b343f20614155233ab4ea2ad3 https://gith
 clone git golang.org/x/sys eb2c74142fd19a79b3f237334c7384d5167b1b46 https://github.com/golang/sys.git
 clone git golang.org/x/sys eb2c74142fd19a79b3f237334c7384d5167b1b46 https://github.com/golang/sys.git
 clone git github.com/docker/go-units 651fc226e7441360384da338d0fd37f2440ffbe3
 clone git github.com/docker/go-units 651fc226e7441360384da338d0fd37f2440ffbe3
 clone git github.com/docker/go-connections v0.2.0
 clone git github.com/docker/go-connections v0.2.0
-clone git github.com/docker/engine-api 1fb8f09960cc32b9648495a422c960fb2a4f8a09
+clone git github.com/docker/engine-api e374c4fb5b121a8fd4295ec5eb91a8068c6304f4
 clone git github.com/RackSec/srslog 259aed10dfa74ea2961eddd1d9847619f6e98837
 clone git github.com/RackSec/srslog 259aed10dfa74ea2961eddd1d9847619f6e98837
 clone git github.com/imdario/mergo 0.2.1
 clone git github.com/imdario/mergo 0.2.1
 
 

+ 0 - 16
vendor/src/github.com/docker/engine-api/client/image_build.go

@@ -8,7 +8,6 @@ import (
 	"net/url"
 	"net/url"
 	"regexp"
 	"regexp"
 	"strconv"
 	"strconv"
-	"strings"
 
 
 	"golang.org/x/net/context"
 	"golang.org/x/net/context"
 
 
@@ -118,18 +117,3 @@ func getDockerOS(serverHeader string) string {
 	}
 	}
 	return osType
 	return osType
 }
 }
-
-// convertKVStringsToMap converts ["key=value"] to {"key":"value"}
-func convertKVStringsToMap(values []string) map[string]string {
-	result := make(map[string]string, len(values))
-	for _, value := range values {
-		kv := strings.SplitN(value, "=", 2)
-		if len(kv) == 1 {
-			result[kv[0]] = ""
-		} else {
-			result[kv[0]] = kv[1]
-		}
-	}
-
-	return result
-}

+ 1 - 1
vendor/src/github.com/docker/engine-api/client/image_pull.go

@@ -32,7 +32,7 @@ func (cli *Client) ImagePull(ctx context.Context, ref string, options types.Imag
 	}
 	}
 
 
 	resp, err := cli.tryImageCreate(ctx, query, options.RegistryAuth)
 	resp, err := cli.tryImageCreate(ctx, query, options.RegistryAuth)
-	if resp.statusCode == http.StatusUnauthorized {
+	if resp.statusCode == http.StatusUnauthorized && options.PrivilegeFunc != nil {
 		newAuthHeader, privilegeErr := options.PrivilegeFunc()
 		newAuthHeader, privilegeErr := options.PrivilegeFunc()
 		if privilegeErr != nil {
 		if privilegeErr != nil {
 			return nil, privilegeErr
 			return nil, privilegeErr

+ 1 - 1
vendor/src/github.com/docker/engine-api/client/image_push.go

@@ -35,7 +35,7 @@ func (cli *Client) ImagePush(ctx context.Context, ref string, options types.Imag
 	query.Set("tag", tag)
 	query.Set("tag", tag)
 
 
 	resp, err := cli.tryImagePush(ctx, distributionRef.Name(), query, options.RegistryAuth)
 	resp, err := cli.tryImagePush(ctx, distributionRef.Name(), query, options.RegistryAuth)
-	if resp.statusCode == http.StatusUnauthorized {
+	if resp.statusCode == http.StatusUnauthorized && options.PrivilegeFunc != nil {
 		newAuthHeader, privilegeErr := options.PrivilegeFunc()
 		newAuthHeader, privilegeErr := options.PrivilegeFunc()
 		if privilegeErr != nil {
 		if privilegeErr != nil {
 			return nil, privilegeErr
 			return nil, privilegeErr

+ 1 - 1
vendor/src/github.com/docker/engine-api/client/image_search.go

@@ -27,7 +27,7 @@ func (cli *Client) ImageSearch(ctx context.Context, term string, options types.I
 	}
 	}
 
 
 	resp, err := cli.tryImageSearch(ctx, query, options.RegistryAuth)
 	resp, err := cli.tryImageSearch(ctx, query, options.RegistryAuth)
-	if resp.statusCode == http.StatusUnauthorized {
+	if resp.statusCode == http.StatusUnauthorized && options.PrivilegeFunc != nil {
 		newAuthHeader, privilegeErr := options.PrivilegeFunc()
 		newAuthHeader, privilegeErr := options.PrivilegeFunc()
 		if privilegeErr != nil {
 		if privilegeErr != nil {
 			return results, privilegeErr
 			return results, privilegeErr

+ 9 - 4
vendor/src/github.com/docker/engine-api/client/request.go

@@ -85,6 +85,10 @@ func (cli *Client) sendClientRequest(ctx context.Context, method, path string, q
 	}
 	}
 
 
 	req, err := cli.newRequest(method, path, query, body, headers)
 	req, err := cli.newRequest(method, path, query, body, headers)
+	if err != nil {
+		return serverResp, err
+	}
+
 	if cli.proto == "unix" || cli.proto == "npipe" {
 	if cli.proto == "unix" || cli.proto == "npipe" {
 		// For local communications, it doesn't matter what the host is. We just
 		// For local communications, it doesn't matter what the host is. We just
 		// need a valid and meaningful host name. (See #189)
 		// need a valid and meaningful host name. (See #189)
@@ -98,10 +102,6 @@ func (cli *Client) sendClientRequest(ctx context.Context, method, path string, q
 	}
 	}
 
 
 	resp, err := cancellable.Do(ctx, cli.transport, req)
 	resp, err := cancellable.Do(ctx, cli.transport, req)
-	if resp != nil {
-		serverResp.statusCode = resp.StatusCode
-	}
-
 	if err != nil {
 	if err != nil {
 		if isTimeout(err) || strings.Contains(err.Error(), "connection refused") || strings.Contains(err.Error(), "dial unix") {
 		if isTimeout(err) || strings.Contains(err.Error(), "connection refused") || strings.Contains(err.Error(), "dial unix") {
 			return serverResp, ErrConnectionFailed
 			return serverResp, ErrConnectionFailed
@@ -110,6 +110,7 @@ func (cli *Client) sendClientRequest(ctx context.Context, method, path string, q
 		if !cli.transport.Secure() && strings.Contains(err.Error(), "malformed HTTP response") {
 		if !cli.transport.Secure() && strings.Contains(err.Error(), "malformed HTTP response") {
 			return serverResp, fmt.Errorf("%v.\n* Are you trying to connect to a TLS-enabled daemon without TLS?", err)
 			return serverResp, fmt.Errorf("%v.\n* Are you trying to connect to a TLS-enabled daemon without TLS?", err)
 		}
 		}
+
 		if cli.transport.Secure() && strings.Contains(err.Error(), "remote error: bad certificate") {
 		if cli.transport.Secure() && strings.Contains(err.Error(), "remote error: bad certificate") {
 			return serverResp, fmt.Errorf("The server probably has client authentication (--tlsverify) enabled. Please check your TLS client certification settings: %v", err)
 			return serverResp, fmt.Errorf("The server probably has client authentication (--tlsverify) enabled. Please check your TLS client certification settings: %v", err)
 		}
 		}
@@ -117,6 +118,10 @@ func (cli *Client) sendClientRequest(ctx context.Context, method, path string, q
 		return serverResp, fmt.Errorf("An error occurred trying to connect: %v", err)
 		return serverResp, fmt.Errorf("An error occurred trying to connect: %v", err)
 	}
 	}
 
 
+	if resp != nil {
+		serverResp.statusCode = resp.StatusCode
+	}
+
 	if serverResp.statusCode < 200 || serverResp.statusCode >= 400 {
 	if serverResp.statusCode < 200 || serverResp.statusCode >= 400 {
 		body, err := ioutil.ReadAll(resp.Body)
 		body, err := ioutil.ReadAll(resp.Body)
 		if err != nil {
 		if err != nil {

+ 1 - 1
vendor/src/github.com/docker/engine-api/types/container/host_config.go

@@ -195,7 +195,7 @@ type RestartPolicy struct {
 // IsNone indicates whether the container has the "no" restart policy.
 // IsNone indicates whether the container has the "no" restart policy.
 // This means the container will not automatically restart when exiting.
 // This means the container will not automatically restart when exiting.
 func (rp *RestartPolicy) IsNone() bool {
 func (rp *RestartPolicy) IsNone() bool {
-	return rp.Name == "no"
+	return rp.Name == "no" || rp.Name == ""
 }
 }
 
 
 // IsAlways indicates whether the container has the "always" restart policy.
 // IsAlways indicates whether the container has the "always" restart policy.

+ 2 - 0
vendor/src/github.com/docker/engine-api/types/events/events.go

@@ -9,6 +9,8 @@ const (
 	VolumeEventType = "volume"
 	VolumeEventType = "volume"
 	// NetworkEventType is the event type that networks generate
 	// NetworkEventType is the event type that networks generate
 	NetworkEventType = "network"
 	NetworkEventType = "network"
+	// DaemonEventType is the event type that daemon generate
+	DaemonEventType = "daemon"
 )
 )
 
 
 // Actor describes something that generates events,
 // Actor describes something that generates events,