From be248d18b5bcb01e094e7ac8cc7b79cb3c9209d4 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 26 Sep 2024 15:30:16 +0200 Subject: [PATCH] client.ContainerCreate: use container.CreateRequest instead of local type This function used a locally defined `configWrapper`, which was identical to the `container.CreateRequest`, with the exception of `CreateRequest` defining `omitempty` for HostConfig and NetworkingConfig, but this should not impact our use as the same type is used to handle the request on the daemon side. Signed-off-by: Sebastiaan van Stijn --- client/container_create.go | 8 +------- client/container_create_test.go | 2 +- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/client/container_create.go b/client/container_create.go index 5442d4267d..522a194c8c 100644 --- a/client/container_create.go +++ b/client/container_create.go @@ -12,12 +12,6 @@ import ( ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) -type configWrapper struct { - *container.Config - HostConfig *container.HostConfig - NetworkingConfig *network.NetworkingConfig -} - // ContainerCreate creates a new container based on the given configuration. // It can be associated with a name, but it's not mandatory. func (cli *Client) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *ocispec.Platform, containerName string) (container.CreateResponse, error) { @@ -74,7 +68,7 @@ func (cli *Client) ContainerCreate(ctx context.Context, config *container.Config query.Set("name", containerName) } - body := configWrapper{ + body := container.CreateRequest{ Config: config, HostConfig: hostConfig, NetworkingConfig: networkingConfig, diff --git a/client/container_create_test.go b/client/container_create_test.go index 284c9df208..46e8cf79e2 100644 --- a/client/container_create_test.go +++ b/client/container_create_test.go @@ -77,7 +77,7 @@ func TestContainerCreateWithName(t *testing.T) { func TestContainerCreateAutoRemove(t *testing.T) { autoRemoveValidator := func(expectedValue bool) func(req *http.Request) (*http.Response, error) { return func(req *http.Request) (*http.Response, error) { - var config configWrapper + var config container.CreateRequest if err := json.NewDecoder(req.Body).Decode(&config); err != nil { return nil, err