Skip to content

Commit 70459d6

Browse files
Merge pull request moby#27908 from Microsoft/jjh/fix27601APIVersion
Windows: Require REST 1.25 or later
2 parents 74bdacb + f811d5b commit 70459d6

10 files changed

Lines changed: 30 additions & 18 deletions

api/common.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ const (
2323
// DefaultVersion of Current REST API
2424
DefaultVersion string = "1.25"
2525

26-
// MinVersion represents Minimum REST API version supported
27-
MinVersion string = "1.12"
28-
2926
// NoBaseImageSpecifier is the symbol used by the FROM
3027
// command to specify that no base image is to be used.
3128
NoBaseImageSpecifier string = "scratch"

api/common_unix.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// +build !windows
2+
3+
package api
4+
5+
// MinVersion represents Minimum REST API version supported
6+
const MinVersion string = "1.12"

api/common_windows.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package api
2+
3+
// MinVersion represents Minimum REST API version supported
4+
const MinVersion string = "1.25"

integration-cli/docker_api_containers_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ func (s *DockerSuite) TestContainerAPICopyNotExistsAnyMore(c *check.C) {
976976
}
977977

978978
func (s *DockerSuite) TestContainerAPICopyPre124(c *check.C) {
979-
979+
testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later
980980
name := "test-container-api-copy"
981981
dockerCmd(c, "run", "--name", name, "busybox", "touch", "/test.txt")
982982

@@ -1006,6 +1006,7 @@ func (s *DockerSuite) TestContainerAPICopyPre124(c *check.C) {
10061006
}
10071007

10081008
func (s *DockerSuite) TestContainerAPICopyResourcePathEmptyPr124(c *check.C) {
1009+
testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later
10091010
name := "test-container-api-copy-resource-empty"
10101011
dockerCmd(c, "run", "--name", name, "busybox", "touch", "/test.txt")
10111012

@@ -1020,6 +1021,7 @@ func (s *DockerSuite) TestContainerAPICopyResourcePathEmptyPr124(c *check.C) {
10201021
}
10211022

10221023
func (s *DockerSuite) TestContainerAPICopyResourcePathNotFoundPre124(c *check.C) {
1024+
testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later
10231025
name := "test-container-api-copy-resource-not-found"
10241026
dockerCmd(c, "run", "--name", name, "busybox")
10251027

@@ -1034,6 +1036,7 @@ func (s *DockerSuite) TestContainerAPICopyResourcePathNotFoundPre124(c *check.C)
10341036
}
10351037

10361038
func (s *DockerSuite) TestContainerAPICopyContainerNotFoundPr124(c *check.C) {
1039+
testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later
10371040
postData := types.CopyConfig{
10381041
Resource: "/something",
10391042
}
@@ -1245,6 +1248,7 @@ func (s *DockerSuite) TestPostContainersCreateWithStringOrSliceCapAddDrop(c *che
12451248

12461249
// #14915
12471250
func (s *DockerSuite) TestContainerAPICreateNoHostConfig118(c *check.C) {
1251+
testRequires(c, DaemonIsLinux) // Windows only support 1.25 or later
12481252
config := struct {
12491253
Image string
12501254
}{"busybox"}

integration-cli/docker_api_exec_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ func (s *DockerSuite) TestExecAPIStart(c *check.C) {
9090
}
9191

9292
func (s *DockerSuite) TestExecAPIStartBackwardsCompatible(c *check.C) {
93+
testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later
9394
runSleepingContainer(c, "-d", "--name", "test")
9495
id := createExec(c, "test")
9596

integration-cli/docker_api_info_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ func (s *DockerSuite) TestInfoAPI(c *check.C) {
4040
}
4141

4242
func (s *DockerSuite) TestInfoAPIVersioned(c *check.C) {
43+
testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later
4344
endpoint := "/v1.20/info"
4445

4546
status, body, err := sockRequest("GET", endpoint, nil)

integration-cli/docker_api_inspect_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func (s *DockerSuite) TestInspectAPIContainerResponse(c *check.C) {
2828

2929
if daemonPlatform == "windows" {
3030
cases = []acase{
31-
{"v1.20", append(keysBase, "Mounts")},
31+
{"v1.25", append(keysBase, "Mounts")},
3232
}
3333

3434
} else {
@@ -84,23 +84,23 @@ func (s *DockerSuite) TestInspectAPIContainerVolumeDriver(c *check.C) {
8484

8585
cleanedContainerID := strings.TrimSpace(out)
8686

87-
body := getInspectBody(c, "v1.21", cleanedContainerID)
87+
body := getInspectBody(c, "v1.25", cleanedContainerID)
8888

8989
var inspectJSON map[string]interface{}
9090
err := json.Unmarshal(body, &inspectJSON)
91-
c.Assert(err, checker.IsNil, check.Commentf("Unable to unmarshal body for version 1.21"))
91+
c.Assert(err, checker.IsNil, check.Commentf("Unable to unmarshal body for version 1.25"))
9292

9393
config, ok := inspectJSON["Config"]
9494
c.Assert(ok, checker.True, check.Commentf("Unable to find 'Config'"))
9595
cfg := config.(map[string]interface{})
9696
_, ok = cfg["VolumeDriver"]
97-
c.Assert(ok, checker.False, check.Commentf("API version 1.21 expected to not include VolumeDriver in 'Config'"))
97+
c.Assert(ok, checker.False, check.Commentf("API version 1.25 expected to not include VolumeDriver in 'Config'"))
9898

9999
config, ok = inspectJSON["HostConfig"]
100100
c.Assert(ok, checker.True, check.Commentf("Unable to find 'HostConfig'"))
101101
cfg = config.(map[string]interface{})
102102
_, ok = cfg["VolumeDriver"]
103-
c.Assert(ok, checker.True, check.Commentf("API version 1.21 expected to include VolumeDriver in 'HostConfig'"))
103+
c.Assert(ok, checker.True, check.Commentf("API version 1.25 expected to include VolumeDriver in 'HostConfig'"))
104104
}
105105

106106
func (s *DockerSuite) TestInspectAPIImageResponse(c *check.C) {

integration-cli/docker_api_stats_test.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -162,20 +162,15 @@ func (s *DockerSuite) TestAPIStatsNetworkStats(c *check.C) {
162162
}
163163

164164
func (s *DockerSuite) TestAPIStatsNetworkStatsVersioning(c *check.C) {
165-
testRequires(c, SameHostDaemon)
165+
// Windows doesn't support API versions less than 1.25, so no point testing 1.17 .. 1.21
166+
testRequires(c, SameHostDaemon, DaemonIsLinux)
166167

167168
out, _ := runSleepingContainer(c)
168169
id := strings.TrimSpace(out)
169170
c.Assert(waitRun(id), checker.IsNil)
170171
wg := sync.WaitGroup{}
171172

172-
// Windows API versions prior to 1.21 doesn't support stats.
173-
startAt := 17
174-
if daemonPlatform == "windows" {
175-
startAt = 21
176-
}
177-
178-
for i := startAt; i <= 21; i++ {
173+
for i := 17; i <= 21; i++ {
179174
wg.Add(1)
180175
go func(i int) {
181176
defer wg.Done()

integration-cli/docker_api_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func (s *DockerSuite) TestAPIClientVersionOldNotSupported(c *check.C) {
7575
c.Assert(err, checker.IsNil)
7676
c.Assert(status, checker.Equals, http.StatusBadRequest)
7777
expected := fmt.Sprintf("client version %s is too old. Minimum supported API version is %s, please upgrade your client to a newer version", version, api.MinVersion)
78-
c.Assert(strings.TrimSpace(string(body)), checker.Equals, expected)
78+
c.Assert(strings.TrimSpace(string(body)), checker.Contains, expected)
7979
}
8080

8181
func (s *DockerSuite) TestAPIDockerAPIVersion(c *check.C) {
@@ -108,6 +108,9 @@ func (s *DockerSuite) TestAPIErrorJSON(c *check.C) {
108108
}
109109

110110
func (s *DockerSuite) TestAPIErrorPlainText(c *check.C) {
111+
// Windows requires API 1.25 or later. This test is validating a behaviour which was present
112+
// in v1.23, but changed in 1.24, hence not applicable on Windows. See apiVersionSupportsJSONErrors
113+
testRequires(c, DaemonIsLinux)
111114
httpResp, body, err := sockRequestRaw("POST", "/v1.23/containers/create", strings.NewReader(`{}`), "application/json")
112115
c.Assert(err, checker.IsNil)
113116
c.Assert(httpResp.StatusCode, checker.Equals, http.StatusInternalServerError)

integration-cli/docker_cli_kill_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ func (s *DockerSuite) TestKillWithInvalidSignal(c *check.C) {
116116
}
117117

118118
func (s *DockerSuite) TestKillStoppedContainerAPIPre120(c *check.C) {
119+
testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later
119120
runSleepingContainer(c, "--name", "docker-kill-test-api", "-d")
120121
dockerCmd(c, "stop", "docker-kill-test-api")
121122

0 commit comments

Comments
 (0)