Browse Source

Merge pull request #22153 from vdemeester/update-engine-api-again

Update engine api again for CopyToContainer and versions
Alexander Morozov 9 years ago
parent
commit
eab65e438e

+ 1 - 1
api/client/cli.go

@@ -142,7 +142,7 @@ func NewDockerCli(in io.ReadCloser, out, err io.Writer, clientFlags *cli.ClientF
 		}
 		}
 		customHeaders["User-Agent"] = clientUserAgent()
 		customHeaders["User-Agent"] = clientUserAgent()
 
 
-		verStr := api.DefaultVersion.String()
+		verStr := api.DefaultVersion
 		if tmpStr := os.Getenv("DOCKER_API_VERSION"); tmpStr != "" {
 		if tmpStr := os.Getenv("DOCKER_API_VERSION"); tmpStr != "" {
 			verStr = tmpStr
 			verStr = tmpStr
 		}
 		}

+ 1 - 4
api/client/cp.go

@@ -288,11 +288,8 @@ func (cli *DockerCli) copyToContainer(srcPath, dstContainer, dstPath string, cpP
 	}
 	}
 
 
 	options := types.CopyToContainerOptions{
 	options := types.CopyToContainerOptions{
-		ContainerID:               dstContainer,
-		Path:                      resolvedDstPath,
-		Content:                   content,
 		AllowOverwriteDirWithFile: false,
 		AllowOverwriteDirWithFile: false,
 	}
 	}
 
 
-	return cli.client.CopyToContainer(context.Background(), options)
+	return cli.client.CopyToContainer(context.Background(), dstContainer, resolvedDstPath, content, options)
 }
 }

+ 2 - 3
api/common.go

@@ -10,7 +10,6 @@ import (
 
 
 	"github.com/Sirupsen/logrus"
 	"github.com/Sirupsen/logrus"
 	"github.com/docker/docker/pkg/system"
 	"github.com/docker/docker/pkg/system"
-	"github.com/docker/docker/pkg/version"
 	"github.com/docker/engine-api/types"
 	"github.com/docker/engine-api/types"
 	"github.com/docker/libtrust"
 	"github.com/docker/libtrust"
 )
 )
@@ -18,10 +17,10 @@ import (
 // Common constants for daemon and client.
 // Common constants for daemon and client.
 const (
 const (
 	// Version of Current REST API
 	// Version of Current REST API
-	DefaultVersion version.Version = "1.24"
+	DefaultVersion string = "1.24"
 
 
 	// MinVersion represents Minimum REST API version supported
 	// MinVersion represents Minimum REST API version supported
-	MinVersion version.Version = "1.12"
+	MinVersion string = "1.12"
 
 
 	// NoBaseImageSpecifier is the symbol used by the FROM
 	// NoBaseImageSpecifier is the symbol used by the FROM
 	// command to specify that no base image is to be used.
 	// command to specify that no base image is to be used.

+ 2 - 3
api/server/httputils/httputils.go

@@ -10,7 +10,6 @@ import (
 	"golang.org/x/net/context"
 	"golang.org/x/net/context"
 
 
 	"github.com/docker/docker/api"
 	"github.com/docker/docker/api"
-	"github.com/docker/docker/pkg/version"
 )
 )
 
 
 // APIVersionKey is the client's requested API version.
 // APIVersionKey is the client's requested API version.
@@ -95,7 +94,7 @@ func WriteJSON(w http.ResponseWriter, code int, v interface{}) error {
 
 
 // VersionFromContext returns an API version from the context using APIVersionKey.
 // VersionFromContext returns an API version from the context using APIVersionKey.
 // It panics if the context value does not have version.Version type.
 // It panics if the context value does not have version.Version type.
-func VersionFromContext(ctx context.Context) (ver version.Version) {
+func VersionFromContext(ctx context.Context) (ver string) {
 	if ctx == nil {
 	if ctx == nil {
 		return
 		return
 	}
 	}
@@ -103,5 +102,5 @@ func VersionFromContext(ctx context.Context) (ver version.Version) {
 	if val == nil {
 	if val == nil {
 		return
 		return
 	}
 	}
-	return val.(version.Version)
+	return val.(string)
 }
 }

+ 4 - 4
api/server/middleware/user_agent.go

@@ -6,19 +6,19 @@ import (
 
 
 	"github.com/Sirupsen/logrus"
 	"github.com/Sirupsen/logrus"
 	"github.com/docker/docker/api/server/httputils"
 	"github.com/docker/docker/api/server/httputils"
-	"github.com/docker/docker/pkg/version"
+	"github.com/docker/engine-api/types/versions"
 	"golang.org/x/net/context"
 	"golang.org/x/net/context"
 )
 )
 
 
 // UserAgentMiddleware is a middleware that
 // UserAgentMiddleware is a middleware that
 // validates the client user-agent.
 // validates the client user-agent.
 type UserAgentMiddleware struct {
 type UserAgentMiddleware struct {
-	serverVersion version.Version
+	serverVersion string
 }
 }
 
 
 // NewUserAgentMiddleware creates a new UserAgentMiddleware
 // NewUserAgentMiddleware creates a new UserAgentMiddleware
 // with the server version.
 // with the server version.
-func NewUserAgentMiddleware(s version.Version) UserAgentMiddleware {
+func NewUserAgentMiddleware(s string) UserAgentMiddleware {
 	return UserAgentMiddleware{
 	return UserAgentMiddleware{
 		serverVersion: s,
 		serverVersion: s,
 	}
 	}
@@ -38,7 +38,7 @@ func (u UserAgentMiddleware) WrapHandler(handler func(ctx context.Context, w htt
 				userAgent[1] = strings.Split(userAgent[1], " ")[0]
 				userAgent[1] = strings.Split(userAgent[1], " ")[0]
 			}
 			}
 
 
-			if len(userAgent) == 2 && !u.serverVersion.Equal(version.Version(userAgent[1])) {
+			if len(userAgent) == 2 && !versions.Equal(u.serverVersion, userAgent[1]) {
 				logrus.Debugf("Client and server don't have the same version (client: %s, server: %s)", userAgent[1], u.serverVersion)
 				logrus.Debugf("Client and server don't have the same version (client: %s, server: %s)", userAgent[1], u.serverVersion)
 			}
 			}
 		}
 		}

+ 8 - 8
api/server/middleware/version.go

@@ -5,7 +5,7 @@ import (
 	"net/http"
 	"net/http"
 	"runtime"
 	"runtime"
 
 
-	"github.com/docker/docker/pkg/version"
+	"github.com/docker/engine-api/types/versions"
 	"golang.org/x/net/context"
 	"golang.org/x/net/context"
 )
 )
 
 
@@ -20,14 +20,14 @@ func (badRequestError) HTTPErrorStatusCode() int {
 // VersionMiddleware is a middleware that
 // VersionMiddleware is a middleware that
 // validates the client and server versions.
 // validates the client and server versions.
 type VersionMiddleware struct {
 type VersionMiddleware struct {
-	serverVersion  version.Version
-	defaultVersion version.Version
-	minVersion     version.Version
+	serverVersion  string
+	defaultVersion string
+	minVersion     string
 }
 }
 
 
 // NewVersionMiddleware creates a new VersionMiddleware
 // NewVersionMiddleware creates a new VersionMiddleware
 // with the default versions.
 // with the default versions.
-func NewVersionMiddleware(s, d, m version.Version) VersionMiddleware {
+func NewVersionMiddleware(s, d, m string) VersionMiddleware {
 	return VersionMiddleware{
 	return VersionMiddleware{
 		serverVersion:  s,
 		serverVersion:  s,
 		defaultVersion: d,
 		defaultVersion: d,
@@ -38,15 +38,15 @@ func NewVersionMiddleware(s, d, m version.Version) VersionMiddleware {
 // WrapHandler returns a new handler function wrapping the previous one in the request chain.
 // WrapHandler returns a new handler function wrapping the previous one in the request chain.
 func (v VersionMiddleware) WrapHandler(handler func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error) func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
 func (v VersionMiddleware) WrapHandler(handler func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error) func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
 	return func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
 	return func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
-		apiVersion := version.Version(vars["version"])
+		apiVersion := vars["version"]
 		if apiVersion == "" {
 		if apiVersion == "" {
 			apiVersion = v.defaultVersion
 			apiVersion = v.defaultVersion
 		}
 		}
 
 
-		if apiVersion.GreaterThan(v.defaultVersion) {
+		if versions.GreaterThan(apiVersion, v.defaultVersion) {
 			return badRequestError{fmt.Errorf("client is newer than server (client API version: %s, server API version: %s)", apiVersion, v.defaultVersion)}
 			return badRequestError{fmt.Errorf("client is newer than server (client API version: %s, server API version: %s)", apiVersion, v.defaultVersion)}
 		}
 		}
-		if apiVersion.LessThan(v.minVersion) {
+		if versions.LessThan(apiVersion, v.minVersion) {
 			return badRequestError{fmt.Errorf("client version %s is too old. Minimum supported API version is %s, please upgrade your client to a newer version", apiVersion, v.minVersion)}
 			return badRequestError{fmt.Errorf("client version %s is too old. Minimum supported API version is %s, please upgrade your client to a newer version", apiVersion, v.minVersion)}
 		}
 		}
 
 

+ 4 - 5
api/server/middleware/version_test.go

@@ -7,7 +7,6 @@ import (
 	"testing"
 	"testing"
 
 
 	"github.com/docker/docker/api/server/httputils"
 	"github.com/docker/docker/api/server/httputils"
-	"github.com/docker/docker/pkg/version"
 	"golang.org/x/net/context"
 	"golang.org/x/net/context"
 )
 )
 
 
@@ -19,8 +18,8 @@ func TestVersionMiddleware(t *testing.T) {
 		return nil
 		return nil
 	}
 	}
 
 
-	defaultVersion := version.Version("1.10.0")
-	minVersion := version.Version("1.2.0")
+	defaultVersion := "1.10.0"
+	minVersion := "1.2.0"
 	m := NewVersionMiddleware(defaultVersion, defaultVersion, minVersion)
 	m := NewVersionMiddleware(defaultVersion, defaultVersion, minVersion)
 	h := m.WrapHandler(handler)
 	h := m.WrapHandler(handler)
 
 
@@ -40,8 +39,8 @@ func TestVersionMiddlewareWithErrors(t *testing.T) {
 		return nil
 		return nil
 	}
 	}
 
 
-	defaultVersion := version.Version("1.10.0")
-	minVersion := version.Version("1.2.0")
+	defaultVersion := "1.10.0"
+	minVersion := "1.2.0"
 	m := NewVersionMiddleware(defaultVersion, defaultVersion, minVersion)
 	m := NewVersionMiddleware(defaultVersion, defaultVersion, minVersion)
 	h := m.WrapHandler(handler)
 	h := m.WrapHandler(handler)
 
 

+ 4 - 3
api/server/router/build/build_routes.go

@@ -19,6 +19,7 @@ import (
 	"github.com/docker/docker/pkg/streamformatter"
 	"github.com/docker/docker/pkg/streamformatter"
 	"github.com/docker/engine-api/types"
 	"github.com/docker/engine-api/types"
 	"github.com/docker/engine-api/types/container"
 	"github.com/docker/engine-api/types/container"
+	"github.com/docker/engine-api/types/versions"
 	"github.com/docker/go-units"
 	"github.com/docker/go-units"
 	"golang.org/x/net/context"
 	"golang.org/x/net/context"
 )
 )
@@ -26,14 +27,14 @@ import (
 func newImageBuildOptions(ctx context.Context, r *http.Request) (*types.ImageBuildOptions, error) {
 func newImageBuildOptions(ctx context.Context, r *http.Request) (*types.ImageBuildOptions, error) {
 	version := httputils.VersionFromContext(ctx)
 	version := httputils.VersionFromContext(ctx)
 	options := &types.ImageBuildOptions{}
 	options := &types.ImageBuildOptions{}
-	if httputils.BoolValue(r, "forcerm") && version.GreaterThanOrEqualTo("1.12") {
+	if httputils.BoolValue(r, "forcerm") && versions.GreaterThanOrEqualTo(version, "1.12") {
 		options.Remove = true
 		options.Remove = true
-	} else if r.FormValue("rm") == "" && version.GreaterThanOrEqualTo("1.12") {
+	} else if r.FormValue("rm") == "" && versions.GreaterThanOrEqualTo(version, "1.12") {
 		options.Remove = true
 		options.Remove = true
 	} else {
 	} else {
 		options.Remove = httputils.BoolValue(r, "rm")
 		options.Remove = httputils.BoolValue(r, "rm")
 	}
 	}
-	if httputils.BoolValue(r, "pull") && version.GreaterThanOrEqualTo("1.16") {
+	if httputils.BoolValue(r, "pull") && versions.GreaterThanOrEqualTo(version, "1.16") {
 		options.PullParent = true
 		options.PullParent = true
 	}
 	}
 
 

+ 1 - 2
api/server/router/container/backend.go

@@ -8,7 +8,6 @@ import (
 
 
 	"github.com/docker/docker/api/types/backend"
 	"github.com/docker/docker/api/types/backend"
 	"github.com/docker/docker/pkg/archive"
 	"github.com/docker/docker/pkg/archive"
-	"github.com/docker/docker/pkg/version"
 	"github.com/docker/engine-api/types"
 	"github.com/docker/engine-api/types"
 	"github.com/docker/engine-api/types/container"
 	"github.com/docker/engine-api/types/container"
 )
 )
@@ -50,7 +49,7 @@ type stateBackend interface {
 // monitorBackend includes functions to implement to provide containers monitoring functionality.
 // monitorBackend includes functions to implement to provide containers monitoring functionality.
 type monitorBackend interface {
 type monitorBackend interface {
 	ContainerChanges(name string) ([]archive.Change, error)
 	ContainerChanges(name string) ([]archive.Change, error)
-	ContainerInspect(name string, size bool, version version.Version) (interface{}, error)
+	ContainerInspect(name string, size bool, version string) (interface{}, error)
 	ContainerLogs(ctx context.Context, name string, config *backend.ContainerLogsConfig, started chan struct{}) error
 	ContainerLogs(ctx context.Context, name string, config *backend.ContainerLogsConfig, started chan struct{}) error
 	ContainerStats(ctx context.Context, name string, config *backend.ContainerStatsConfig) error
 	ContainerStats(ctx context.Context, name string, config *backend.ContainerStatsConfig) error
 	ContainerTop(name string, psArgs string) (*types.ContainerProcessList, error)
 	ContainerTop(name string, psArgs string) (*types.ContainerProcessList, error)

+ 3 - 2
api/server/router/container/container_routes.go

@@ -18,6 +18,7 @@ import (
 	"github.com/docker/engine-api/types"
 	"github.com/docker/engine-api/types"
 	"github.com/docker/engine-api/types/container"
 	"github.com/docker/engine-api/types/container"
 	"github.com/docker/engine-api/types/filters"
 	"github.com/docker/engine-api/types/filters"
+	"github.com/docker/engine-api/types/versions"
 	"golang.org/x/net/context"
 	"golang.org/x/net/context"
 	"golang.org/x/net/websocket"
 	"golang.org/x/net/websocket"
 )
 )
@@ -195,7 +196,7 @@ func (s *containerRouter) postContainersKill(ctx context.Context, w http.Respons
 		// Return error if the container is not running and the api is >= 1.20
 		// Return error if the container is not running and the api is >= 1.20
 		// to keep backwards compatibility.
 		// to keep backwards compatibility.
 		version := httputils.VersionFromContext(ctx)
 		version := httputils.VersionFromContext(ctx)
-		if version.GreaterThanOrEqualTo("1.20") || !isStopped {
+		if versions.GreaterThanOrEqualTo(version, "1.20") || !isStopped {
 			return fmt.Errorf("Cannot kill container %s: %v", name, err)
 			return fmt.Errorf("Cannot kill container %s: %v", name, err)
 		}
 		}
 	}
 	}
@@ -341,7 +342,7 @@ func (s *containerRouter) postContainersCreate(ctx context.Context, w http.Respo
 		return err
 		return err
 	}
 	}
 	version := httputils.VersionFromContext(ctx)
 	version := httputils.VersionFromContext(ctx)
-	adjustCPUShares := version.LessThan("1.19")
+	adjustCPUShares := versions.LessThan(version, "1.19")
 
 
 	ccr, err := s.backend.ContainerCreate(types.ContainerCreateConfig{
 	ccr, err := s.backend.ContainerCreate(types.ContainerCreateConfig{
 		Name:             name,
 		Name:             name,

+ 2 - 1
api/server/router/container/exec.go

@@ -11,6 +11,7 @@ import (
 	"github.com/docker/docker/api/server/httputils"
 	"github.com/docker/docker/api/server/httputils"
 	"github.com/docker/docker/pkg/stdcopy"
 	"github.com/docker/docker/pkg/stdcopy"
 	"github.com/docker/engine-api/types"
 	"github.com/docker/engine-api/types"
+	"github.com/docker/engine-api/types/versions"
 	"golang.org/x/net/context"
 	"golang.org/x/net/context"
 )
 )
 
 
@@ -60,7 +61,7 @@ func (s *containerRouter) postContainerExecStart(ctx context.Context, w http.Res
 	}
 	}
 
 
 	version := httputils.VersionFromContext(ctx)
 	version := httputils.VersionFromContext(ctx)
-	if version.GreaterThan("1.21") {
+	if versions.GreaterThan(version, "1.21") {
 		if err := httputils.CheckForJSON(r); err != nil {
 		if err := httputils.CheckForJSON(r); err != nil {
 			return err
 			return err
 		}
 		}

+ 2 - 1
api/server/router/image/image_routes.go

@@ -16,6 +16,7 @@ import (
 	"github.com/docker/docker/pkg/streamformatter"
 	"github.com/docker/docker/pkg/streamformatter"
 	"github.com/docker/engine-api/types"
 	"github.com/docker/engine-api/types"
 	"github.com/docker/engine-api/types/container"
 	"github.com/docker/engine-api/types/container"
+	"github.com/docker/engine-api/types/versions"
 	"golang.org/x/net/context"
 	"golang.org/x/net/context"
 )
 )
 
 
@@ -32,7 +33,7 @@ func (s *imageRouter) postCommit(ctx context.Context, w http.ResponseWriter, r *
 
 
 	pause := httputils.BoolValue(r, "pause")
 	pause := httputils.BoolValue(r, "pause")
 	version := httputils.VersionFromContext(ctx)
 	version := httputils.VersionFromContext(ctx)
-	if r.FormValue("pause") == "" && version.GreaterThanOrEqualTo("1.13") {
+	if r.FormValue("pause") == "" && versions.GreaterThanOrEqualTo(version, "1.13") {
 		pause = true
 		pause = true
 	}
 	}
 
 

+ 1 - 1
api/server/router/system/system_routes.go

@@ -39,7 +39,7 @@ func (s *systemRouter) getInfo(ctx context.Context, w http.ResponseWriter, r *ht
 
 
 func (s *systemRouter) getVersion(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
 func (s *systemRouter) getVersion(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
 	info := s.backend.SystemVersion()
 	info := s.backend.SystemVersion()
-	info.APIVersion = api.DefaultVersion.String()
+	info.APIVersion = api.DefaultVersion
 
 
 	return httputils.WriteJSON(w, http.StatusOK, info)
 	return httputils.WriteJSON(w, http.StatusOK, info)
 }
 }

+ 1 - 2
api/server/server_test.go

@@ -9,7 +9,6 @@ import (
 	"github.com/docker/docker/api"
 	"github.com/docker/docker/api"
 	"github.com/docker/docker/api/server/httputils"
 	"github.com/docker/docker/api/server/httputils"
 	"github.com/docker/docker/api/server/middleware"
 	"github.com/docker/docker/api/server/middleware"
-	"github.com/docker/docker/pkg/version"
 
 
 	"golang.org/x/net/context"
 	"golang.org/x/net/context"
 )
 )
@@ -22,7 +21,7 @@ func TestMiddlewares(t *testing.T) {
 		cfg: cfg,
 		cfg: cfg,
 	}
 	}
 
 
-	srv.UseMiddleware(middleware.NewVersionMiddleware(version.Version("0.1omega2"), api.DefaultVersion, api.MinVersion))
+	srv.UseMiddleware(middleware.NewVersionMiddleware("0.1omega2", api.DefaultVersion, api.MinVersion))
 
 
 	req, _ := http.NewRequest("GET", "/containers/json", nil)
 	req, _ := http.NewRequest("GET", "/containers/json", nil)
 	resp := httptest.NewRecorder()
 	resp := httptest.NewRecorder()

+ 4 - 4
daemon/inspect.go

@@ -7,20 +7,20 @@ import (
 	"github.com/docker/docker/api/types/backend"
 	"github.com/docker/docker/api/types/backend"
 	"github.com/docker/docker/container"
 	"github.com/docker/docker/container"
 	"github.com/docker/docker/daemon/network"
 	"github.com/docker/docker/daemon/network"
-	"github.com/docker/docker/pkg/version"
 	"github.com/docker/engine-api/types"
 	"github.com/docker/engine-api/types"
 	networktypes "github.com/docker/engine-api/types/network"
 	networktypes "github.com/docker/engine-api/types/network"
+	"github.com/docker/engine-api/types/versions"
 	"github.com/docker/engine-api/types/versions/v1p20"
 	"github.com/docker/engine-api/types/versions/v1p20"
 )
 )
 
 
 // ContainerInspect returns low-level information about a
 // ContainerInspect returns low-level information about a
 // container. Returns an error if the container cannot be found, or if
 // container. Returns an error if the container cannot be found, or if
 // there is an error getting the data.
 // there is an error getting the data.
-func (daemon *Daemon) ContainerInspect(name string, size bool, version version.Version) (interface{}, error) {
+func (daemon *Daemon) ContainerInspect(name string, size bool, version string) (interface{}, error) {
 	switch {
 	switch {
-	case version.LessThan("1.20"):
+	case versions.LessThan(version, "1.20"):
 		return daemon.containerInspectPre120(name)
 		return daemon.containerInspectPre120(name)
-	case version.Equal("1.20"):
+	case versions.Equal(version, "1.20"):
 		return daemon.containerInspect120(name)
 		return daemon.containerInspect120(name)
 	}
 	}
 	return daemon.containerInspectCurrent(name, size)
 	return daemon.containerInspectCurrent(name, size)

+ 3 - 3
daemon/stats.go

@@ -9,8 +9,8 @@ import (
 
 
 	"github.com/docker/docker/api/types/backend"
 	"github.com/docker/docker/api/types/backend"
 	"github.com/docker/docker/pkg/ioutils"
 	"github.com/docker/docker/pkg/ioutils"
-	"github.com/docker/docker/pkg/version"
 	"github.com/docker/engine-api/types"
 	"github.com/docker/engine-api/types"
+	"github.com/docker/engine-api/types/versions"
 	"github.com/docker/engine-api/types/versions/v1p20"
 	"github.com/docker/engine-api/types/versions/v1p20"
 )
 )
 
 
@@ -21,7 +21,7 @@ func (daemon *Daemon) ContainerStats(ctx context.Context, prefixOrName string, c
 		return errors.New("Windows does not support stats")
 		return errors.New("Windows does not support stats")
 	}
 	}
 	// Remote API version (used for backwards compatibility)
 	// Remote API version (used for backwards compatibility)
-	apiVersion := version.Version(config.Version)
+	apiVersion := config.Version
 
 
 	container, err := daemon.GetContainer(prefixOrName)
 	container, err := daemon.GetContainer(prefixOrName)
 	if err != nil {
 	if err != nil {
@@ -65,7 +65,7 @@ func (daemon *Daemon) ContainerStats(ctx context.Context, prefixOrName string, c
 
 
 			var statsJSON interface{}
 			var statsJSON interface{}
 			statsJSONPost120 := getStatJSON(v)
 			statsJSONPost120 := getStatJSON(v)
-			if apiVersion.LessThan("1.21") {
+			if versions.LessThan(apiVersion, "1.21") {
 				var (
 				var (
 					rxBytes   uint64
 					rxBytes   uint64
 					rxPackets uint64
 					rxPackets uint64

+ 1 - 2
docker/daemon.go

@@ -39,7 +39,6 @@ import (
 	"github.com/docker/docker/pkg/pidfile"
 	"github.com/docker/docker/pkg/pidfile"
 	"github.com/docker/docker/pkg/signal"
 	"github.com/docker/docker/pkg/signal"
 	"github.com/docker/docker/pkg/system"
 	"github.com/docker/docker/pkg/system"
-	"github.com/docker/docker/pkg/version"
 	"github.com/docker/docker/registry"
 	"github.com/docker/docker/registry"
 	"github.com/docker/docker/runconfig"
 	"github.com/docker/docker/runconfig"
 	"github.com/docker/docker/utils"
 	"github.com/docker/docker/utils"
@@ -440,7 +439,7 @@ func initRouter(s *apiserver.Server, d *daemon.Daemon) {
 }
 }
 
 
 func (cli *DaemonCli) initMiddlewares(s *apiserver.Server, cfg *apiserver.Config) {
 func (cli *DaemonCli) initMiddlewares(s *apiserver.Server, cfg *apiserver.Config) {
-	v := version.Version(cfg.Version)
+	v := cfg.Version
 
 
 	vm := middleware.NewVersionMiddleware(v, api.DefaultVersion, api.MinVersion)
 	vm := middleware.NewVersionMiddleware(v, api.DefaultVersion, api.MinVersion)
 	s.UseMiddleware(vm)
 	s.UseMiddleware(vm)

+ 1 - 1
hack/vendor.sh

@@ -25,7 +25,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 a6dca654f28f26b648115649f6382252ada81119
+clone git github.com/docker/engine-api a2999dbd3471ffe167f2aec7dccb9fa9b016dcbc
 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
 
 

+ 3 - 3
image/v1/imagev1.go

@@ -11,7 +11,7 @@ import (
 	"github.com/docker/distribution/digest"
 	"github.com/docker/distribution/digest"
 	"github.com/docker/docker/image"
 	"github.com/docker/docker/image"
 	"github.com/docker/docker/layer"
 	"github.com/docker/docker/layer"
-	"github.com/docker/docker/pkg/version"
+	"github.com/docker/engine-api/types/versions"
 )
 )
 
 
 var validHex = regexp.MustCompile(`^([a-f0-9]{64})$`)
 var validHex = regexp.MustCompile(`^([a-f0-9]{64})$`)
@@ -19,7 +19,7 @@ var validHex = regexp.MustCompile(`^([a-f0-9]{64})$`)
 // noFallbackMinVersion is the minimum version for which v1compatibility
 // noFallbackMinVersion is the minimum version for which v1compatibility
 // information will not be marshaled through the Image struct to remove
 // information will not be marshaled through the Image struct to remove
 // blank fields.
 // blank fields.
-var noFallbackMinVersion = version.Version("1.8.3")
+var noFallbackMinVersion = "1.8.3"
 
 
 // HistoryFromConfig creates a History struct from v1 configuration JSON
 // HistoryFromConfig creates a History struct from v1 configuration JSON
 func HistoryFromConfig(imageJSON []byte, emptyLayer bool) (image.History, error) {
 func HistoryFromConfig(imageJSON []byte, emptyLayer bool) (image.History, error) {
@@ -77,7 +77,7 @@ func MakeConfigFromV1Config(imageJSON []byte, rootfs *image.RootFS, history []im
 		return nil, err
 		return nil, err
 	}
 	}
 
 
-	useFallback := version.Version(dver.DockerVersion).LessThan(noFallbackMinVersion)
+	useFallback := versions.LessThan(dver.DockerVersion, noFallbackMinVersion)
 
 
 	if useFallback {
 	if useFallback {
 		var v1Image image.V1Image
 		var v1Image image.V1Image

+ 2 - 2
integration-cli/docker_api_stats_test.go

@@ -11,8 +11,8 @@ import (
 	"time"
 	"time"
 
 
 	"github.com/docker/docker/pkg/integration/checker"
 	"github.com/docker/docker/pkg/integration/checker"
-	"github.com/docker/docker/pkg/version"
 	"github.com/docker/engine-api/types"
 	"github.com/docker/engine-api/types"
+	"github.com/docker/engine-api/types/versions"
 	"github.com/go-check/check"
 	"github.com/go-check/check"
 )
 )
 
 
@@ -136,7 +136,7 @@ func (s *DockerSuite) TestApiStatsNetworkStatsVersioning(c *check.C) {
 	for i := 17; i <= 21; i++ {
 	for i := 17; i <= 21; i++ {
 		apiVersion := fmt.Sprintf("v1.%d", i)
 		apiVersion := fmt.Sprintf("v1.%d", i)
 		statsJSONBlob := getVersionedStats(c, id, apiVersion)
 		statsJSONBlob := getVersionedStats(c, id, apiVersion)
-		if version.Version(apiVersion).LessThan("v1.21") {
+		if versions.LessThan(apiVersion, "v1.21") {
 			c.Assert(jsonBlobHasLTv121NetworkStats(statsJSONBlob), checker.Equals, true,
 			c.Assert(jsonBlobHasLTv121NetworkStats(statsJSONBlob), checker.Equals, true,
 				check.Commentf("Stats JSON blob from API %s %#v does not look like a <v1.21 API stats structure", apiVersion, statsJSONBlob))
 				check.Commentf("Stats JSON blob from API %s %#v does not look like a <v1.21 API stats structure", apiVersion, statsJSONBlob))
 		} else {
 		} else {

+ 2 - 2
integration-cli/docker_api_test.go

@@ -49,7 +49,7 @@ func (s *DockerSuite) TestApiVersionStatusCode(c *check.C) {
 }
 }
 
 
 func (s *DockerSuite) TestApiClientVersionNewerThanServer(c *check.C) {
 func (s *DockerSuite) TestApiClientVersionNewerThanServer(c *check.C) {
-	v := strings.Split(api.DefaultVersion.String(), ".")
+	v := strings.Split(api.DefaultVersion, ".")
 	vMinInt, err := strconv.Atoi(v[1])
 	vMinInt, err := strconv.Atoi(v[1])
 	c.Assert(err, checker.IsNil)
 	c.Assert(err, checker.IsNil)
 	vMinInt++
 	vMinInt++
@@ -64,7 +64,7 @@ func (s *DockerSuite) TestApiClientVersionNewerThanServer(c *check.C) {
 }
 }
 
 
 func (s *DockerSuite) TestApiClientVersionOldNotSupported(c *check.C) {
 func (s *DockerSuite) TestApiClientVersionOldNotSupported(c *check.C) {
-	v := strings.Split(api.MinVersion.String(), ".")
+	v := strings.Split(api.MinVersion, ".")
 	vMinInt, err := strconv.Atoi(v[1])
 	vMinInt, err := strconv.Atoi(v[1])
 	c.Assert(err, checker.IsNil)
 	c.Assert(err, checker.IsNil)
 	vMinInt--
 	vMinInt--

+ 0 - 68
pkg/version/version.go

@@ -1,68 +0,0 @@
-package version
-
-import (
-	"strconv"
-	"strings"
-)
-
-// Version provides utility methods for comparing versions.
-type Version string
-
-func (v Version) compareTo(other Version) int {
-	var (
-		currTab  = strings.Split(string(v), ".")
-		otherTab = strings.Split(string(other), ".")
-	)
-
-	max := len(currTab)
-	if len(otherTab) > max {
-		max = len(otherTab)
-	}
-	for i := 0; i < max; i++ {
-		var currInt, otherInt int
-
-		if len(currTab) > i {
-			currInt, _ = strconv.Atoi(currTab[i])
-		}
-		if len(otherTab) > i {
-			otherInt, _ = strconv.Atoi(otherTab[i])
-		}
-		if currInt > otherInt {
-			return 1
-		}
-		if otherInt > currInt {
-			return -1
-		}
-	}
-	return 0
-}
-
-// String returns the version string
-func (v Version) String() string {
-	return string(v)
-}
-
-// LessThan checks if a version is less than another
-func (v Version) LessThan(other Version) bool {
-	return v.compareTo(other) == -1
-}
-
-// LessThanOrEqualTo checks if a version is less than or equal to another
-func (v Version) LessThanOrEqualTo(other Version) bool {
-	return v.compareTo(other) <= 0
-}
-
-// GreaterThan checks if a version is greater than another
-func (v Version) GreaterThan(other Version) bool {
-	return v.compareTo(other) == 1
-}
-
-// GreaterThanOrEqualTo checks if a version is greater than or equal to another
-func (v Version) GreaterThanOrEqualTo(other Version) bool {
-	return v.compareTo(other) >= 0
-}
-
-// Equal checks if a version is equal to another
-func (v Version) Equal(other Version) bool {
-	return v.compareTo(other) == 0
-}

+ 0 - 27
pkg/version/version_test.go

@@ -1,27 +0,0 @@
-package version
-
-import (
-	"testing"
-)
-
-func assertVersion(t *testing.T, a, b string, result int) {
-	if r := Version(a).compareTo(Version(b)); r != result {
-		t.Fatalf("Unexpected version comparison result. Found %d, expected %d", r, result)
-	}
-}
-
-func TestCompareVersion(t *testing.T) {
-	assertVersion(t, "1.12", "1.12", 0)
-	assertVersion(t, "1.0.0", "1", 0)
-	assertVersion(t, "1", "1.0.0", 0)
-	assertVersion(t, "1.05.00.0156", "1.0.221.9289", 1)
-	assertVersion(t, "1", "1.0.1", -1)
-	assertVersion(t, "1.0.1", "1", 1)
-	assertVersion(t, "1.0.1", "1.0.2", -1)
-	assertVersion(t, "1.0.2", "1.0.3", -1)
-	assertVersion(t, "1.0.3", "1.1", -1)
-	assertVersion(t, "1.1", "1.1.1", -1)
-	assertVersion(t, "1.1.1", "1.1.2", -1)
-	assertVersion(t, "1.1.2", "1.2", -1)
-
-}

+ 6 - 6
vendor/src/github.com/docker/engine-api/client/container_copy.go

@@ -30,17 +30,17 @@ func (cli *Client) ContainerStatPath(ctx context.Context, containerID, path stri
 }
 }
 
 
 // CopyToContainer copies content into the container filesystem.
 // CopyToContainer copies content into the container filesystem.
-func (cli *Client) CopyToContainer(ctx context.Context, options types.CopyToContainerOptions) error {
+func (cli *Client) CopyToContainer(ctx context.Context, container, path string, content io.Reader, options types.CopyToContainerOptions) error {
 	query := url.Values{}
 	query := url.Values{}
-	query.Set("path", filepath.ToSlash(options.Path)) // Normalize the paths used in the API.
+	query.Set("path", filepath.ToSlash(path)) // Normalize the paths used in the API.
 	// Do not allow for an existing directory to be overwritten by a non-directory and vice versa.
 	// Do not allow for an existing directory to be overwritten by a non-directory and vice versa.
 	if !options.AllowOverwriteDirWithFile {
 	if !options.AllowOverwriteDirWithFile {
 		query.Set("noOverwriteDirNonDir", "true")
 		query.Set("noOverwriteDirNonDir", "true")
 	}
 	}
 
 
-	path := fmt.Sprintf("/containers/%s/archive", options.ContainerID)
+	apiPath := fmt.Sprintf("/containers/%s/archive", container)
 
 
-	response, err := cli.putRaw(ctx, path, query, options.Content, nil)
+	response, err := cli.putRaw(ctx, apiPath, query, content, nil)
 	if err != nil {
 	if err != nil {
 		return err
 		return err
 	}
 	}
@@ -55,11 +55,11 @@ func (cli *Client) CopyToContainer(ctx context.Context, options types.CopyToCont
 
 
 // CopyFromContainer gets the content from the container and returns it as a Reader
 // CopyFromContainer gets the content from the container and returns it as a Reader
 // to manipulate it in the host. It's up to the caller to close the reader.
 // to manipulate it in the host. It's up to the caller to close the reader.
-func (cli *Client) CopyFromContainer(ctx context.Context, containerID, srcPath string) (io.ReadCloser, types.ContainerPathStat, error) {
+func (cli *Client) CopyFromContainer(ctx context.Context, container, srcPath string) (io.ReadCloser, types.ContainerPathStat, error) {
 	query := make(url.Values, 1)
 	query := make(url.Values, 1)
 	query.Set("path", filepath.ToSlash(srcPath)) // Normalize the paths used in the API.
 	query.Set("path", filepath.ToSlash(srcPath)) // Normalize the paths used in the API.
 
 
-	apiPath := fmt.Sprintf("/containers/%s/archive", containerID)
+	apiPath := fmt.Sprintf("/containers/%s/archive", container)
 	response, err := cli.get(ctx, apiPath, query, nil)
 	response, err := cli.get(ctx, apiPath, query, nil)
 	if err != nil {
 	if err != nil {
 		return nil, types.ContainerPathStat{}, err
 		return nil, types.ContainerPathStat{}, err

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

@@ -44,7 +44,7 @@ type APIClient interface {
 	ContainerUpdate(ctx context.Context, container string, updateConfig container.UpdateConfig) error
 	ContainerUpdate(ctx context.Context, container string, updateConfig container.UpdateConfig) error
 	ContainerWait(ctx context.Context, container string) (int, error)
 	ContainerWait(ctx context.Context, container string) (int, error)
 	CopyFromContainer(ctx context.Context, container, srcPath string) (io.ReadCloser, types.ContainerPathStat, error)
 	CopyFromContainer(ctx context.Context, container, srcPath string) (io.ReadCloser, types.ContainerPathStat, error)
-	CopyToContainer(ctx context.Context, options types.CopyToContainerOptions) error
+	CopyToContainer(ctx context.Context, container, path string, content io.Reader, options types.CopyToContainerOptions) error
 	Events(ctx context.Context, options types.EventsOptions) (io.ReadCloser, error)
 	Events(ctx context.Context, options types.EventsOptions) (io.ReadCloser, error)
 	ImageBuild(ctx context.Context, context io.Reader, options types.ImageBuildOptions) (types.ImageBuildResponse, error)
 	ImageBuild(ctx context.Context, context io.Reader, options types.ImageBuildOptions) (types.ImageBuildResponse, error)
 	ImageCreate(ctx context.Context, parentReference string, options types.ImageCreateOptions) (io.ReadCloser, error)
 	ImageCreate(ctx context.Context, parentReference string, options types.ImageCreateOptions) (io.ReadCloser, error)

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

@@ -1 +0,0 @@
-package client

+ 0 - 3
vendor/src/github.com/docker/engine-api/types/client.go

@@ -69,9 +69,6 @@ type ContainerRemoveOptions struct {
 // CopyToContainerOptions holds information
 // CopyToContainerOptions holds information
 // about files to copy into a container
 // about files to copy into a container
 type CopyToContainerOptions struct {
 type CopyToContainerOptions struct {
-	ContainerID               string
-	Path                      string
-	Content                   io.Reader
 	AllowOverwriteDirWithFile bool
 	AllowOverwriteDirWithFile bool
 }
 }
 
 

+ 3 - 33
vendor/src/github.com/docker/engine-api/types/filters/parse.go

@@ -7,8 +7,9 @@ import (
 	"errors"
 	"errors"
 	"fmt"
 	"fmt"
 	"regexp"
 	"regexp"
-	"strconv"
 	"strings"
 	"strings"
+
+	"github.com/docker/engine-api/types/versions"
 )
 )
 
 
 // Args stores filter arguments as map key:{map key: bool}.
 // Args stores filter arguments as map key:{map key: bool}.
@@ -80,7 +81,7 @@ func ToParamWithVersion(version string, a Args) (string, error) {
 	// for daemons older than v1.10, filter must be of the form map[string][]string
 	// for daemons older than v1.10, filter must be of the form map[string][]string
 	buf := []byte{}
 	buf := []byte{}
 	err := errors.New("")
 	err := errors.New("")
-	if version != "" && compareTo(version, "1.22") == -1 {
+	if version != "" && versions.LessThan(version, "1.22") {
 		buf, err = json.Marshal(convertArgsToSlice(a.fields))
 		buf, err = json.Marshal(convertArgsToSlice(a.fields))
 	} else {
 	} else {
 		buf, err = json.Marshal(a.fields)
 		buf, err = json.Marshal(a.fields)
@@ -292,34 +293,3 @@ func convertArgsToSlice(f map[string]map[string]bool) map[string][]string {
 	}
 	}
 	return m
 	return m
 }
 }
-
-// compareTo compares two version strings
-// returns -1 if v1 < v2, 1 if v1 > v2, 0 otherwise
-func compareTo(v1, v2 string) int {
-	var (
-		currTab  = strings.Split(v1, ".")
-		otherTab = strings.Split(v2, ".")
-	)
-
-	max := len(currTab)
-	if len(otherTab) > max {
-		max = len(otherTab)
-	}
-	for i := 0; i < max; i++ {
-		var currInt, otherInt int
-
-		if len(currTab) > i {
-			currInt, _ = strconv.Atoi(currTab[i])
-		}
-		if len(otherTab) > i {
-			otherInt, _ = strconv.Atoi(otherTab[i])
-		}
-		if currInt > otherInt {
-			return 1
-		}
-		if otherInt > currInt {
-			return -1
-		}
-	}
-	return 0
-}

+ 14 - 0
vendor/src/github.com/docker/engine-api/types/versions/README.md

@@ -0,0 +1,14 @@
+## Legacy API type versions
+
+This package includes types for legacy API versions. The stable version of the API types live in `api/types/*.go`.
+
+Consider moving a type here when you need to keep backwards compatibility in the API. This legacy types are organized by the latest API version they appear in. For instance, types in the `v1p19` package are valid for API versions below or equal `1.19`. Types in the `v1p20` package are valid for the API version `1.20`, since the versions below that will use the legacy types in `v1p19`.
+
+### Package name conventions
+
+The package name convention is to use `v` as a prefix for the version number and `p`(patch) as a separator. We use this nomenclature due to a few restrictions in the Go package name convention:
+
+1. We cannot use `.` because it's interpreted by the language, think of `v1.20.CallFunction`.
+2. We cannot use `_` because golint complains abount it. The code is actually valid, but it looks probably more weird: `v1_20.CallFunction`.
+
+For instance, if you want to modify a type that was available in the version `1.21` of the API but it will have different fields in the version `1.22`, you want to create a new package under `api/types/versions/v1p21`.

+ 62 - 0
vendor/src/github.com/docker/engine-api/types/versions/compare.go

@@ -0,0 +1,62 @@
+package versions
+
+import (
+	"strconv"
+	"strings"
+)
+
+// compare compares two version strings
+// returns -1 if v1 < v2, 1 if v1 > v2, 0 otherwise.
+func compare(v1, v2 string) int {
+	var (
+		currTab  = strings.Split(v1, ".")
+		otherTab = strings.Split(v2, ".")
+	)
+
+	max := len(currTab)
+	if len(otherTab) > max {
+		max = len(otherTab)
+	}
+	for i := 0; i < max; i++ {
+		var currInt, otherInt int
+
+		if len(currTab) > i {
+			currInt, _ = strconv.Atoi(currTab[i])
+		}
+		if len(otherTab) > i {
+			otherInt, _ = strconv.Atoi(otherTab[i])
+		}
+		if currInt > otherInt {
+			return 1
+		}
+		if otherInt > currInt {
+			return -1
+		}
+	}
+	return 0
+}
+
+// LessThan checks if a version is less than another
+func LessThan(v, other string) bool {
+	return compare(v, other) == -1
+}
+
+// LessThanOrEqualTo checks if a version is less than or equal to another
+func LessThanOrEqualTo(v, other string) bool {
+	return compare(v, other) <= 0
+}
+
+// GreaterThan checks if a version is greater than another
+func GreaterThan(v, other string) bool {
+	return compare(v, other) == 1
+}
+
+// GreaterThanOrEqualTo checks if a version is greater than or equal to another
+func GreaterThanOrEqualTo(v, other string) bool {
+	return compare(v, other) >= 0
+}
+
+// Equal checks if a version is equal to another
+func Equal(v, other string) bool {
+	return compare(v, other) == 0
+}