Use IDResponse for container create response.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
Daniel Nephin 2016-10-18 17:27:55 -07:00
parent 01883c136d
commit c8d5e7203e
6 changed files with 8 additions and 21 deletions

View file

@ -63,7 +63,7 @@ func (s *imageRouter) postCommit(ctx context.Context, w http.ResponseWriter, r *
return err
}
return httputils.WriteJSON(w, http.StatusCreated, &types.ContainerCommitResponse{
return httputils.WriteJSON(w, http.StatusCreated, &types.IDResponse{
ID: string(imgID),
})
}

View file

@ -4937,14 +4937,7 @@ paths:
201:
description: "no error"
schema:
type: "object"
properties:
Id:
description: "The ID of the image created"
type: "string"
examples:
application/json:
Id: "596069db4bf5"
$ref: "#/definitions/IdResponse"
404:
description: "no such container"
schema:

View file

@ -38,12 +38,6 @@ type ContainerWaitResponse struct {
StatusCode int `json:"StatusCode"`
}
// ContainerCommitResponse contains response of Remote API:
// POST "/commit?container="+containerID
type ContainerCommitResponse struct {
ID string `json:"Id"`
}
// ContainerChange contains response of Remote API:
// GET "/containers/{name:.*}/changes"
type ContainerChange struct {

View file

@ -12,16 +12,16 @@ import (
)
// ContainerCommit applies changes into a container and creates a new tagged image.
func (cli *Client) ContainerCommit(ctx context.Context, container string, options types.ContainerCommitOptions) (types.ContainerCommitResponse, error) {
func (cli *Client) ContainerCommit(ctx context.Context, container string, options types.ContainerCommitOptions) (types.IDResponse, error) {
var repository, tag string
if options.Reference != "" {
distributionRef, err := distreference.ParseNamed(options.Reference)
if err != nil {
return types.ContainerCommitResponse{}, err
return types.IDResponse{}, err
}
if _, isCanonical := distributionRef.(distreference.Canonical); isCanonical {
return types.ContainerCommitResponse{}, errors.New("refusing to create a tag with a digest reference")
return types.IDResponse{}, errors.New("refusing to create a tag with a digest reference")
}
tag = reference.GetTagFromNamedRef(distributionRef)
@ -41,7 +41,7 @@ func (cli *Client) ContainerCommit(ctx context.Context, container string, option
query.Set("pause", "0")
}
var response types.ContainerCommitResponse
var response types.IDResponse
resp, err := cli.post(ctx, "/commit", query, options.Config, nil)
if err != nil {
return response, err

View file

@ -67,7 +67,7 @@ func TestContainerCommit(t *testing.T) {
if len(changes) != len(expectedChanges) {
return nil, fmt.Errorf("expected container changes size to be '%d', got %d", len(expectedChanges), len(changes))
}
b, err := json.Marshal(types.ContainerCommitResponse{
b, err := json.Marshal(types.IDResponse{
ID: "new_container_id",
})
if err != nil {

View file

@ -33,7 +33,7 @@ type CommonAPIClient interface {
// ContainerAPIClient defines API client methods for the containers
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.ContainerCommitResponse, 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, containerName string) (container.ContainerCreateCreatedBody, error)
ContainerDiff(ctx context.Context, container string) ([]types.ContainerChange, error)
ContainerExecAttach(ctx context.Context, execID string, config types.ExecConfig) (types.HijackedResponse, error)