Skip to content

Commit 1fc9236

Browse files
committed
api/types: deprecate ContainerJSONBase.Node, ContainerNode
The `Node` field and related `ContainerNode` type were used by the classic (standalone) Swarm API. API documentation for this field was already removed in 234d5a7 (API 1.41 / docker 20.10), and as the Docker Engine didn't implement these fields for the Swarm API, it would always have been unset / nil. Let's do a quick deprecation, and remove it on the next release. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent ff1e2c0 commit 1fc9236

3 files changed

Lines changed: 15 additions & 65 deletions

File tree

api/types/types.go

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -245,18 +245,6 @@ type ContainerState struct {
245245
Health *Health `json:",omitempty"`
246246
}
247247

248-
// ContainerNode stores information about the node that a container
249-
// is running on. It's only used by the Docker Swarm standalone API
250-
type ContainerNode struct {
251-
ID string
252-
IPAddress string `json:"IP"`
253-
Addr string
254-
Name string
255-
Cpus int
256-
Memory int64
257-
Labels map[string]string
258-
}
259-
260248
// ContainerJSONBase contains response of Engine API:
261249
// GET "/containers/{name:.*}/json"
262250
type ContainerJSONBase struct {
@@ -270,7 +258,7 @@ type ContainerJSONBase struct {
270258
HostnamePath string
271259
HostsPath string
272260
LogPath string
273-
Node *ContainerNode `json:",omitempty"` // Node is only propagated by Docker Swarm standalone API
261+
Node *ContainerNode `json:",omitempty"` // Deprecated: Node was only propagated by Docker Swarm standalone API. It sill be removed in the next release.
274262
Name string
275263
RestartCount int
276264
Driver string

api/types/types_deprecated.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,17 @@ type ImageImportSource image.ImportSource
194194
//
195195
// Deprecated: use [image.LoadResponse].
196196
type ImageLoadResponse = image.LoadResponse
197+
198+
// ContainerNode stores information about the node that a container
199+
// is running on. It's only used by the Docker Swarm standalone API.
200+
//
201+
// Deprecated: ContainerNode was used for the classic Docker Swarm standalone API. It will be removed in the next release.
202+
type ContainerNode struct {
203+
ID string
204+
IPAddress string `json:"IP"`
205+
Addr string
206+
Name string
207+
Cpus int
208+
Memory int64
209+
Labels map[string]string
210+
}

client/container_inspect_test.go

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -83,55 +83,3 @@ func TestContainerInspect(t *testing.T) {
8383
t.Fatalf("expected `name`, got %s", r.Name)
8484
}
8585
}
86-
87-
// TestContainerInspectNode tests that the "Node" field is included in the "inspect"
88-
// output. This information is only present when connected to a Swarm standalone API.
89-
func TestContainerInspectNode(t *testing.T) {
90-
client := &Client{
91-
client: newMockClient(func(req *http.Request) (*http.Response, error) {
92-
content, err := json.Marshal(types.ContainerJSON{
93-
ContainerJSONBase: &types.ContainerJSONBase{
94-
ID: "container_id",
95-
Image: "image",
96-
Name: "name",
97-
Node: &types.ContainerNode{
98-
ID: "container_node_id",
99-
Addr: "container_node",
100-
Labels: map[string]string{"foo": "bar"},
101-
},
102-
},
103-
})
104-
if err != nil {
105-
return nil, err
106-
}
107-
return &http.Response{
108-
StatusCode: http.StatusOK,
109-
Body: io.NopCloser(bytes.NewReader(content)),
110-
}, nil
111-
}),
112-
}
113-
114-
r, err := client.ContainerInspect(context.Background(), "container_id")
115-
if err != nil {
116-
t.Fatal(err)
117-
}
118-
if r.ID != "container_id" {
119-
t.Fatalf("expected `container_id`, got %s", r.ID)
120-
}
121-
if r.Image != "image" {
122-
t.Fatalf("expected `image`, got %s", r.Image)
123-
}
124-
if r.Name != "name" {
125-
t.Fatalf("expected `name`, got %s", r.Name)
126-
}
127-
if r.Node.ID != "container_node_id" {
128-
t.Fatalf("expected `container_node_id`, got %s", r.Node.ID)
129-
}
130-
if r.Node.Addr != "container_node" {
131-
t.Fatalf("expected `container_node`, got %s", r.Node.Addr)
132-
}
133-
foo, ok := r.Node.Labels["foo"]
134-
if foo != "bar" || !ok {
135-
t.Fatalf("expected `bar` for label `foo`")
136-
}
137-
}

0 commit comments

Comments
 (0)