Skip to content

Commit c8d5e72

Browse files
committed
Use IDResponse for container create response.
Signed-off-by: Daniel Nephin <[email protected]>
1 parent 01883c1 commit c8d5e72

6 files changed

Lines changed: 8 additions & 21 deletions

File tree

api/server/router/image/image_routes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (s *imageRouter) postCommit(ctx context.Context, w http.ResponseWriter, r *
6363
return err
6464
}
6565

66-
return httputils.WriteJSON(w, http.StatusCreated, &types.ContainerCommitResponse{
66+
return httputils.WriteJSON(w, http.StatusCreated, &types.IDResponse{
6767
ID: string(imgID),
6868
})
6969
}

api/swagger.yaml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4937,14 +4937,7 @@ paths:
49374937
201:
49384938
description: "no error"
49394939
schema:
4940-
type: "object"
4941-
properties:
4942-
Id:
4943-
description: "The ID of the image created"
4944-
type: "string"
4945-
examples:
4946-
application/json:
4947-
Id: "596069db4bf5"
4940+
$ref: "#/definitions/IdResponse"
49484941
404:
49494942
description: "no such container"
49504943
schema:

api/types/types.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,6 @@ type ContainerWaitResponse struct {
3838
StatusCode int `json:"StatusCode"`
3939
}
4040

41-
// ContainerCommitResponse contains response of Remote API:
42-
// POST "/commit?container="+containerID
43-
type ContainerCommitResponse struct {
44-
ID string `json:"Id"`
45-
}
46-
4741
// ContainerChange contains response of Remote API:
4842
// GET "/containers/{name:.*}/changes"
4943
type ContainerChange struct {

client/container_commit.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ import (
1212
)
1313

1414
// ContainerCommit applies changes into a container and creates a new tagged image.
15-
func (cli *Client) ContainerCommit(ctx context.Context, container string, options types.ContainerCommitOptions) (types.ContainerCommitResponse, error) {
15+
func (cli *Client) ContainerCommit(ctx context.Context, container string, options types.ContainerCommitOptions) (types.IDResponse, error) {
1616
var repository, tag string
1717
if options.Reference != "" {
1818
distributionRef, err := distreference.ParseNamed(options.Reference)
1919
if err != nil {
20-
return types.ContainerCommitResponse{}, err
20+
return types.IDResponse{}, err
2121
}
2222

2323
if _, isCanonical := distributionRef.(distreference.Canonical); isCanonical {
24-
return types.ContainerCommitResponse{}, errors.New("refusing to create a tag with a digest reference")
24+
return types.IDResponse{}, errors.New("refusing to create a tag with a digest reference")
2525
}
2626

2727
tag = reference.GetTagFromNamedRef(distributionRef)
@@ -41,7 +41,7 @@ func (cli *Client) ContainerCommit(ctx context.Context, container string, option
4141
query.Set("pause", "0")
4242
}
4343

44-
var response types.ContainerCommitResponse
44+
var response types.IDResponse
4545
resp, err := cli.post(ctx, "/commit", query, options.Config, nil)
4646
if err != nil {
4747
return response, err

client/container_commit_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func TestContainerCommit(t *testing.T) {
6767
if len(changes) != len(expectedChanges) {
6868
return nil, fmt.Errorf("expected container changes size to be '%d', got %d", len(expectedChanges), len(changes))
6969
}
70-
b, err := json.Marshal(types.ContainerCommitResponse{
70+
b, err := json.Marshal(types.IDResponse{
7171
ID: "new_container_id",
7272
})
7373
if err != nil {

client/interface.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ type CommonAPIClient interface {
3333
// ContainerAPIClient defines API client methods for the containers
3434
type ContainerAPIClient interface {
3535
ContainerAttach(ctx context.Context, container string, options types.ContainerAttachOptions) (types.HijackedResponse, error)
36-
ContainerCommit(ctx context.Context, container string, options types.ContainerCommitOptions) (types.ContainerCommitResponse, error)
36+
ContainerCommit(ctx context.Context, container string, options types.ContainerCommitOptions) (types.IDResponse, error)
3737
ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, containerName string) (container.ContainerCreateCreatedBody, error)
3838
ContainerDiff(ctx context.Context, container string) ([]types.ContainerChange, error)
3939
ContainerExecAttach(ctx context.Context, execID string, config types.ExecConfig) (types.HijackedResponse, error)

0 commit comments

Comments
 (0)