Browse Source

update uses of container.ContainerCreateCreatedBody to CreateResponse

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 3 years ago
parent
commit
41b96bff55

+ 1 - 1
api/server/router/container/backend.go

@@ -32,7 +32,7 @@ type copyBackend interface {
 
 
 // stateBackend includes functions to implement to provide container state lifecycle functionality.
 // stateBackend includes functions to implement to provide container state lifecycle functionality.
 type stateBackend interface {
 type stateBackend interface {
-	ContainerCreate(config types.ContainerCreateConfig) (container.ContainerCreateCreatedBody, error)
+	ContainerCreate(config types.ContainerCreateConfig) (container.CreateResponse, error)
 	ContainerKill(name string, sig uint64) error
 	ContainerKill(name string, sig uint64) error
 	ContainerPause(name string) error
 	ContainerPause(name string) error
 	ContainerRename(oldName, newName string) error
 	ContainerRename(oldName, newName string) error

+ 1 - 1
builder/builder.go

@@ -61,7 +61,7 @@ type ExecBackend interface {
 	// ContainerAttachRaw attaches to container.
 	// ContainerAttachRaw attaches to container.
 	ContainerAttachRaw(cID string, stdin io.ReadCloser, stdout, stderr io.Writer, stream bool, attached chan struct{}) error
 	ContainerAttachRaw(cID string, stdin io.ReadCloser, stdout, stderr io.Writer, stream bool, attached chan struct{}) error
 	// ContainerCreateIgnoreImagesArgsEscaped creates a new Docker container and returns potential warnings
 	// ContainerCreateIgnoreImagesArgsEscaped creates a new Docker container and returns potential warnings
-	ContainerCreateIgnoreImagesArgsEscaped(config types.ContainerCreateConfig) (container.ContainerCreateCreatedBody, error)
+	ContainerCreateIgnoreImagesArgsEscaped(config types.ContainerCreateConfig) (container.CreateResponse, error)
 	// ContainerRm removes a container specified by `id`.
 	// ContainerRm removes a container specified by `id`.
 	ContainerRm(name string, config *types.ContainerRmConfig) error
 	ContainerRm(name string, config *types.ContainerRmConfig) error
 	// ContainerKill stops the container execution abruptly.
 	// ContainerKill stops the container execution abruptly.

+ 1 - 1
builder/dockerfile/containerbackend.go

@@ -28,7 +28,7 @@ func newContainerManager(docker builder.ExecBackend) *containerManager {
 }
 }
 
 
 // Create a container
 // Create a container
-func (c *containerManager) Create(runConfig *container.Config, hostConfig *container.HostConfig) (container.ContainerCreateCreatedBody, error) {
+func (c *containerManager) Create(runConfig *container.Config, hostConfig *container.HostConfig) (container.CreateResponse, error) {
 	container, err := c.backend.ContainerCreateIgnoreImagesArgsEscaped(types.ContainerCreateConfig{
 	container, err := c.backend.ContainerCreateIgnoreImagesArgsEscaped(types.ContainerCreateConfig{
 		Config:     runConfig,
 		Config:     runConfig,
 		HostConfig: hostConfig,
 		HostConfig: hostConfig,

+ 6 - 6
builder/dockerfile/dispatchers_test.go

@@ -470,12 +470,12 @@ func TestRunWithBuildArgs(t *testing.T) {
 			config: &container.Config{Cmd: origCmd},
 			config: &container.Config{Cmd: origCmd},
 		}, nil, nil
 		}, nil, nil
 	}
 	}
-	mockBackend.containerCreateFunc = func(config types.ContainerCreateConfig) (container.ContainerCreateCreatedBody, error) {
+	mockBackend.containerCreateFunc = func(config types.ContainerCreateConfig) (container.CreateResponse, error) {
 		// Check the runConfig.Cmd sent to create()
 		// Check the runConfig.Cmd sent to create()
 		assert.Check(t, is.DeepEqual(cmdWithShell, config.Config.Cmd))
 		assert.Check(t, is.DeepEqual(cmdWithShell, config.Config.Cmd))
 		assert.Check(t, is.Contains(config.Config.Env, "one=two"))
 		assert.Check(t, is.Contains(config.Config.Env, "one=two"))
 		assert.Check(t, is.DeepEqual(strslice.StrSlice{""}, config.Config.Entrypoint))
 		assert.Check(t, is.DeepEqual(strslice.StrSlice{""}, config.Config.Entrypoint))
-		return container.ContainerCreateCreatedBody{ID: "12345"}, nil
+		return container.CreateResponse{ID: "12345"}, nil
 	}
 	}
 	mockBackend.commitFunc = func(cfg backend.CommitConfig) (image.ID, error) {
 	mockBackend.commitFunc = func(cfg backend.CommitConfig) (image.ID, error) {
 		// Check the runConfig.Cmd sent to commit()
 		// Check the runConfig.Cmd sent to commit()
@@ -536,8 +536,8 @@ func TestRunIgnoresHealthcheck(t *testing.T) {
 			config: &container.Config{Cmd: origCmd},
 			config: &container.Config{Cmd: origCmd},
 		}, nil, nil
 		}, nil, nil
 	}
 	}
-	mockBackend.containerCreateFunc = func(config types.ContainerCreateConfig) (container.ContainerCreateCreatedBody, error) {
-		return container.ContainerCreateCreatedBody{ID: "12345"}, nil
+	mockBackend.containerCreateFunc = func(config types.ContainerCreateConfig) (container.CreateResponse, error) {
+		return container.CreateResponse{ID: "12345"}, nil
 	}
 	}
 	mockBackend.commitFunc = func(cfg backend.CommitConfig) (image.ID, error) {
 	mockBackend.commitFunc = func(cfg backend.CommitConfig) (image.ID, error) {
 		return "", nil
 		return "", nil
@@ -563,10 +563,10 @@ func TestRunIgnoresHealthcheck(t *testing.T) {
 	assert.NilError(t, dispatch(sb, cmd))
 	assert.NilError(t, dispatch(sb, cmd))
 	assert.Assert(t, sb.state.runConfig.Healthcheck != nil)
 	assert.Assert(t, sb.state.runConfig.Healthcheck != nil)
 
 
-	mockBackend.containerCreateFunc = func(config types.ContainerCreateConfig) (container.ContainerCreateCreatedBody, error) {
+	mockBackend.containerCreateFunc = func(config types.ContainerCreateConfig) (container.CreateResponse, error) {
 		// Check the Healthcheck is disabled.
 		// Check the Healthcheck is disabled.
 		assert.Check(t, is.DeepEqual([]string{"NONE"}, config.Config.Healthcheck.Test))
 		assert.Check(t, is.DeepEqual([]string{"NONE"}, config.Config.Healthcheck.Test))
-		return container.ContainerCreateCreatedBody{ID: "123456"}, nil
+		return container.CreateResponse{ID: "123456"}, nil
 	}
 	}
 
 
 	sb.state.buildArgs.AddArg("one", strPtr("two"))
 	sb.state.buildArgs.AddArg("one", strPtr("two"))

+ 3 - 3
builder/dockerfile/mockbackend_test.go

@@ -18,7 +18,7 @@ import (
 
 
 // MockBackend implements the builder.Backend interface for unit testing
 // MockBackend implements the builder.Backend interface for unit testing
 type MockBackend struct {
 type MockBackend struct {
-	containerCreateFunc func(config types.ContainerCreateConfig) (container.ContainerCreateCreatedBody, error)
+	containerCreateFunc func(config types.ContainerCreateConfig) (container.CreateResponse, error)
 	commitFunc          func(backend.CommitConfig) (image.ID, error)
 	commitFunc          func(backend.CommitConfig) (image.ID, error)
 	getImageFunc        func(string) (builder.Image, builder.ROLayer, error)
 	getImageFunc        func(string) (builder.Image, builder.ROLayer, error)
 	makeImageCacheFunc  func(cacheFrom []string) builder.ImageCache
 	makeImageCacheFunc  func(cacheFrom []string) builder.ImageCache
@@ -28,11 +28,11 @@ func (m *MockBackend) ContainerAttachRaw(cID string, stdin io.ReadCloser, stdout
 	return nil
 	return nil
 }
 }
 
 
-func (m *MockBackend) ContainerCreateIgnoreImagesArgsEscaped(config types.ContainerCreateConfig) (container.ContainerCreateCreatedBody, error) {
+func (m *MockBackend) ContainerCreateIgnoreImagesArgsEscaped(config types.ContainerCreateConfig) (container.CreateResponse, error) {
 	if m.containerCreateFunc != nil {
 	if m.containerCreateFunc != nil {
 		return m.containerCreateFunc(config)
 		return m.containerCreateFunc(config)
 	}
 	}
-	return container.ContainerCreateCreatedBody{}, nil
+	return container.CreateResponse{}, nil
 }
 }
 
 
 func (m *MockBackend) ContainerRm(name string, config *types.ContainerRmConfig) error {
 func (m *MockBackend) ContainerRm(name string, config *types.ContainerRmConfig) error {

+ 2 - 2
client/container_create.go

@@ -20,8 +20,8 @@ type configWrapper struct {
 
 
 // ContainerCreate creates a new container based on the given configuration.
 // ContainerCreate creates a new container based on the given configuration.
 // It can be associated with a name, but it's not mandatory.
 // 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 *specs.Platform, containerName string) (container.ContainerCreateCreatedBody, error) {
-	var response container.ContainerCreateCreatedBody
+func (cli *Client) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *specs.Platform, containerName string) (container.CreateResponse, error) {
+	var response container.CreateResponse
 
 
 	if err := cli.NewVersionError("1.25", "stop timeout"); config != nil && config.StopTimeout != nil && err != nil {
 	if err := cli.NewVersionError("1.25", "stop timeout"); config != nil && config.StopTimeout != nil && err != nil {
 		return response, err
 		return response, err

+ 2 - 2
client/container_create_test.go

@@ -54,7 +54,7 @@ func TestContainerCreateWithName(t *testing.T) {
 			if name != "container_name" {
 			if name != "container_name" {
 				return nil, fmt.Errorf("container name not set in URL query properly. Expected `container_name`, got %s", name)
 				return nil, fmt.Errorf("container name not set in URL query properly. Expected `container_name`, got %s", name)
 			}
 			}
-			b, err := json.Marshal(container.ContainerCreateCreatedBody{
+			b, err := json.Marshal(container.CreateResponse{
 				ID: "container_id",
 				ID: "container_id",
 			})
 			})
 			if err != nil {
 			if err != nil {
@@ -89,7 +89,7 @@ func TestContainerCreateAutoRemove(t *testing.T) {
 			if config.HostConfig.AutoRemove != expectedValue {
 			if config.HostConfig.AutoRemove != expectedValue {
 				return nil, fmt.Errorf("expected AutoRemove to be %v, got %v", expectedValue, config.HostConfig.AutoRemove)
 				return nil, fmt.Errorf("expected AutoRemove to be %v, got %v", expectedValue, config.HostConfig.AutoRemove)
 			}
 			}
-			b, err := json.Marshal(container.ContainerCreateCreatedBody{
+			b, err := json.Marshal(container.CreateResponse{
 				ID: "container_id",
 				ID: "container_id",
 			})
 			})
 			if err != nil {
 			if err != nil {

+ 1 - 1
client/interface.go

@@ -47,7 +47,7 @@ type CommonAPIClient interface {
 type ContainerAPIClient interface {
 type ContainerAPIClient interface {
 	ContainerAttach(ctx context.Context, container string, options types.ContainerAttachOptions) (types.HijackedResponse, error)
 	ContainerAttach(ctx context.Context, container string, options types.ContainerAttachOptions) (types.HijackedResponse, error)
 	ContainerCommit(ctx context.Context, container string, options types.ContainerCommitOptions) (types.IDResponse, error)
 	ContainerCommit(ctx context.Context, container string, options types.ContainerCommitOptions) (types.IDResponse, error)
-	ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *specs.Platform, containerName string) (container.ContainerCreateCreatedBody, error)
+	ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *specs.Platform, containerName string) (container.CreateResponse, error)
 	ContainerDiff(ctx context.Context, container string) ([]container.ContainerChangeResponseItem, error)
 	ContainerDiff(ctx context.Context, container string) ([]container.ContainerChangeResponseItem, error)
 	ContainerExecAttach(ctx context.Context, execID string, config types.ExecStartCheck) (types.HijackedResponse, error)
 	ContainerExecAttach(ctx context.Context, execID string, config types.ExecStartCheck) (types.HijackedResponse, error)
 	ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error)
 	ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error)

+ 1 - 1
daemon/cluster/executor/backend.go

@@ -34,7 +34,7 @@ type Backend interface {
 	FindNetwork(idName string) (libnetwork.Network, error)
 	FindNetwork(idName string) (libnetwork.Network, error)
 	SetupIngress(clustertypes.NetworkCreateRequest, string) (<-chan struct{}, error)
 	SetupIngress(clustertypes.NetworkCreateRequest, string) (<-chan struct{}, error)
 	ReleaseIngress() (<-chan struct{}, error)
 	ReleaseIngress() (<-chan struct{}, error)
-	CreateManagedContainer(config types.ContainerCreateConfig) (container.ContainerCreateCreatedBody, error)
+	CreateManagedContainer(config types.ContainerCreateConfig) (container.CreateResponse, error)
 	ContainerStart(name string, hostConfig *container.HostConfig, checkpoint string, checkpointDir string) error
 	ContainerStart(name string, hostConfig *container.HostConfig, checkpoint string, checkpointDir string) error
 	ContainerStop(ctx context.Context, name string, config container.StopOptions) error
 	ContainerStop(ctx context.Context, name string, config container.StopOptions) error
 	ContainerLogs(ctx context.Context, name string, config *types.ContainerLogsOptions) (msgs <-chan *backend.LogMessage, tty bool, err error)
 	ContainerLogs(ctx context.Context, name string, config *types.ContainerLogsOptions) (msgs <-chan *backend.LogMessage, tty bool, err error)

+ 1 - 1
daemon/cluster/executor/container/adapter.go

@@ -283,7 +283,7 @@ func (c *containerAdapter) waitForDetach(ctx context.Context) error {
 }
 }
 
 
 func (c *containerAdapter) create(ctx context.Context) error {
 func (c *containerAdapter) create(ctx context.Context) error {
-	var cr containertypes.ContainerCreateCreatedBody
+	var cr containertypes.CreateResponse
 	var err error
 	var err error
 	if cr, err = c.backend.CreateManagedContainer(types.ContainerCreateConfig{
 	if cr, err = c.backend.CreateManagedContainer(types.ContainerCreateConfig{
 		Name:       c.container.name(),
 		Name:       c.container.name(),

+ 10 - 10
daemon/create.go

@@ -32,7 +32,7 @@ type createOpts struct {
 }
 }
 
 
 // CreateManagedContainer creates a container that is managed by a Service
 // CreateManagedContainer creates a container that is managed by a Service
-func (daemon *Daemon) CreateManagedContainer(params types.ContainerCreateConfig) (containertypes.ContainerCreateCreatedBody, error) {
+func (daemon *Daemon) CreateManagedContainer(params types.ContainerCreateConfig) (containertypes.CreateResponse, error) {
 	return daemon.containerCreate(createOpts{
 	return daemon.containerCreate(createOpts{
 		params:                  params,
 		params:                  params,
 		managed:                 true,
 		managed:                 true,
@@ -40,7 +40,7 @@ func (daemon *Daemon) CreateManagedContainer(params types.ContainerCreateConfig)
 }
 }
 
 
 // ContainerCreate creates a regular container
 // ContainerCreate creates a regular container
-func (daemon *Daemon) ContainerCreate(params types.ContainerCreateConfig) (containertypes.ContainerCreateCreatedBody, error) {
+func (daemon *Daemon) ContainerCreate(params types.ContainerCreateConfig) (containertypes.CreateResponse, error) {
 	return daemon.containerCreate(createOpts{
 	return daemon.containerCreate(createOpts{
 		params:                  params,
 		params:                  params,
 		managed:                 false,
 		managed:                 false,
@@ -49,22 +49,22 @@ func (daemon *Daemon) ContainerCreate(params types.ContainerCreateConfig) (conta
 
 
 // ContainerCreateIgnoreImagesArgsEscaped creates a regular container. This is called from the builder RUN case
 // ContainerCreateIgnoreImagesArgsEscaped creates a regular container. This is called from the builder RUN case
 // and ensures that we do not take the images ArgsEscaped
 // and ensures that we do not take the images ArgsEscaped
-func (daemon *Daemon) ContainerCreateIgnoreImagesArgsEscaped(params types.ContainerCreateConfig) (containertypes.ContainerCreateCreatedBody, error) {
+func (daemon *Daemon) ContainerCreateIgnoreImagesArgsEscaped(params types.ContainerCreateConfig) (containertypes.CreateResponse, error) {
 	return daemon.containerCreate(createOpts{
 	return daemon.containerCreate(createOpts{
 		params:                  params,
 		params:                  params,
 		managed:                 false,
 		managed:                 false,
 		ignoreImagesArgsEscaped: true})
 		ignoreImagesArgsEscaped: true})
 }
 }
 
 
-func (daemon *Daemon) containerCreate(opts createOpts) (containertypes.ContainerCreateCreatedBody, error) {
+func (daemon *Daemon) containerCreate(opts createOpts) (containertypes.CreateResponse, error) {
 	start := time.Now()
 	start := time.Now()
 	if opts.params.Config == nil {
 	if opts.params.Config == nil {
-		return containertypes.ContainerCreateCreatedBody{}, errdefs.InvalidParameter(errors.New("Config cannot be empty in order to create a container"))
+		return containertypes.CreateResponse{}, errdefs.InvalidParameter(errors.New("Config cannot be empty in order to create a container"))
 	}
 	}
 
 
 	warnings, err := daemon.verifyContainerSettings(opts.params.HostConfig, opts.params.Config, false)
 	warnings, err := daemon.verifyContainerSettings(opts.params.HostConfig, opts.params.Config, false)
 	if err != nil {
 	if err != nil {
-		return containertypes.ContainerCreateCreatedBody{Warnings: warnings}, errdefs.InvalidParameter(err)
+		return containertypes.CreateResponse{Warnings: warnings}, errdefs.InvalidParameter(err)
 	}
 	}
 
 
 	if opts.params.Platform == nil && opts.params.Config.Image != "" {
 	if opts.params.Platform == nil && opts.params.Config.Image != "" {
@@ -84,7 +84,7 @@ func (daemon *Daemon) containerCreate(opts createOpts) (containertypes.Container
 
 
 	err = verifyNetworkingConfig(opts.params.NetworkingConfig)
 	err = verifyNetworkingConfig(opts.params.NetworkingConfig)
 	if err != nil {
 	if err != nil {
-		return containertypes.ContainerCreateCreatedBody{Warnings: warnings}, errdefs.InvalidParameter(err)
+		return containertypes.CreateResponse{Warnings: warnings}, errdefs.InvalidParameter(err)
 	}
 	}
 
 
 	if opts.params.HostConfig == nil {
 	if opts.params.HostConfig == nil {
@@ -92,12 +92,12 @@ func (daemon *Daemon) containerCreate(opts createOpts) (containertypes.Container
 	}
 	}
 	err = daemon.adaptContainerSettings(opts.params.HostConfig, opts.params.AdjustCPUShares)
 	err = daemon.adaptContainerSettings(opts.params.HostConfig, opts.params.AdjustCPUShares)
 	if err != nil {
 	if err != nil {
-		return containertypes.ContainerCreateCreatedBody{Warnings: warnings}, errdefs.InvalidParameter(err)
+		return containertypes.CreateResponse{Warnings: warnings}, errdefs.InvalidParameter(err)
 	}
 	}
 
 
 	ctr, err := daemon.create(opts)
 	ctr, err := daemon.create(opts)
 	if err != nil {
 	if err != nil {
-		return containertypes.ContainerCreateCreatedBody{Warnings: warnings}, err
+		return containertypes.CreateResponse{Warnings: warnings}, err
 	}
 	}
 	containerActions.WithValues("create").UpdateSince(start)
 	containerActions.WithValues("create").UpdateSince(start)
 
 
@@ -105,7 +105,7 @@ func (daemon *Daemon) containerCreate(opts createOpts) (containertypes.Container
 		warnings = make([]string, 0) // Create an empty slice to avoid https://github.com/moby/moby/issues/38222
 		warnings = make([]string, 0) // Create an empty slice to avoid https://github.com/moby/moby/issues/38222
 	}
 	}
 
 
-	return containertypes.ContainerCreateCreatedBody{ID: ctr.ID, Warnings: warnings}, nil
+	return containertypes.CreateResponse{ID: ctr.ID, Warnings: warnings}, nil
 }
 }
 
 
 // Create creates a new container from the given configuration with a given name.
 // Create creates a new container from the given configuration with a given name.

+ 1 - 1
integration/internal/container/container.go

@@ -24,7 +24,7 @@ type TestContainerConfig struct {
 }
 }
 
 
 // create creates a container with the specified options
 // create creates a container with the specified options
-func create(ctx context.Context, t *testing.T, client client.APIClient, ops ...func(*TestContainerConfig)) (container.ContainerCreateCreatedBody, error) {
+func create(ctx context.Context, t *testing.T, client client.APIClient, ops ...func(*TestContainerConfig)) (container.CreateResponse, error) {
 	t.Helper()
 	t.Helper()
 	cmd := []string{"top"}
 	cmd := []string{"top"}
 	if runtime.GOOS == "windows" {
 	if runtime.GOOS == "windows" {