Skip to content

Commit

Permalink
Merge pull request #31164 from vieux/missing_api_changes
Browse files Browse the repository at this point in the history
add missing API changes
  • Loading branch information
vieux committed Feb 20, 2017
2 parents 75843d3 + a7e6d2c commit f100851
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 17 deletions.
4 changes: 2 additions & 2 deletions api/server/router/container/container_routes.go
Expand Up @@ -520,9 +520,9 @@ func (s *containerRouter) wsContainersAttach(ctx context.Context, w http.Respons
}()

conn := <-wsChan
// In case version is higher than 1.26, a binary frame will be sent.
// In case version is higher than 1.27, a binary frame will be sent.
// See 28176 for details.
if versions.GreaterThanOrEqualTo(version, "1.26") {
if versions.GreaterThanOrEqualTo(version, "1.27") {
conn.PayloadType = websocket.BinaryFrame
}
return conn, conn, conn, nil
Expand Down
6 changes: 3 additions & 3 deletions api/server/router/network/network_routes.go
Expand Up @@ -60,11 +60,11 @@ SKIP:
}

var nr *types.NetworkResource
// Versions < 1.26 fetches all the containers attached to a network
// Versions < 1.27 fetches all the containers attached to a network
// in a network list api call. It is a heavy weight operation when
// run across all the networks. Starting API version 1.26, this detailed
// run across all the networks. Starting API version 1.27, this detailed
// info is available for network specific GET API (equivalent to inspect)
if versions.LessThan(httputils.VersionFromContext(ctx), "1.26") {
if versions.LessThan(httputils.VersionFromContext(ctx), "1.27") {
nr = n.buildDetailedNetworkResources(nw)
} else {
nr = n.buildNetworkResource(nw)
Expand Down
2 changes: 1 addition & 1 deletion cli/command/service/opts.go
Expand Up @@ -469,7 +469,7 @@ func addServiceFlags(cmd *cobra.Command, opts *serviceOptions) {
flags.SetAnnotation(flagTTY, "version", []string{"1.25"})

flags.BoolVar(&opts.readOnly, flagReadOnly, false, "Mount the container's root filesystem as read only")
flags.SetAnnotation(flagReadOnly, "version", []string{"1.26"})
flags.SetAnnotation(flagReadOnly, "version", []string{"1.27"})
}

const (
Expand Down
6 changes: 2 additions & 4 deletions client/client.go
Expand Up @@ -53,13 +53,11 @@ import (
"path/filepath"
"strings"

"github.com/docker/docker/api"
"github.com/docker/go-connections/sockets"
"github.com/docker/go-connections/tlsconfig"
)

// DefaultVersion is the version of the current stable API
const DefaultVersion string = "1.26"

// Client is the API client that performs all operations
// against a docker server.
type Client struct {
Expand Down Expand Up @@ -115,7 +113,7 @@ func NewEnvClient() (*Client, error) {
}
version := os.Getenv("DOCKER_API_VERSION")
if version == "" {
version = DefaultVersion
version = api.DefaultVersion
}

cli, err := NewClient(host, version, client, nil)
Expand Down
15 changes: 8 additions & 7 deletions client/client_test.go
Expand Up @@ -11,6 +11,7 @@ import (
"strings"
"testing"

"github.com/docker/docker/api"
"github.com/docker/docker/api/types"
"golang.org/x/net/context"
)
Expand All @@ -26,7 +27,7 @@ func TestNewEnvClient(t *testing.T) {
}{
{
envs: map[string]string{},
expectedVersion: DefaultVersion,
expectedVersion: api.DefaultVersion,
},
{
envs: map[string]string{
Expand All @@ -38,21 +39,21 @@ func TestNewEnvClient(t *testing.T) {
envs: map[string]string{
"DOCKER_CERT_PATH": "testdata/",
},
expectedVersion: DefaultVersion,
expectedVersion: api.DefaultVersion,
},
{
envs: map[string]string{
"DOCKER_CERT_PATH": "testdata/",
"DOCKER_TLS_VERIFY": "1",
},
expectedVersion: DefaultVersion,
expectedVersion: api.DefaultVersion,
},
{
envs: map[string]string{
"DOCKER_CERT_PATH": "testdata/",
"DOCKER_HOST": "https://notaunixsocket",
},
expectedVersion: DefaultVersion,
expectedVersion: api.DefaultVersion,
},
{
envs: map[string]string{
Expand All @@ -64,7 +65,7 @@ func TestNewEnvClient(t *testing.T) {
envs: map[string]string{
"DOCKER_HOST": "invalid://url",
},
expectedVersion: DefaultVersion,
expectedVersion: api.DefaultVersion,
},
{
envs: map[string]string{
Expand Down Expand Up @@ -262,8 +263,8 @@ func TestNewEnvClientSetsDefaultVersion(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if client.version != DefaultVersion {
t.Fatalf("Expected %s, got %s", DefaultVersion, client.version)
if client.version != api.DefaultVersion {
t.Fatalf("Expected %s, got %s", api.DefaultVersion, client.version)
}

expected := "1.22"
Expand Down

0 comments on commit f100851

Please sign in to comment.