- Update CopyToContainer uses
- Use engine-api/types/versions instead of pkg/version
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
| ... | ... |
@@ -142,7 +142,7 @@ func NewDockerCli(in io.ReadCloser, out, err io.Writer, clientFlags *cli.ClientF |
| 142 | 142 |
} |
| 143 | 143 |
customHeaders["User-Agent"] = clientUserAgent() |
| 144 | 144 |
|
| 145 |
- verStr := api.DefaultVersion.String() |
|
| 145 |
+ verStr := api.DefaultVersion |
|
| 146 | 146 |
if tmpStr := os.Getenv("DOCKER_API_VERSION"); tmpStr != "" {
|
| 147 | 147 |
verStr = tmpStr |
| 148 | 148 |
} |
| ... | ... |
@@ -288,11 +288,8 @@ func (cli *DockerCli) copyToContainer(srcPath, dstContainer, dstPath string, cpP |
| 288 | 288 |
} |
| 289 | 289 |
|
| 290 | 290 |
options := types.CopyToContainerOptions{
|
| 291 |
- ContainerID: dstContainer, |
|
| 292 |
- Path: resolvedDstPath, |
|
| 293 |
- Content: content, |
|
| 294 | 291 |
AllowOverwriteDirWithFile: false, |
| 295 | 292 |
} |
| 296 | 293 |
|
| 297 |
- return cli.client.CopyToContainer(context.Background(), options) |
|
| 294 |
+ return cli.client.CopyToContainer(context.Background(), dstContainer, resolvedDstPath, content, options) |
|
| 298 | 295 |
} |
| ... | ... |
@@ -10,7 +10,6 @@ import ( |
| 10 | 10 |
|
| 11 | 11 |
"github.com/Sirupsen/logrus" |
| 12 | 12 |
"github.com/docker/docker/pkg/system" |
| 13 |
- "github.com/docker/docker/pkg/version" |
|
| 14 | 13 |
"github.com/docker/engine-api/types" |
| 15 | 14 |
"github.com/docker/libtrust" |
| 16 | 15 |
) |
| ... | ... |
@@ -18,10 +17,10 @@ import ( |
| 18 | 18 |
// Common constants for daemon and client. |
| 19 | 19 |
const ( |
| 20 | 20 |
// Version of Current REST API |
| 21 |
- DefaultVersion version.Version = "1.24" |
|
| 21 |
+ DefaultVersion string = "1.24" |
|
| 22 | 22 |
|
| 23 | 23 |
// MinVersion represents Minimum REST API version supported |
| 24 |
- MinVersion version.Version = "1.12" |
|
| 24 |
+ MinVersion string = "1.12" |
|
| 25 | 25 |
|
| 26 | 26 |
// NoBaseImageSpecifier is the symbol used by the FROM |
| 27 | 27 |
// command to specify that no base image is to be used. |
| ... | ... |
@@ -10,7 +10,6 @@ import ( |
| 10 | 10 |
"golang.org/x/net/context" |
| 11 | 11 |
|
| 12 | 12 |
"github.com/docker/docker/api" |
| 13 |
- "github.com/docker/docker/pkg/version" |
|
| 14 | 13 |
) |
| 15 | 14 |
|
| 16 | 15 |
// APIVersionKey is the client's requested API version. |
| ... | ... |
@@ -95,7 +94,7 @@ func WriteJSON(w http.ResponseWriter, code int, v interface{}) error {
|
| 95 | 95 |
|
| 96 | 96 |
// VersionFromContext returns an API version from the context using APIVersionKey. |
| 97 | 97 |
// It panics if the context value does not have version.Version type. |
| 98 |
-func VersionFromContext(ctx context.Context) (ver version.Version) {
|
|
| 98 |
+func VersionFromContext(ctx context.Context) (ver string) {
|
|
| 99 | 99 |
if ctx == nil {
|
| 100 | 100 |
return |
| 101 | 101 |
} |
| ... | ... |
@@ -103,5 +102,5 @@ func VersionFromContext(ctx context.Context) (ver version.Version) {
|
| 103 | 103 |
if val == nil {
|
| 104 | 104 |
return |
| 105 | 105 |
} |
| 106 |
- return val.(version.Version) |
|
| 106 |
+ return val.(string) |
|
| 107 | 107 |
} |
| ... | ... |
@@ -6,19 +6,19 @@ import ( |
| 6 | 6 |
|
| 7 | 7 |
"github.com/Sirupsen/logrus" |
| 8 | 8 |
"github.com/docker/docker/api/server/httputils" |
| 9 |
- "github.com/docker/docker/pkg/version" |
|
| 9 |
+ "github.com/docker/engine-api/types/versions" |
|
| 10 | 10 |
"golang.org/x/net/context" |
| 11 | 11 |
) |
| 12 | 12 |
|
| 13 | 13 |
// UserAgentMiddleware is a middleware that |
| 14 | 14 |
// validates the client user-agent. |
| 15 | 15 |
type UserAgentMiddleware struct {
|
| 16 |
- serverVersion version.Version |
|
| 16 |
+ serverVersion string |
|
| 17 | 17 |
} |
| 18 | 18 |
|
| 19 | 19 |
// NewUserAgentMiddleware creates a new UserAgentMiddleware |
| 20 | 20 |
// with the server version. |
| 21 |
-func NewUserAgentMiddleware(s version.Version) UserAgentMiddleware {
|
|
| 21 |
+func NewUserAgentMiddleware(s string) UserAgentMiddleware {
|
|
| 22 | 22 |
return UserAgentMiddleware{
|
| 23 | 23 |
serverVersion: s, |
| 24 | 24 |
} |
| ... | ... |
@@ -38,7 +38,7 @@ func (u UserAgentMiddleware) WrapHandler(handler func(ctx context.Context, w htt |
| 38 | 38 |
userAgent[1] = strings.Split(userAgent[1], " ")[0] |
| 39 | 39 |
} |
| 40 | 40 |
|
| 41 |
- if len(userAgent) == 2 && !u.serverVersion.Equal(version.Version(userAgent[1])) {
|
|
| 41 |
+ if len(userAgent) == 2 && !versions.Equal(u.serverVersion, userAgent[1]) {
|
|
| 42 | 42 |
logrus.Debugf("Client and server don't have the same version (client: %s, server: %s)", userAgent[1], u.serverVersion)
|
| 43 | 43 |
} |
| 44 | 44 |
} |
| ... | ... |
@@ -5,7 +5,7 @@ import ( |
| 5 | 5 |
"net/http" |
| 6 | 6 |
"runtime" |
| 7 | 7 |
|
| 8 |
- "github.com/docker/docker/pkg/version" |
|
| 8 |
+ "github.com/docker/engine-api/types/versions" |
|
| 9 | 9 |
"golang.org/x/net/context" |
| 10 | 10 |
) |
| 11 | 11 |
|
| ... | ... |
@@ -20,14 +20,14 @@ func (badRequestError) HTTPErrorStatusCode() int {
|
| 20 | 20 |
// VersionMiddleware is a middleware that |
| 21 | 21 |
// validates the client and server versions. |
| 22 | 22 |
type VersionMiddleware struct {
|
| 23 |
- serverVersion version.Version |
|
| 24 |
- defaultVersion version.Version |
|
| 25 |
- minVersion version.Version |
|
| 23 |
+ serverVersion string |
|
| 24 |
+ defaultVersion string |
|
| 25 |
+ minVersion string |
|
| 26 | 26 |
} |
| 27 | 27 |
|
| 28 | 28 |
// NewVersionMiddleware creates a new VersionMiddleware |
| 29 | 29 |
// with the default versions. |
| 30 |
-func NewVersionMiddleware(s, d, m version.Version) VersionMiddleware {
|
|
| 30 |
+func NewVersionMiddleware(s, d, m string) VersionMiddleware {
|
|
| 31 | 31 |
return VersionMiddleware{
|
| 32 | 32 |
serverVersion: s, |
| 33 | 33 |
defaultVersion: d, |
| ... | ... |
@@ -38,15 +38,15 @@ func NewVersionMiddleware(s, d, m version.Version) VersionMiddleware {
|
| 38 | 38 |
// WrapHandler returns a new handler function wrapping the previous one in the request chain. |
| 39 | 39 |
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 {
|
| 40 | 40 |
return func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
| 41 |
- apiVersion := version.Version(vars["version"]) |
|
| 41 |
+ apiVersion := vars["version"] |
|
| 42 | 42 |
if apiVersion == "" {
|
| 43 | 43 |
apiVersion = v.defaultVersion |
| 44 | 44 |
} |
| 45 | 45 |
|
| 46 |
- if apiVersion.GreaterThan(v.defaultVersion) {
|
|
| 46 |
+ if versions.GreaterThan(apiVersion, v.defaultVersion) {
|
|
| 47 | 47 |
return badRequestError{fmt.Errorf("client is newer than server (client API version: %s, server API version: %s)", apiVersion, v.defaultVersion)}
|
| 48 | 48 |
} |
| 49 |
- if apiVersion.LessThan(v.minVersion) {
|
|
| 49 |
+ if versions.LessThan(apiVersion, v.minVersion) {
|
|
| 50 | 50 |
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)}
|
| 51 | 51 |
} |
| 52 | 52 |
|
| ... | ... |
@@ -7,7 +7,6 @@ import ( |
| 7 | 7 |
"testing" |
| 8 | 8 |
|
| 9 | 9 |
"github.com/docker/docker/api/server/httputils" |
| 10 |
- "github.com/docker/docker/pkg/version" |
|
| 11 | 10 |
"golang.org/x/net/context" |
| 12 | 11 |
) |
| 13 | 12 |
|
| ... | ... |
@@ -19,8 +18,8 @@ func TestVersionMiddleware(t *testing.T) {
|
| 19 | 19 |
return nil |
| 20 | 20 |
} |
| 21 | 21 |
|
| 22 |
- defaultVersion := version.Version("1.10.0")
|
|
| 23 |
- minVersion := version.Version("1.2.0")
|
|
| 22 |
+ defaultVersion := "1.10.0" |
|
| 23 |
+ minVersion := "1.2.0" |
|
| 24 | 24 |
m := NewVersionMiddleware(defaultVersion, defaultVersion, minVersion) |
| 25 | 25 |
h := m.WrapHandler(handler) |
| 26 | 26 |
|
| ... | ... |
@@ -40,8 +39,8 @@ func TestVersionMiddlewareWithErrors(t *testing.T) {
|
| 40 | 40 |
return nil |
| 41 | 41 |
} |
| 42 | 42 |
|
| 43 |
- defaultVersion := version.Version("1.10.0")
|
|
| 44 |
- minVersion := version.Version("1.2.0")
|
|
| 43 |
+ defaultVersion := "1.10.0" |
|
| 44 |
+ minVersion := "1.2.0" |
|
| 45 | 45 |
m := NewVersionMiddleware(defaultVersion, defaultVersion, minVersion) |
| 46 | 46 |
h := m.WrapHandler(handler) |
| 47 | 47 |
|
| ... | ... |
@@ -19,6 +19,7 @@ import ( |
| 19 | 19 |
"github.com/docker/docker/pkg/streamformatter" |
| 20 | 20 |
"github.com/docker/engine-api/types" |
| 21 | 21 |
"github.com/docker/engine-api/types/container" |
| 22 |
+ "github.com/docker/engine-api/types/versions" |
|
| 22 | 23 |
"github.com/docker/go-units" |
| 23 | 24 |
"golang.org/x/net/context" |
| 24 | 25 |
) |
| ... | ... |
@@ -26,14 +27,14 @@ import ( |
| 26 | 26 |
func newImageBuildOptions(ctx context.Context, r *http.Request) (*types.ImageBuildOptions, error) {
|
| 27 | 27 |
version := httputils.VersionFromContext(ctx) |
| 28 | 28 |
options := &types.ImageBuildOptions{}
|
| 29 |
- if httputils.BoolValue(r, "forcerm") && version.GreaterThanOrEqualTo("1.12") {
|
|
| 29 |
+ if httputils.BoolValue(r, "forcerm") && versions.GreaterThanOrEqualTo(version, "1.12") {
|
|
| 30 | 30 |
options.Remove = true |
| 31 |
- } else if r.FormValue("rm") == "" && version.GreaterThanOrEqualTo("1.12") {
|
|
| 31 |
+ } else if r.FormValue("rm") == "" && versions.GreaterThanOrEqualTo(version, "1.12") {
|
|
| 32 | 32 |
options.Remove = true |
| 33 | 33 |
} else {
|
| 34 | 34 |
options.Remove = httputils.BoolValue(r, "rm") |
| 35 | 35 |
} |
| 36 |
- if httputils.BoolValue(r, "pull") && version.GreaterThanOrEqualTo("1.16") {
|
|
| 36 |
+ if httputils.BoolValue(r, "pull") && versions.GreaterThanOrEqualTo(version, "1.16") {
|
|
| 37 | 37 |
options.PullParent = true |
| 38 | 38 |
} |
| 39 | 39 |
|
| ... | ... |
@@ -8,7 +8,6 @@ import ( |
| 8 | 8 |
|
| 9 | 9 |
"github.com/docker/docker/api/types/backend" |
| 10 | 10 |
"github.com/docker/docker/pkg/archive" |
| 11 |
- "github.com/docker/docker/pkg/version" |
|
| 12 | 11 |
"github.com/docker/engine-api/types" |
| 13 | 12 |
"github.com/docker/engine-api/types/container" |
| 14 | 13 |
) |
| ... | ... |
@@ -50,7 +49,7 @@ type stateBackend interface {
|
| 50 | 50 |
// monitorBackend includes functions to implement to provide containers monitoring functionality. |
| 51 | 51 |
type monitorBackend interface {
|
| 52 | 52 |
ContainerChanges(name string) ([]archive.Change, error) |
| 53 |
- ContainerInspect(name string, size bool, version version.Version) (interface{}, error)
|
|
| 53 |
+ ContainerInspect(name string, size bool, version string) (interface{}, error)
|
|
| 54 | 54 |
ContainerLogs(ctx context.Context, name string, config *backend.ContainerLogsConfig, started chan struct{}) error
|
| 55 | 55 |
ContainerStats(ctx context.Context, name string, config *backend.ContainerStatsConfig) error |
| 56 | 56 |
ContainerTop(name string, psArgs string) (*types.ContainerProcessList, error) |
| ... | ... |
@@ -18,6 +18,7 @@ import ( |
| 18 | 18 |
"github.com/docker/engine-api/types" |
| 19 | 19 |
"github.com/docker/engine-api/types/container" |
| 20 | 20 |
"github.com/docker/engine-api/types/filters" |
| 21 |
+ "github.com/docker/engine-api/types/versions" |
|
| 21 | 22 |
"golang.org/x/net/context" |
| 22 | 23 |
"golang.org/x/net/websocket" |
| 23 | 24 |
) |
| ... | ... |
@@ -195,7 +196,7 @@ func (s *containerRouter) postContainersKill(ctx context.Context, w http.Respons |
| 195 | 195 |
// Return error if the container is not running and the api is >= 1.20 |
| 196 | 196 |
// to keep backwards compatibility. |
| 197 | 197 |
version := httputils.VersionFromContext(ctx) |
| 198 |
- if version.GreaterThanOrEqualTo("1.20") || !isStopped {
|
|
| 198 |
+ if versions.GreaterThanOrEqualTo(version, "1.20") || !isStopped {
|
|
| 199 | 199 |
return fmt.Errorf("Cannot kill container %s: %v", name, err)
|
| 200 | 200 |
} |
| 201 | 201 |
} |
| ... | ... |
@@ -341,7 +342,7 @@ func (s *containerRouter) postContainersCreate(ctx context.Context, w http.Respo |
| 341 | 341 |
return err |
| 342 | 342 |
} |
| 343 | 343 |
version := httputils.VersionFromContext(ctx) |
| 344 |
- adjustCPUShares := version.LessThan("1.19")
|
|
| 344 |
+ adjustCPUShares := versions.LessThan(version, "1.19") |
|
| 345 | 345 |
|
| 346 | 346 |
ccr, err := s.backend.ContainerCreate(types.ContainerCreateConfig{
|
| 347 | 347 |
Name: name, |
| ... | ... |
@@ -11,6 +11,7 @@ import ( |
| 11 | 11 |
"github.com/docker/docker/api/server/httputils" |
| 12 | 12 |
"github.com/docker/docker/pkg/stdcopy" |
| 13 | 13 |
"github.com/docker/engine-api/types" |
| 14 |
+ "github.com/docker/engine-api/types/versions" |
|
| 14 | 15 |
"golang.org/x/net/context" |
| 15 | 16 |
) |
| 16 | 17 |
|
| ... | ... |
@@ -60,7 +61,7 @@ func (s *containerRouter) postContainerExecStart(ctx context.Context, w http.Res |
| 60 | 60 |
} |
| 61 | 61 |
|
| 62 | 62 |
version := httputils.VersionFromContext(ctx) |
| 63 |
- if version.GreaterThan("1.21") {
|
|
| 63 |
+ if versions.GreaterThan(version, "1.21") {
|
|
| 64 | 64 |
if err := httputils.CheckForJSON(r); err != nil {
|
| 65 | 65 |
return err |
| 66 | 66 |
} |
| ... | ... |
@@ -16,6 +16,7 @@ import ( |
| 16 | 16 |
"github.com/docker/docker/pkg/streamformatter" |
| 17 | 17 |
"github.com/docker/engine-api/types" |
| 18 | 18 |
"github.com/docker/engine-api/types/container" |
| 19 |
+ "github.com/docker/engine-api/types/versions" |
|
| 19 | 20 |
"golang.org/x/net/context" |
| 20 | 21 |
) |
| 21 | 22 |
|
| ... | ... |
@@ -32,7 +33,7 @@ func (s *imageRouter) postCommit(ctx context.Context, w http.ResponseWriter, r * |
| 32 | 32 |
|
| 33 | 33 |
pause := httputils.BoolValue(r, "pause") |
| 34 | 34 |
version := httputils.VersionFromContext(ctx) |
| 35 |
- if r.FormValue("pause") == "" && version.GreaterThanOrEqualTo("1.13") {
|
|
| 35 |
+ if r.FormValue("pause") == "" && versions.GreaterThanOrEqualTo(version, "1.13") {
|
|
| 36 | 36 |
pause = true |
| 37 | 37 |
} |
| 38 | 38 |
|
| ... | ... |
@@ -39,7 +39,7 @@ func (s *systemRouter) getInfo(ctx context.Context, w http.ResponseWriter, r *ht |
| 39 | 39 |
|
| 40 | 40 |
func (s *systemRouter) getVersion(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
| 41 | 41 |
info := s.backend.SystemVersion() |
| 42 |
- info.APIVersion = api.DefaultVersion.String() |
|
| 42 |
+ info.APIVersion = api.DefaultVersion |
|
| 43 | 43 |
|
| 44 | 44 |
return httputils.WriteJSON(w, http.StatusOK, info) |
| 45 | 45 |
} |
| ... | ... |
@@ -9,7 +9,6 @@ import ( |
| 9 | 9 |
"github.com/docker/docker/api" |
| 10 | 10 |
"github.com/docker/docker/api/server/httputils" |
| 11 | 11 |
"github.com/docker/docker/api/server/middleware" |
| 12 |
- "github.com/docker/docker/pkg/version" |
|
| 13 | 12 |
|
| 14 | 13 |
"golang.org/x/net/context" |
| 15 | 14 |
) |
| ... | ... |
@@ -22,7 +21,7 @@ func TestMiddlewares(t *testing.T) {
|
| 22 | 22 |
cfg: cfg, |
| 23 | 23 |
} |
| 24 | 24 |
|
| 25 |
- srv.UseMiddleware(middleware.NewVersionMiddleware(version.Version("0.1omega2"), api.DefaultVersion, api.MinVersion))
|
|
| 25 |
+ srv.UseMiddleware(middleware.NewVersionMiddleware("0.1omega2", api.DefaultVersion, api.MinVersion))
|
|
| 26 | 26 |
|
| 27 | 27 |
req, _ := http.NewRequest("GET", "/containers/json", nil)
|
| 28 | 28 |
resp := httptest.NewRecorder() |
| ... | ... |
@@ -7,20 +7,20 @@ import ( |
| 7 | 7 |
"github.com/docker/docker/api/types/backend" |
| 8 | 8 |
"github.com/docker/docker/container" |
| 9 | 9 |
"github.com/docker/docker/daemon/network" |
| 10 |
- "github.com/docker/docker/pkg/version" |
|
| 11 | 10 |
"github.com/docker/engine-api/types" |
| 12 | 11 |
networktypes "github.com/docker/engine-api/types/network" |
| 12 |
+ "github.com/docker/engine-api/types/versions" |
|
| 13 | 13 |
"github.com/docker/engine-api/types/versions/v1p20" |
| 14 | 14 |
) |
| 15 | 15 |
|
| 16 | 16 |
// ContainerInspect returns low-level information about a |
| 17 | 17 |
// container. Returns an error if the container cannot be found, or if |
| 18 | 18 |
// there is an error getting the data. |
| 19 |
-func (daemon *Daemon) ContainerInspect(name string, size bool, version version.Version) (interface{}, error) {
|
|
| 19 |
+func (daemon *Daemon) ContainerInspect(name string, size bool, version string) (interface{}, error) {
|
|
| 20 | 20 |
switch {
|
| 21 |
- case version.LessThan("1.20"):
|
|
| 21 |
+ case versions.LessThan(version, "1.20"): |
|
| 22 | 22 |
return daemon.containerInspectPre120(name) |
| 23 |
- case version.Equal("1.20"):
|
|
| 23 |
+ case versions.Equal(version, "1.20"): |
|
| 24 | 24 |
return daemon.containerInspect120(name) |
| 25 | 25 |
} |
| 26 | 26 |
return daemon.containerInspectCurrent(name, size) |
| ... | ... |
@@ -9,8 +9,8 @@ import ( |
| 9 | 9 |
|
| 10 | 10 |
"github.com/docker/docker/api/types/backend" |
| 11 | 11 |
"github.com/docker/docker/pkg/ioutils" |
| 12 |
- "github.com/docker/docker/pkg/version" |
|
| 13 | 12 |
"github.com/docker/engine-api/types" |
| 13 |
+ "github.com/docker/engine-api/types/versions" |
|
| 14 | 14 |
"github.com/docker/engine-api/types/versions/v1p20" |
| 15 | 15 |
) |
| 16 | 16 |
|
| ... | ... |
@@ -21,7 +21,7 @@ func (daemon *Daemon) ContainerStats(ctx context.Context, prefixOrName string, c |
| 21 | 21 |
return errors.New("Windows does not support stats")
|
| 22 | 22 |
} |
| 23 | 23 |
// Remote API version (used for backwards compatibility) |
| 24 |
- apiVersion := version.Version(config.Version) |
|
| 24 |
+ apiVersion := config.Version |
|
| 25 | 25 |
|
| 26 | 26 |
container, err := daemon.GetContainer(prefixOrName) |
| 27 | 27 |
if err != nil {
|
| ... | ... |
@@ -65,7 +65,7 @@ func (daemon *Daemon) ContainerStats(ctx context.Context, prefixOrName string, c |
| 65 | 65 |
|
| 66 | 66 |
var statsJSON interface{}
|
| 67 | 67 |
statsJSONPost120 := getStatJSON(v) |
| 68 |
- if apiVersion.LessThan("1.21") {
|
|
| 68 |
+ if versions.LessThan(apiVersion, "1.21") {
|
|
| 69 | 69 |
var ( |
| 70 | 70 |
rxBytes uint64 |
| 71 | 71 |
rxPackets uint64 |
| ... | ... |
@@ -39,7 +39,6 @@ import ( |
| 39 | 39 |
"github.com/docker/docker/pkg/pidfile" |
| 40 | 40 |
"github.com/docker/docker/pkg/signal" |
| 41 | 41 |
"github.com/docker/docker/pkg/system" |
| 42 |
- "github.com/docker/docker/pkg/version" |
|
| 43 | 42 |
"github.com/docker/docker/registry" |
| 44 | 43 |
"github.com/docker/docker/runconfig" |
| 45 | 44 |
"github.com/docker/docker/utils" |
| ... | ... |
@@ -440,7 +439,7 @@ func initRouter(s *apiserver.Server, d *daemon.Daemon) {
|
| 440 | 440 |
} |
| 441 | 441 |
|
| 442 | 442 |
func (cli *DaemonCli) initMiddlewares(s *apiserver.Server, cfg *apiserver.Config) {
|
| 443 |
- v := version.Version(cfg.Version) |
|
| 443 |
+ v := cfg.Version |
|
| 444 | 444 |
|
| 445 | 445 |
vm := middleware.NewVersionMiddleware(v, api.DefaultVersion, api.MinVersion) |
| 446 | 446 |
s.UseMiddleware(vm) |
| ... | ... |
@@ -11,7 +11,7 @@ import ( |
| 11 | 11 |
"github.com/docker/distribution/digest" |
| 12 | 12 |
"github.com/docker/docker/image" |
| 13 | 13 |
"github.com/docker/docker/layer" |
| 14 |
- "github.com/docker/docker/pkg/version" |
|
| 14 |
+ "github.com/docker/engine-api/types/versions" |
|
| 15 | 15 |
) |
| 16 | 16 |
|
| 17 | 17 |
var validHex = regexp.MustCompile(`^([a-f0-9]{64})$`)
|
| ... | ... |
@@ -19,7 +19,7 @@ var validHex = regexp.MustCompile(`^([a-f0-9]{64})$`)
|
| 19 | 19 |
// noFallbackMinVersion is the minimum version for which v1compatibility |
| 20 | 20 |
// information will not be marshaled through the Image struct to remove |
| 21 | 21 |
// blank fields. |
| 22 |
-var noFallbackMinVersion = version.Version("1.8.3")
|
|
| 22 |
+var noFallbackMinVersion = "1.8.3" |
|
| 23 | 23 |
|
| 24 | 24 |
// HistoryFromConfig creates a History struct from v1 configuration JSON |
| 25 | 25 |
func HistoryFromConfig(imageJSON []byte, emptyLayer bool) (image.History, error) {
|
| ... | ... |
@@ -77,7 +77,7 @@ func MakeConfigFromV1Config(imageJSON []byte, rootfs *image.RootFS, history []im |
| 77 | 77 |
return nil, err |
| 78 | 78 |
} |
| 79 | 79 |
|
| 80 |
- useFallback := version.Version(dver.DockerVersion).LessThan(noFallbackMinVersion) |
|
| 80 |
+ useFallback := versions.LessThan(dver.DockerVersion, noFallbackMinVersion) |
|
| 81 | 81 |
|
| 82 | 82 |
if useFallback {
|
| 83 | 83 |
var v1Image image.V1Image |
| ... | ... |
@@ -11,8 +11,8 @@ import ( |
| 11 | 11 |
"time" |
| 12 | 12 |
|
| 13 | 13 |
"github.com/docker/docker/pkg/integration/checker" |
| 14 |
- "github.com/docker/docker/pkg/version" |
|
| 15 | 14 |
"github.com/docker/engine-api/types" |
| 15 |
+ "github.com/docker/engine-api/types/versions" |
|
| 16 | 16 |
"github.com/go-check/check" |
| 17 | 17 |
) |
| 18 | 18 |
|
| ... | ... |
@@ -136,7 +136,7 @@ func (s *DockerSuite) TestApiStatsNetworkStatsVersioning(c *check.C) {
|
| 136 | 136 |
for i := 17; i <= 21; i++ {
|
| 137 | 137 |
apiVersion := fmt.Sprintf("v1.%d", i)
|
| 138 | 138 |
statsJSONBlob := getVersionedStats(c, id, apiVersion) |
| 139 |
- if version.Version(apiVersion).LessThan("v1.21") {
|
|
| 139 |
+ if versions.LessThan(apiVersion, "v1.21") {
|
|
| 140 | 140 |
c.Assert(jsonBlobHasLTv121NetworkStats(statsJSONBlob), checker.Equals, true, |
| 141 | 141 |
check.Commentf("Stats JSON blob from API %s %#v does not look like a <v1.21 API stats structure", apiVersion, statsJSONBlob))
|
| 142 | 142 |
} else {
|
| ... | ... |
@@ -49,7 +49,7 @@ func (s *DockerSuite) TestApiVersionStatusCode(c *check.C) {
|
| 49 | 49 |
} |
| 50 | 50 |
|
| 51 | 51 |
func (s *DockerSuite) TestApiClientVersionNewerThanServer(c *check.C) {
|
| 52 |
- v := strings.Split(api.DefaultVersion.String(), ".") |
|
| 52 |
+ v := strings.Split(api.DefaultVersion, ".") |
|
| 53 | 53 |
vMinInt, err := strconv.Atoi(v[1]) |
| 54 | 54 |
c.Assert(err, checker.IsNil) |
| 55 | 55 |
vMinInt++ |
| ... | ... |
@@ -64,7 +64,7 @@ func (s *DockerSuite) TestApiClientVersionNewerThanServer(c *check.C) {
|
| 64 | 64 |
} |
| 65 | 65 |
|
| 66 | 66 |
func (s *DockerSuite) TestApiClientVersionOldNotSupported(c *check.C) {
|
| 67 |
- v := strings.Split(api.MinVersion.String(), ".") |
|
| 67 |
+ v := strings.Split(api.MinVersion, ".") |
|
| 68 | 68 |
vMinInt, err := strconv.Atoi(v[1]) |
| 69 | 69 |
c.Assert(err, checker.IsNil) |
| 70 | 70 |
vMinInt-- |