Skip to content

Commit c692af3

Browse files
committed
runconfig: deprecate ContainerConfigWrapper, move to api/types/container
Move the type to api/types/container.CreateRequest, together with other types used by the container API endpoints. The Decoder, and related validation code is kept in the runconfig package for now, but should likely be moved elsewhere (inside the API). Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent afdfe4f commit c692af3

3 files changed

Lines changed: 18 additions & 7 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package container
2+
3+
import "github.com/docker/docker/api/types/network"
4+
5+
// CreateRequest is the request message sent to the server for container
6+
// create calls. It is a config wrapper that holds the container [Config]
7+
// (portable) and the corresponding [HostConfig] (non-portable) and
8+
// [network.NetworkingConfig].
9+
type CreateRequest struct {
10+
*Config
11+
HostConfig *HostConfig `json:"HostConfig,omitempty"`
12+
NetworkingConfig *network.NetworkingConfig `json:"NetworkingConfig,omitempty"`
13+
}

runconfig/config.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ import (
1212

1313
// ContainerConfigWrapper is a Config wrapper that holds the container Config (portable)
1414
// and the corresponding HostConfig (non-portable).
15-
type ContainerConfigWrapper struct {
16-
*container.Config
17-
HostConfig *container.HostConfig `json:"HostConfig,omitempty"`
18-
NetworkingConfig *network.NetworkingConfig `json:"NetworkingConfig,omitempty"`
19-
}
15+
//
16+
// Deprecated: use [container.CreateRequest].
17+
type ContainerConfigWrapper = container.CreateRequest
2018

2119
// ContainerDecoder implements httputils.ContainerDecoder
2220
// calling DecodeContainerConfig.
@@ -43,7 +41,7 @@ func (r ContainerDecoder) DecodeConfig(src io.Reader) (*container.Config, *conta
4341
// Be aware this function is not checking whether the resulted structs are nil,
4442
// it's your business to do so
4543
func decodeContainerConfig(src io.Reader, si *sysinfo.SysInfo) (*container.Config, *container.HostConfig, *network.NetworkingConfig, error) {
46-
var w ContainerConfigWrapper
44+
var w container.CreateRequest
4745
if err := loadJSON(src, &w); err != nil {
4846
return nil, nil, nil, err
4947
}

runconfig/config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func callDecodeContainerConfigIsolation(isolation string) (*container.Config, *c
122122
b []byte
123123
err error
124124
)
125-
w := ContainerConfigWrapper{
125+
w := container.CreateRequest{
126126
Config: &container.Config{},
127127
HostConfig: &container.HostConfig{
128128
NetworkMode: "none",

0 commit comments

Comments
 (0)