Skip to content

Commit 564abf9

Browse files
committed
api: info: omit deprecated "Commit.Expected" fields on API >= 1.49
These fields were deprecated in ff191c5, and are now omitted. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent ba12b2d commit 564abf9

File tree

5 files changed

+42
-22
lines changed

5 files changed

+42
-22
lines changed

api/server/router/system/system_routes.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,13 @@ func (s *systemRouter) getInfo(ctx context.Context, w http.ResponseWriter, r *ht
116116
info.FirewallBackend = nil
117117
}
118118

119-
// TODO(thaJeztah): Expected commits are deprecated, and should no longer be set in API 1.49.
120-
info.ContainerdCommit.Expected = info.ContainerdCommit.ID //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.49.
121-
info.RuncCommit.Expected = info.RuncCommit.ID //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.49.
122-
info.InitCommit.Expected = info.InitCommit.ID //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.49.
123-
119+
if versions.LessThan(version, "1.49") {
120+
// Expected commits are omitted in API 1.49, but should still be
121+
// included in older versions.
122+
info.ContainerdCommit.Expected = info.ContainerdCommit.ID //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.49.
123+
info.RuncCommit.Expected = info.RuncCommit.ID //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.49.
124+
info.InitCommit.Expected = info.InitCommit.ID //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.49.
125+
}
124126
if versions.GreaterThanOrEqualTo(version, "1.42") {
125127
info.KernelMemory = false
126128
}

api/swagger.yaml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7186,13 +7186,6 @@ definitions:
71867186
description: "Actual commit ID of external tool."
71877187
type: "string"
71887188
example: "cfb82a876ecc11b5ca0977d1733adbe58599088a"
7189-
Expected:
7190-
description: |
7191-
Commit ID of external tool expected by dockerd as set at build time.
7192-
7193-
**Deprecated**: This field is deprecated and will be omitted in a API v1.49.
7194-
type: "string"
7195-
example: "2d41c047c83e09a6d61d464906feb2a2f3c52aa4"
71967189

71977190
SwarmInfo:
71987191
description: |

api/types/system/info.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ type Commit struct {
144144
// Expected is the commit ID of external tool expected by dockerd as set at build time.
145145
//
146146
// Deprecated: this field is no longer used in API v1.49, but kept for backward-compatibility with older API versions.
147-
Expected string
147+
Expected string `json:",omitempty"`
148148
}
149149

150150
// NetworkAddressPool is a temp struct used by [Info] struct.

docs/api/version-history.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ keywords: "API, Docker, rcli, REST, documentation"
2626
* Deprecated: The `AllowNondistributableArtifactsCIDRs` and `AllowNondistributableArtifactsHostnames`
2727
fields in the `RegistryConfig` struct in the `GET /info` response are omitted
2828
in API v1.49.
29+
* Deprecated: The `ContainerdCommit.Expected`, `RuncCommit.Expected`, and
30+
`InitCommit.Expected` fields in the `GET /info` endpoint were deprecated
31+
in API v1.48, and are now omitted in API v1.49.
2932

3033
## v1.48 API changes
3134

integration/system/info_linux_test.go

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,45 @@ package system // import "github.com/docker/docker/integration/system"
55
import (
66
"testing"
77

8+
"github.com/docker/docker/client"
89
"gotest.tools/v3/assert"
910
is "gotest.tools/v3/assert/cmp"
1011
)
1112

1213
func TestInfoBinaryCommits(t *testing.T) {
1314
ctx := setupTest(t)
14-
apiClient := testEnv.APIClient()
1515

16-
info, err := apiClient.Info(ctx)
17-
assert.NilError(t, err)
16+
t.Run("current", func(t *testing.T) {
17+
apiClient := testEnv.APIClient()
1818

19-
assert.Check(t, "N/A" != info.ContainerdCommit.ID)
20-
assert.Check(t, is.Equal(info.ContainerdCommit.Expected, info.ContainerdCommit.ID)) //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.49.
19+
info, err := apiClient.Info(ctx)
20+
assert.NilError(t, err)
2121

22-
assert.Check(t, "N/A" != info.InitCommit.ID)
23-
assert.Check(t, is.Equal(info.InitCommit.Expected, info.InitCommit.ID)) //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.49.
22+
assert.Check(t, "N/A" != info.ContainerdCommit.ID)
23+
assert.Check(t, is.Equal(info.ContainerdCommit.Expected, "")) //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.49.
2424

25-
assert.Check(t, "N/A" != info.RuncCommit.ID)
26-
assert.Check(t, is.Equal(info.RuncCommit.Expected, info.RuncCommit.ID)) //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.49.
25+
assert.Check(t, "N/A" != info.InitCommit.ID)
26+
assert.Check(t, is.Equal(info.InitCommit.Expected, "")) //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.49.
27+
28+
assert.Check(t, "N/A" != info.RuncCommit.ID)
29+
assert.Check(t, is.Equal(info.RuncCommit.Expected, "")) //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.49.
30+
})
31+
32+
// Expected commits are omitted in API 1.49, but should still be included in older versions.
33+
t.Run("1.48", func(t *testing.T) {
34+
apiClient, err := client.NewClientWithOpts(client.FromEnv, client.WithVersion("1.48"))
35+
assert.NilError(t, err)
36+
37+
info, err := apiClient.Info(ctx)
38+
assert.NilError(t, err)
39+
40+
assert.Check(t, "N/A" != info.ContainerdCommit.ID)
41+
assert.Check(t, is.Equal(info.ContainerdCommit.Expected, info.ContainerdCommit.ID)) //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.49.
42+
43+
assert.Check(t, "N/A" != info.InitCommit.ID)
44+
assert.Check(t, is.Equal(info.InitCommit.Expected, info.InitCommit.ID)) //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.49.
45+
46+
assert.Check(t, "N/A" != info.RuncCommit.ID)
47+
assert.Check(t, is.Equal(info.RuncCommit.Expected, info.RuncCommit.ID)) //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.49.
48+
})
2749
}

0 commit comments

Comments
 (0)