update uses of container.ContainerCreateCreatedBody to CreateResponse
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
3bb2d0026b
commit
41b96bff55
12 changed files with 30 additions and 30 deletions
|
@ -32,7 +32,7 @@ type copyBackend interface {
|
|||
|
||||
// stateBackend includes functions to implement to provide container state lifecycle functionality.
|
||||
type stateBackend interface {
|
||||
ContainerCreate(config types.ContainerCreateConfig) (container.ContainerCreateCreatedBody, error)
|
||||
ContainerCreate(config types.ContainerCreateConfig) (container.CreateResponse, error)
|
||||
ContainerKill(name string, sig uint64) error
|
||||
ContainerPause(name string) error
|
||||
ContainerRename(oldName, newName string) error
|
||||
|
|
|
@ -61,7 +61,7 @@ type ExecBackend interface {
|
|||
// ContainerAttachRaw attaches to container.
|
||||
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(config types.ContainerCreateConfig) (container.ContainerCreateCreatedBody, error)
|
||||
ContainerCreateIgnoreImagesArgsEscaped(config types.ContainerCreateConfig) (container.CreateResponse, error)
|
||||
// ContainerRm removes a container specified by `id`.
|
||||
ContainerRm(name string, config *types.ContainerRmConfig) error
|
||||
// ContainerKill stops the container execution abruptly.
|
||||
|
|
|
@ -28,7 +28,7 @@ func newContainerManager(docker builder.ExecBackend) *containerManager {
|
|||
}
|
||||
|
||||
// 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{
|
||||
Config: runConfig,
|
||||
HostConfig: hostConfig,
|
||||
|
|
|
@ -470,12 +470,12 @@ func TestRunWithBuildArgs(t *testing.T) {
|
|||
config: &container.Config{Cmd: origCmd},
|
||||
}, 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()
|
||||
assert.Check(t, is.DeepEqual(cmdWithShell, config.Config.Cmd))
|
||||
assert.Check(t, is.Contains(config.Config.Env, "one=two"))
|
||||
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) {
|
||||
// Check the runConfig.Cmd sent to commit()
|
||||
|
@ -536,8 +536,8 @@ func TestRunIgnoresHealthcheck(t *testing.T) {
|
|||
config: &container.Config{Cmd: origCmd},
|
||||
}, 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) {
|
||||
return "", nil
|
||||
|
@ -563,10 +563,10 @@ func TestRunIgnoresHealthcheck(t *testing.T) {
|
|||
assert.NilError(t, dispatch(sb, cmd))
|
||||
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.
|
||||
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"))
|
||||
|
|
|
@ -18,7 +18,7 @@ import (
|
|||
|
||||
// MockBackend implements the builder.Backend interface for unit testing
|
||||
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)
|
||||
getImageFunc func(string) (builder.Image, builder.ROLayer, error)
|
||||
makeImageCacheFunc func(cacheFrom []string) builder.ImageCache
|
||||
|
@ -28,11 +28,11 @@ func (m *MockBackend) ContainerAttachRaw(cID string, stdin io.ReadCloser, stdout
|
|||
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 {
|
||||
return m.containerCreateFunc(config)
|
||||
}
|
||||
return container.ContainerCreateCreatedBody{}, nil
|
||||
return container.CreateResponse{}, nil
|
||||
}
|
||||
|
||||
func (m *MockBackend) ContainerRm(name string, config *types.ContainerRmConfig) error {
|
||||
|
|
|
@ -20,8 +20,8 @@ type configWrapper struct {
|
|||
|
||||
// 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 *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 {
|
||||
return response, err
|
||||
|
|
|
@ -54,7 +54,7 @@ func TestContainerCreateWithName(t *testing.T) {
|
|||
if name != "container_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",
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -89,7 +89,7 @@ func TestContainerCreateAutoRemove(t *testing.T) {
|
|||
if config.HostConfig.AutoRemove != expectedValue {
|
||||
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",
|
||||
})
|
||||
if err != nil {
|
||||
|
|
|
@ -47,7 +47,7 @@ type CommonAPIClient interface {
|
|||
type ContainerAPIClient interface {
|
||||
ContainerAttach(ctx context.Context, container string, options types.ContainerAttachOptions) (types.HijackedResponse, 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)
|
||||
ContainerExecAttach(ctx context.Context, execID string, config types.ExecStartCheck) (types.HijackedResponse, error)
|
||||
ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error)
|
||||
|
|
|
@ -34,7 +34,7 @@ type Backend interface {
|
|||
FindNetwork(idName string) (libnetwork.Network, error)
|
||||
SetupIngress(clustertypes.NetworkCreateRequest, string) (<-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
|
||||
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)
|
||||
|
|
|
@ -283,7 +283,7 @@ func (c *containerAdapter) waitForDetach(ctx context.Context) error {
|
|||
}
|
||||
|
||||
func (c *containerAdapter) create(ctx context.Context) error {
|
||||
var cr containertypes.ContainerCreateCreatedBody
|
||||
var cr containertypes.CreateResponse
|
||||
var err error
|
||||
if cr, err = c.backend.CreateManagedContainer(types.ContainerCreateConfig{
|
||||
Name: c.container.name(),
|
||||
|
|
|
@ -32,7 +32,7 @@ type createOpts struct {
|
|||
}
|
||||
|
||||
// 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{
|
||||
params: params,
|
||||
managed: true,
|
||||
|
@ -40,7 +40,7 @@ func (daemon *Daemon) CreateManagedContainer(params types.ContainerCreateConfig)
|
|||
}
|
||||
|
||||
// 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{
|
||||
params: params,
|
||||
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
|
||||
// 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{
|
||||
params: params,
|
||||
managed: false,
|
||||
ignoreImagesArgsEscaped: true})
|
||||
}
|
||||
|
||||
func (daemon *Daemon) containerCreate(opts createOpts) (containertypes.ContainerCreateCreatedBody, error) {
|
||||
func (daemon *Daemon) containerCreate(opts createOpts) (containertypes.CreateResponse, error) {
|
||||
start := time.Now()
|
||||
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)
|
||||
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 != "" {
|
||||
|
@ -84,7 +84,7 @@ func (daemon *Daemon) containerCreate(opts createOpts) (containertypes.Container
|
|||
|
||||
err = verifyNetworkingConfig(opts.params.NetworkingConfig)
|
||||
if err != nil {
|
||||
return containertypes.ContainerCreateCreatedBody{Warnings: warnings}, errdefs.InvalidParameter(err)
|
||||
return containertypes.CreateResponse{Warnings: warnings}, errdefs.InvalidParameter(err)
|
||||
}
|
||||
|
||||
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)
|
||||
if err != nil {
|
||||
return containertypes.ContainerCreateCreatedBody{Warnings: warnings}, errdefs.InvalidParameter(err)
|
||||
return containertypes.CreateResponse{Warnings: warnings}, errdefs.InvalidParameter(err)
|
||||
}
|
||||
|
||||
ctr, err := daemon.create(opts)
|
||||
if err != nil {
|
||||
return containertypes.ContainerCreateCreatedBody{Warnings: warnings}, err
|
||||
return containertypes.CreateResponse{Warnings: warnings}, err
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
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.
|
||||
|
|
|
@ -24,7 +24,7 @@ type TestContainerConfig struct {
|
|||
}
|
||||
|
||||
// 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()
|
||||
cmd := []string{"top"}
|
||||
if runtime.GOOS == "windows" {
|
||||
|
|
Loading…
Reference in a new issue