Skip to content

Commit 9498d89

Browse files
committed
api/types: move ContainerCommitOptions to api/types/container
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 30f09b4 commit 9498d89

11 files changed

Lines changed: 34 additions & 25 deletions

File tree

api/types/client.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,6 @@ import (
1111
units "github.com/docker/go-units"
1212
)
1313

14-
// ContainerCommitOptions holds parameters to commit changes into a container.
15-
type ContainerCommitOptions struct {
16-
Reference string
17-
Comment string
18-
Author string
19-
Changes []string
20-
Pause bool
21-
Config *container.Config
22-
}
23-
2414
// ContainerExecInspect holds information returned by exec inspect.
2515
type ContainerExecInspect struct {
2616
ExecID string `json:"ID"`

api/types/container/options.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,13 @@ type AttachOptions struct {
1717
DetachKeys string
1818
Logs bool
1919
}
20+
21+
// CommitOptions holds parameters to commit changes into a container.
22+
type CommitOptions struct {
23+
Reference string
24+
Comment string
25+
Author string
26+
Changes []string
27+
Pause bool
28+
Config *Config
29+
}

api/types/types_deprecated.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ type ResizeOptions = container.ResizeOptions
104104
// Deprecated: use [container.AttachOptions].
105105
type ContainerAttachOptions = container.AttachOptions
106106

107+
// ContainerCommitOptions holds parameters to commit changes into a container.
108+
//
109+
// Deprecated: use [container.CommitOptions].
110+
type ContainerCommitOptions = container.CommitOptions
111+
107112
// DecodeSecurityOptions decodes a security options string slice to a type safe
108113
// [system.SecurityOpt].
109114
//

client/container_commit.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ import (
88

99
"github.com/distribution/reference"
1010
"github.com/docker/docker/api/types"
11+
"github.com/docker/docker/api/types/container"
1112
)
1213

1314
// ContainerCommit applies changes to a container and creates a new tagged image.
14-
func (cli *Client) ContainerCommit(ctx context.Context, container string, options types.ContainerCommitOptions) (types.IDResponse, error) {
15+
func (cli *Client) ContainerCommit(ctx context.Context, container string, options container.CommitOptions) (types.IDResponse, error) {
1516
var repository, tag string
1617
if options.Reference != "" {
1718
ref, err := reference.ParseNormalizedNamed(options.Reference)

client/container_commit_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"testing"
1212

1313
"github.com/docker/docker/api/types"
14+
"github.com/docker/docker/api/types/container"
1415
"github.com/docker/docker/errdefs"
1516
"gotest.tools/v3/assert"
1617
is "gotest.tools/v3/assert/cmp"
@@ -20,7 +21,7 @@ func TestContainerCommitError(t *testing.T) {
2021
client := &Client{
2122
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
2223
}
23-
_, err := client.ContainerCommit(context.Background(), "nothing", types.ContainerCommitOptions{})
24+
_, err := client.ContainerCommit(context.Background(), "nothing", container.CommitOptions{})
2425
assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
2526
}
2627

@@ -81,7 +82,7 @@ func TestContainerCommit(t *testing.T) {
8182
}),
8283
}
8384

84-
r, err := client.ContainerCommit(context.Background(), expectedContainerID, types.ContainerCommitOptions{
85+
r, err := client.ContainerCommit(context.Background(), expectedContainerID, container.CommitOptions{
8586
Reference: specifiedReference,
8687
Comment: expectedComment,
8788
Author: expectedAuthor,

client/interface.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ type CommonAPIClient interface {
4747
// ContainerAPIClient defines API client methods for the containers
4848
type ContainerAPIClient interface {
4949
ContainerAttach(ctx context.Context, container string, options container.AttachOptions) (types.HijackedResponse, error)
50-
ContainerCommit(ctx context.Context, container string, options types.ContainerCommitOptions) (types.IDResponse, error)
50+
ContainerCommit(ctx context.Context, container string, options container.CommitOptions) (types.IDResponse, error)
5151
ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *ocispec.Platform, containerName string) (container.CreateResponse, error)
5252
ContainerDiff(ctx context.Context, container string) ([]container.FilesystemChange, error)
5353
ContainerExecAttach(ctx context.Context, execID string, config types.ExecStartCheck) (types.HijackedResponse, error)

integration-cli/docker_api_containers_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ func (s *DockerAPISuite) TestContainerAPICommit(c *testing.T) {
454454
assert.NilError(c, err)
455455
defer apiClient.Close()
456456

457-
options := types.ContainerCommitOptions{
457+
options := container.CommitOptions{
458458
Reference: "testcontainerapicommit:testtag",
459459
}
460460

@@ -480,7 +480,7 @@ func (s *DockerAPISuite) TestContainerAPICommitWithLabelInConfig(c *testing.T) {
480480
Labels: map[string]string{"key1": "value1", "key2": "value2"},
481481
}
482482

483-
options := types.ContainerCommitOptions{
483+
options := container.CommitOptions{
484484
Reference: "testcontainerapicommitwithconfig",
485485
Config: &config,
486486
}

integration/image/commit_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"strings"
55
"testing"
66

7-
"github.com/docker/docker/api/types"
7+
containertypes "github.com/docker/docker/api/types/container"
88
"github.com/docker/docker/api/types/versions"
99
"github.com/docker/docker/integration/internal/container"
1010
"gotest.tools/v3/assert"
@@ -22,7 +22,7 @@ func TestCommitInheritsEnv(t *testing.T) {
2222
cID1 := container.Create(ctx, t, client)
2323
imgName := strings.ToLower(t.Name())
2424

25-
commitResp1, err := client.ContainerCommit(ctx, cID1, types.ContainerCommitOptions{
25+
commitResp1, err := client.ContainerCommit(ctx, cID1, containertypes.CommitOptions{
2626
Changes: []string{"ENV PATH=/bin"},
2727
Reference: imgName,
2828
})
@@ -36,7 +36,7 @@ func TestCommitInheritsEnv(t *testing.T) {
3636

3737
cID2 := container.Create(ctx, t, client, container.WithImage(image1.ID))
3838

39-
commitResp2, err := client.ContainerCommit(ctx, cID2, types.ContainerCommitOptions{
39+
commitResp2, err := client.ContainerCommit(ctx, cID2, containertypes.CommitOptions{
4040
Changes: []string{"ENV PATH=/usr/bin:$PATH"},
4141
Reference: imgName,
4242
})

integration/image/list_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"time"
88

99
"github.com/docker/docker/api/types"
10+
containertypes "github.com/docker/docker/api/types/container"
1011
"github.com/docker/docker/api/types/filters"
1112
"github.com/docker/docker/api/types/versions"
1213
"github.com/docker/docker/integration/internal/container"
@@ -70,7 +71,7 @@ func TestImagesFilterBeforeSince(t *testing.T) {
7071
// Make really really sure each image has a distinct timestamp.
7172
time.Sleep(time.Millisecond)
7273
}
73-
id, err := client.ContainerCommit(ctx, ctr, types.ContainerCommitOptions{Reference: fmt.Sprintf("%s:v%d", name, i)})
74+
id, err := client.ContainerCommit(ctx, ctr, containertypes.CommitOptions{Reference: fmt.Sprintf("%s:v%d", name, i)})
7475
assert.NilError(t, err)
7576
imgs[i] = id.ID
7677
}

integration/image/remove_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"testing"
66

77
"github.com/docker/docker/api/types"
8+
containertypes "github.com/docker/docker/api/types/container"
89
"github.com/docker/docker/errdefs"
910
"github.com/docker/docker/integration/internal/container"
1011
"gotest.tools/v3/assert"
@@ -21,7 +22,7 @@ func TestRemoveImageOrphaning(t *testing.T) {
2122

2223
// Create a container from busybox, and commit a small change so we have a new image
2324
cID1 := container.Create(ctx, t, client, container.WithCmd(""))
24-
commitResp1, err := client.ContainerCommit(ctx, cID1, types.ContainerCommitOptions{
25+
commitResp1, err := client.ContainerCommit(ctx, cID1, containertypes.CommitOptions{
2526
Changes: []string{`ENTRYPOINT ["true"]`},
2627
Reference: imgName,
2728
})
@@ -34,7 +35,7 @@ func TestRemoveImageOrphaning(t *testing.T) {
3435

3536
// Create a container from created image, and commit a small change with same reference name
3637
cID2 := container.Create(ctx, t, client, container.WithImage(imgName), container.WithCmd(""))
37-
commitResp2, err := client.ContainerCommit(ctx, cID2, types.ContainerCommitOptions{
38+
commitResp2, err := client.ContainerCommit(ctx, cID2, containertypes.CommitOptions{
3839
Changes: []string{`LABEL Maintainer="Integration Tests"`},
3940
Reference: imgName,
4041
})

0 commit comments

Comments
 (0)