Merge pull request #2065 from dongluochen/UpdateEngineApi

Update engine-api
This commit is contained in:
Victor Vieux 2016-03-31 11:02:33 -07:00
commit 7c1dcadb98
4 changed files with 39 additions and 38 deletions

44
Godeps/Godeps.json generated
View File

@ -91,58 +91,58 @@
},
{
"ImportPath": "github.com/docker/engine-api/client",
"Comment": "v0.3.1-11-ge37a82d",
"Rev": "e37a82dfcea64559ca6a581776253c01d83357d9"
"Comment": "v0.3.1-16-g6ca9064",
"Rev": "6ca9064650fd3d66ea1722c24e475ec0138feb11"
},
{
"ImportPath": "github.com/docker/engine-api/client/transport",
"Comment": "v0.3.1-11-ge37a82d",
"Rev": "e37a82dfcea64559ca6a581776253c01d83357d9"
"Comment": "v0.3.1-16-g6ca9064",
"Rev": "6ca9064650fd3d66ea1722c24e475ec0138feb11"
},
{
"ImportPath": "github.com/docker/engine-api/client/transport/cancellable",
"Comment": "v0.3.1-11-ge37a82d",
"Rev": "e37a82dfcea64559ca6a581776253c01d83357d9"
"Comment": "v0.3.1-16-g6ca9064",
"Rev": "6ca9064650fd3d66ea1722c24e475ec0138feb11"
},
{
"ImportPath": "github.com/docker/engine-api/types",
"Comment": "v0.3.1-11-ge37a82d",
"Rev": "e37a82dfcea64559ca6a581776253c01d83357d9"
"Comment": "v0.3.1-16-g6ca9064",
"Rev": "6ca9064650fd3d66ea1722c24e475ec0138feb11"
},
{
"ImportPath": "github.com/docker/engine-api/types/blkiodev",
"Comment": "v0.3.1-11-ge37a82d",
"Rev": "e37a82dfcea64559ca6a581776253c01d83357d9"
"Comment": "v0.3.1-16-g6ca9064",
"Rev": "6ca9064650fd3d66ea1722c24e475ec0138feb11"
},
{
"ImportPath": "github.com/docker/engine-api/types/container",
"Comment": "v0.3.1-11-ge37a82d",
"Rev": "e37a82dfcea64559ca6a581776253c01d83357d9"
"Comment": "v0.3.1-16-g6ca9064",
"Rev": "6ca9064650fd3d66ea1722c24e475ec0138feb11"
},
{
"ImportPath": "github.com/docker/engine-api/types/filters",
"Comment": "v0.3.1-11-ge37a82d",
"Rev": "e37a82dfcea64559ca6a581776253c01d83357d9"
"Comment": "v0.3.1-16-g6ca9064",
"Rev": "6ca9064650fd3d66ea1722c24e475ec0138feb11"
},
{
"ImportPath": "github.com/docker/engine-api/types/network",
"Comment": "v0.3.1-11-ge37a82d",
"Rev": "e37a82dfcea64559ca6a581776253c01d83357d9"
"Comment": "v0.3.1-16-g6ca9064",
"Rev": "6ca9064650fd3d66ea1722c24e475ec0138feb11"
},
{
"ImportPath": "github.com/docker/engine-api/types/registry",
"Comment": "v0.3.1-11-ge37a82d",
"Rev": "e37a82dfcea64559ca6a581776253c01d83357d9"
"Comment": "v0.3.1-16-g6ca9064",
"Rev": "6ca9064650fd3d66ea1722c24e475ec0138feb11"
},
{
"ImportPath": "github.com/docker/engine-api/types/strslice",
"Comment": "v0.3.1-11-ge37a82d",
"Rev": "e37a82dfcea64559ca6a581776253c01d83357d9"
"Comment": "v0.3.1-16-g6ca9064",
"Rev": "6ca9064650fd3d66ea1722c24e475ec0138feb11"
},
{
"ImportPath": "github.com/docker/engine-api/types/time",
"Comment": "v0.3.1-11-ge37a82d",
"Rev": "e37a82dfcea64559ca6a581776253c01d83357d9"
"Comment": "v0.3.1-16-g6ca9064",
"Rev": "6ca9064650fd3d66ea1722c24e475ec0138feb11"
},
{
"ImportPath": "github.com/docker/go-connections/nat",

View File

@ -8,7 +8,7 @@ import (
"github.com/docker/engine-api/types"
)
// ContainerWait pauses execution util a container exits.
// ContainerWait pauses execution until a container exits.
// It returns the API status code as response of its readiness.
func (cli *Client) ContainerWait(ctx context.Context, containerID string) (int, error) {
resp, err := cli.post(ctx, "/containers/"+containerID+"/wait", nil, nil, nil)

View File

@ -46,8 +46,7 @@ func (cli *Client) postHijacked(ctx context.Context, path string, query url.Valu
req.Header.Set("Connection", "Upgrade")
req.Header.Set("Upgrade", "tcp")
tlsConfig := cli.transport.TLSConfig()
conn, err := dial(cli.proto, cli.addr, tlsConfig)
conn, err := dial(cli.proto, cli.addr, cli.transport.TLSConfig())
if err != nil {
if strings.Contains(err.Error(), "connection refused") {
return types.HijackedResponse{}, fmt.Errorf("Cannot connect to the Docker daemon. Is 'docker daemon' running on this host?")
@ -126,6 +125,21 @@ func tlsDialWithDialer(dialer *net.Dialer, network, addr string, config *tls.Con
tcpConn.SetKeepAlivePeriod(30 * time.Second)
}
colonPos := strings.LastIndex(addr, ":")
if colonPos == -1 {
colonPos = len(addr)
}
hostname := addr[:colonPos]
// If no ServerName is set, infer the ServerName
// from the hostname we're connecting to.
if config.ServerName == "" {
// Make a copy to avoid polluting argument or default.
c := *config
c.ServerName = hostname
config = &c
}
conn := tls.Client(rawConn, config)
if timeout == 0 {

View File

@ -4,7 +4,6 @@ package transport
import (
"fmt"
"net/http"
"strings"
"github.com/docker/go-connections/sockets"
)
@ -35,10 +34,6 @@ func NewTransportWithHTTP(proto, addr string, client *http.Client) (Client, erro
}
}
if transport.TLSClientConfig != nil && transport.TLSClientConfig.ServerName == "" {
transport.TLSClientConfig.ServerName = hostname(addr)
}
return &apiTransport{
Client: client,
tlsInfo: &tlsInfo{transport.TLSClientConfig},
@ -59,12 +54,4 @@ func defaultTransport(proto, addr string) *http.Transport {
return tr
}
func hostname(addr string) string {
colonPos := strings.LastIndex(addr, ":")
if colonPos == -1 {
return addr
}
return addr[:colonPos]
}
var _ Client = &apiTransport{}