diff --git a/api/server/router/container/backend.go b/api/server/router/container/backend.go index c81a9788d6..0c9f081471 100644 --- a/api/server/router/container/backend.go +++ b/api/server/router/container/backend.go @@ -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, validateHostname bool) (types.ContainerCreateResponse, error) + ContainerCreate(config types.ContainerCreateConfig, validateHostname bool) (container.ContainerCreateCreatedBody, error) ContainerKill(name string, sig uint64) error ContainerPause(name string) error ContainerRename(oldName, newName string) error @@ -42,7 +42,7 @@ type stateBackend interface { ContainerStart(name string, hostConfig *container.HostConfig, validateHostname bool, checkpoint string, checkpointDir string) error ContainerStop(name string, seconds *int) error ContainerUnpause(name string) error - ContainerUpdate(name string, hostConfig *container.HostConfig, validateHostname bool) (types.ContainerUpdateResponse, error) + ContainerUpdate(name string, hostConfig *container.HostConfig, validateHostname bool) (container.ContainerUpdateOKBody, error) ContainerWait(name string, timeout time.Duration) (int, error) } diff --git a/api/server/router/container/container_routes.go b/api/server/router/container/container_routes.go index f721268ba8..c0c008c010 100644 --- a/api/server/router/container/container_routes.go +++ b/api/server/router/container/container_routes.go @@ -283,8 +283,8 @@ func (s *containerRouter) postContainersWait(ctx context.Context, w http.Respons return err } - return httputils.WriteJSON(w, http.StatusOK, &types.ContainerWaitResponse{ - StatusCode: status, + return httputils.WriteJSON(w, http.StatusOK, &container.ContainerWaitOKBody{ + StatusCode: int64(status), }) } diff --git a/api/server/router/container/exec.go b/api/server/router/container/exec.go index f840e54d70..8d49de7dac 100644 --- a/api/server/router/container/exec.go +++ b/api/server/router/container/exec.go @@ -49,7 +49,7 @@ func (s *containerRouter) postContainerExecCreate(ctx context.Context, w http.Re return err } - return httputils.WriteJSON(w, http.StatusCreated, &types.ContainerExecCreateResponse{ + return httputils.WriteJSON(w, http.StatusCreated, &types.IDResponse{ ID: id, }) } diff --git a/api/server/router/image/image_routes.go b/api/server/router/image/image_routes.go index 961c547aab..bbc2d2bfad 100644 --- a/api/server/router/image/image_routes.go +++ b/api/server/router/image/image_routes.go @@ -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), }) } diff --git a/api/server/router/system/system_routes.go b/api/server/router/system/system_routes.go index 5e508610d7..89ff1a79b4 100644 --- a/api/server/router/system/system_routes.go +++ b/api/server/router/system/system_routes.go @@ -13,6 +13,7 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/events" "github.com/docker/docker/api/types/filters" + "github.com/docker/docker/api/types/registry" timetypes "github.com/docker/docker/api/types/time" "github.com/docker/docker/api/types/versions" "github.com/docker/docker/pkg/ioutils" @@ -154,7 +155,7 @@ func (s *systemRouter) postAuth(ctx context.Context, w http.ResponseWriter, r *h if err != nil { return err } - return httputils.WriteJSON(w, http.StatusOK, &types.AuthResponse{ + return httputils.WriteJSON(w, http.StatusOK, ®istry.AuthenticateOKBody{ Status: status, IdentityToken: token, }) diff --git a/api/server/router/volume/volume_routes.go b/api/server/router/volume/volume_routes.go index 02cf53fd55..e0398817c3 100644 --- a/api/server/router/volume/volume_routes.go +++ b/api/server/router/volume/volume_routes.go @@ -6,6 +6,7 @@ import ( "github.com/docker/docker/api/server/httputils" "github.com/docker/docker/api/types" + volumetypes "github.com/docker/docker/api/types/volume" "golang.org/x/net/context" ) @@ -18,7 +19,7 @@ func (v *volumeRouter) getVolumesList(ctx context.Context, w http.ResponseWriter if err != nil { return err } - return httputils.WriteJSON(w, http.StatusOK, &types.VolumesListResponse{Volumes: volumes, Warnings: warnings}) + return httputils.WriteJSON(w, http.StatusOK, &volumetypes.VolumesListOKBody{Volumes: volumes, Warnings: warnings}) } func (v *volumeRouter) getVolumeByName(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error { @@ -42,7 +43,7 @@ func (v *volumeRouter) postVolumesCreate(ctx context.Context, w http.ResponseWri return err } - var req types.VolumeCreateRequest + var req volumetypes.VolumesCreateBody if err := json.NewDecoder(r.Body).Decode(&req); err != nil { return err } diff --git a/api/swagger-gen.yaml b/api/swagger-gen.yaml new file mode 100644 index 0000000000..f07a02737f --- /dev/null +++ b/api/swagger-gen.yaml @@ -0,0 +1,12 @@ + +layout: + models: + - name: definition + source: asset:model + target: "{{ joinFilePath .Target .ModelPackage }}" + file_name: "{{ (snakize (pascalize .Name)) }}.go" + operations: + - name: handler + source: asset:serverOperation + target: "{{ joinFilePath .Target .APIPackage .Package }}" + file_name: "{{ (snakize (pascalize .Name)) }}.go" diff --git a/api/swagger.yaml b/api/swagger.yaml index 48d9b1cad4..94cc36a172 100644 --- a/api/swagger.yaml +++ b/api/swagger.yaml @@ -1063,7 +1063,7 @@ definitions: message: type: "integer" - Error: + ErrorResponse: description: "Represents an error." type: "object" required: ["message"] @@ -1071,9 +1071,20 @@ definitions: message: description: "The error message." type: "string" + x-nullable: false example: message: "Something went wrong." + IdResponse: + description: "Response to an API call that returns just an Id" + type: "object" + required: ["Id"] + properties: + Id: + description: "The id of the newly created object." + type: "string" + x-nullable: false + EndpointSettings: description: "Configuration for a network endpoint." type: "object" @@ -2382,17 +2393,17 @@ paths: 400: description: "bad parameter" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" tags: - "Container" /containers/create: post: summary: "Create a container" - operationId: "PostContainerCreate" + operationId: "ContainerCreate" consumes: - "application/json" - "application/octet-stream" @@ -2541,15 +2552,19 @@ paths: required: true responses: 201: - description: "no error" + description: "Container created successfully" schema: type: "object" + required: [Id, Warnings] properties: Id: description: "The ID of the created container" type: "string" + x-nullable: false Warnings: + description: "Warnings encountered when creating the container" type: "array" + x-nullable: false items: type: "string" examples: @@ -2559,26 +2574,26 @@ paths: 400: description: "bad parameter" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 404: description: "no such container" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" examples: application/json: message: "No such container: c2ada9df5af8" 406: description: "impossible to attach" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 409: description: "conflict" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" tags: - "Container" /containers/{id}/json: @@ -2851,14 +2866,14 @@ paths: 404: description: "no such container" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" examples: application/json: message: "No such container: c2ada9df5af8" 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "id" in: "path" @@ -2928,14 +2943,14 @@ paths: 404: description: "no such container" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" examples: application/json: message: "No such container: c2ada9df5af8" 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "id" in: "path" @@ -2970,14 +2985,14 @@ paths: 404: description: "no such container" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" examples: application/json: message: "No such container: c2ada9df5af8" 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "id" in: "path" @@ -3060,14 +3075,14 @@ paths: 404: description: "no such container" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" examples: application/json: message: "No such container: c2ada9df5af8" 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "id" in: "path" @@ -3089,14 +3104,14 @@ paths: 404: description: "no such container" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" examples: application/json: message: "No such container: c2ada9df5af8" 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "id" in: "path" @@ -3213,14 +3228,14 @@ paths: 404: description: "no such container" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" examples: application/json: message: "No such container: c2ada9df5af8" 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "id" in: "path" @@ -3249,14 +3264,14 @@ paths: 404: description: "no such container" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" examples: application/json: message: "No such container: c2ada9df5af8" 500: description: "cannot resize container" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "id" in: "path" @@ -3283,18 +3298,18 @@ paths: 304: description: "container already started" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 404: description: "no such container" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" examples: application/json: message: "No such container: c2ada9df5af8" 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "id" in: "path" @@ -3317,18 +3332,18 @@ paths: 304: description: "container already stopped" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 404: description: "no such container" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" examples: application/json: message: "No such container: c2ada9df5af8" 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "id" in: "path" @@ -3351,14 +3366,14 @@ paths: 404: description: "no such container" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" examples: application/json: message: "No such container: c2ada9df5af8" 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "id" in: "path" @@ -3382,14 +3397,14 @@ paths: 404: description: "no such container" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" examples: application/json: message: "No such container: c2ada9df5af8" 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "id" in: "path" @@ -3407,14 +3422,12 @@ paths: post: summary: "Update a container" description: "Change various configuration options of a container without having to recreate it." - operationId: "PostContainerUpdate" - consumes: - - "application/json" - produces: - - "application/json" + operationId: "ContainerUpdate" + consumes: ["application/json"] + produces: ["application/json"] responses: 200: - description: "no error" + description: "The container has been updated." schema: type: "object" properties: @@ -3425,14 +3438,14 @@ paths: 404: description: "no such container" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" examples: application/json: message: "No such container: c2ada9df5af8" 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "id" in: "path" @@ -3475,18 +3488,18 @@ paths: 404: description: "no such container" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" examples: application/json: message: "No such container: c2ada9df5af8" 409: description: "name already in use" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "id" in: "path" @@ -3514,14 +3527,14 @@ paths: 404: description: "no such container" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" examples: application/json: message: "No such container: c2ada9df5af8" 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "id" in: "path" @@ -3541,14 +3554,14 @@ paths: 404: description: "no such container" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" examples: application/json: message: "No such container: c2ada9df5af8" 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "id" in: "path" @@ -3648,18 +3661,18 @@ paths: 400: description: "bad parameter" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 404: description: "no such container" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" examples: application/json: message: "No such container: c2ada9df5af8" 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "id" in: "path" @@ -3714,18 +3727,18 @@ paths: 400: description: "bad parameter" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 404: description: "no such container" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" examples: application/json: message: "No such container: c2ada9df5af8" 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "id" in: "path" @@ -3767,29 +3780,30 @@ paths: post: summary: "Wait for a container" description: "Block until a container stops, then returns the exit code." - operationId: "PostContainerWait" - produces: - - "application/json" + operationId: "ContainerWait" + produces: ["application/json"] responses: 200: - description: "no error" + description: "The container has exit." schema: type: "object" + required: [StatusCode] properties: StatusCode: description: "Exit code of the container" type: "integer" + x-nullable: false 404: description: "no such container" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" examples: application/json: message: "No such container: c2ada9df5af8" 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "id" in: "path" @@ -3808,18 +3822,18 @@ paths: 400: description: "bad parameter" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 404: description: "no such container" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" examples: application/json: message: "No such container: c2ada9df5af8" 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "id" in: "path" @@ -3853,18 +3867,18 @@ paths: 400: description: "client error, bad parameter, details in JSON response body, one of: must specify path parameter (path cannot be empty) not a directory (path was asserted to be a directory but exists as a file)" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 404: description: "client error, resource not found, one of: 1) no such container (container id does not exist) 2) no such file or directory (path resource does not exist)" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" examples: application/json: message: "No such container: c2ada9df5af8" 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "id" in: "path" @@ -3890,18 +3904,18 @@ paths: 400: description: "client error, bad parameter, details in JSON response body, one of: must specify path parameter (path cannot be empty) not a directory (path was asserted to be a directory but exists as a file)" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 404: description: "client error, resource not found, one of: 1) no such container (container id does not exist) 2) no such file or directory (path resource does not exist)" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" examples: application/json: message: "No such container: c2ada9df5af8" 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "id" in: "path" @@ -3928,22 +3942,22 @@ paths: 400: description: "Bad parameter" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 403: description: "Permission denied, the volume or container rootfs is marked as read-only." schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 404: description: "No such container or path does not exist inside the container" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" examples: application/json: message: "No such container: c2ada9df5af8" 500: description: "Server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "id" in: "path" @@ -4005,7 +4019,7 @@ paths: 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "all" in: "query" @@ -4155,7 +4169,7 @@ paths: 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" tags: - "Image" /images/create: @@ -4174,7 +4188,7 @@ paths: 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "fromImage" in: "query" @@ -4302,14 +4316,14 @@ paths: 404: description: "No such image" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" examples: application/json: message: "No such image: someimage (tag: latest)" 500: description: "Server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "name" in: "path" @@ -4376,11 +4390,11 @@ paths: 404: description: "No such image" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 500: description: "Server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "name" in: "path" @@ -4407,11 +4421,11 @@ paths: 404: description: "No such image" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 500: description: "Server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "name" in: "path" @@ -4440,19 +4454,19 @@ paths: 400: description: "Bad parameter" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 404: description: "No such image" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 409: description: "Conflict" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 500: description: "Server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "name" in: "path" @@ -4501,15 +4515,15 @@ paths: 404: description: "No such image" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 409: description: "Conflict" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 500: description: "Server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "name" in: "path" @@ -4573,7 +4587,7 @@ paths: 500: description: "Server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "term" in: "query" @@ -4599,23 +4613,24 @@ paths: post: summary: "Check auth configuration" description: "Validate credentials for a registry and, if available, get an identity token for accessing the registry without password." - operationId: "checkAuthentication" - consumes: - - "application/json" - produces: - - "application/json" + operationId: "Authenticate" + consumes: ["application/json"] + produces: ["application/json"] responses: 200: - description: "No error" + description: "An identity token was generated successfully." schema: type: "object" + required: [Status] properties: Status: description: "The status of the authentication" type: "string" + x-nullable: false IdentityToken: description: "An opaque token used to authenticate a user after a successful login" type: "string" + x-nullable: false examples: application/json: Status: "Login Succeeded" @@ -4625,15 +4640,14 @@ paths: 500: description: "Server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "authConfig" in: "body" description: "Authentication to check" schema: $ref: "#/definitions/AuthConfig" - tags: - - "Misc" + tags: ["Registry"] /info: get: summary: "Get system information" @@ -4840,7 +4854,7 @@ paths: 500: description: "Server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" tags: - "Misc" /version: @@ -4888,7 +4902,7 @@ paths: 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" tags: - "Misc" /_ping: @@ -4907,7 +4921,7 @@ paths: 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" tags: - "Misc" /commit: @@ -4922,25 +4936,18 @@ 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: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" examples: application/json: message: "No such container: c2ada9df5af8" 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "containerConfig" in: "body" @@ -5043,7 +5050,7 @@ paths: 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "since" in: "query" @@ -5108,7 +5115,7 @@ paths: 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "name" in: "path" @@ -5138,7 +5145,7 @@ paths: 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "names" in: "query" @@ -5166,7 +5173,7 @@ paths: 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "imagesTarball" in: "body" @@ -5189,34 +5196,22 @@ paths: 201: description: "no error" schema: - type: "object" - properties: - Id: - description: "The ID of the exec instance created." - type: "string" - Warnings: - type: "array" - items: - type: "string" - examples: - application/json: - Id: "f90e34656806" - Warnings: [] + $ref: "#/definitions/IdResponse" 404: description: "no such container" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" examples: application/json: message: "No such container: c2ada9df5af8" 409: description: "container is paused" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 500: description: "Server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "execConfig" in: "body" @@ -5275,11 +5270,11 @@ paths: 404: description: "No such exec instance" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 409: description: "Container is stopped or paused" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "execStartConfig" in: "body" @@ -5313,7 +5308,7 @@ paths: 404: description: "No such exec instance" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "id" in: "path" @@ -5381,11 +5376,11 @@ paths: 404: description: "No such exec instance" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 500: description: "Server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "id" in: "path" @@ -5434,7 +5429,7 @@ paths: 500: description: "Server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "filters" in: "query" @@ -5451,26 +5446,23 @@ paths: driver name. type: "string" format: "json" - tags: - - "Volume" + tags: ["Volume"] /volumes/create: post: summary: "Create a volume" - operationId: "PostVolumesCreate" - consumes: - - "application/json" - produces: - - "application/json" + operationId: "VolumesCreate" + consumes: ["application/json"] + produces: ["application/json"] responses: 201: - description: "No error" + description: "The volume was created successfully" schema: $ref: "#/definitions/Volume" 500: description: "Server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "volumeConfig" in: "body" @@ -5482,10 +5474,12 @@ paths: Name: description: "The new volume's name. If not specified, Docker generates a name." type: "string" + x-nullable: false Driver: description: "Name of the volume driver to use." type: "string" default: "local" + x-nullable: false DriverOpts: description: "A mapping of driver options and values. These options are passed directly to the driver and are driver specific." type: "object" @@ -5502,14 +5496,13 @@ paths: com.example.some-label: "some-value" com.example.some-other-label: "some-other-value" Driver: "custom" - tags: - - "Volume" + tags: ["Volume"] + /volumes/{name}: get: summary: "Inspect a volume" - operationId: "GetVolumesInspect" - produces: - - "application/json" + operationId: "VolumesInspect" + produces: ["application/json"] responses: 200: description: "No error" @@ -5518,50 +5511,50 @@ paths: 404: description: "No such volume" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 500: description: "Server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "name" in: "path" required: true description: "Volume name or ID" type: "string" - tags: - - "Volume" + tags: ["Volume"] + delete: summary: "Remove a volume" description: "Instruct the driver to remove the volume." - operationId: "DeleteVolumes" + operationId: "VolumesDelete" responses: 204: - description: "No error" + description: "The volume was removed" 404: description: "No such volume or volume driver" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 409: description: "Volume is in use and cannot be removed" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 500: description: "Server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "name" in: "path" required: true description: "Volume name or ID" type: "string" - tags: - - "Volume" + tags: ["Volume"] + /networks: get: summary: "List networks" - operationId: "GetNetworksList" + operationId: "NetworksList" produces: - "application/json" responses: @@ -5622,7 +5615,7 @@ paths: 500: description: "Server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "filters" in: "query" @@ -5635,12 +5628,12 @@ paths: - `name=` Matches all or part of a network name. - `type=["custom"|"builtin"]` Filters networks by type. The `custom` keyword returns all user-defined networks. type: "string" - tags: - - "Network" + tags: ["Network"] + /networks/{id}: get: summary: "Inspect a network" - operationId: "GetNetworksInspect" + operationId: "NetworksInspect" produces: - "application/json" responses: @@ -5651,15 +5644,15 @@ paths: 404: description: "Network not found" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "id" in: "path" description: "Network ID or name" required: true type: "string" - tags: - - "Network" + tags: ["Network"] + delete: summary: "Remove a network" operationId: "DeleteNetworks" @@ -5669,23 +5662,23 @@ paths: 404: description: "no such network" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 500: description: "Server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "id" in: "path" description: "Network ID or name" required: true type: "string" - tags: - - "Network" + tags: ["Network"] + /networks/create: post: summary: "Create a network" - operationId: "PostNetworksCreate" + operationId: "NetworksCreate" consumes: - "application/json" produces: @@ -5707,11 +5700,11 @@ paths: 404: description: "plugin not found" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 500: description: "Server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "networkConfig" in: "body" @@ -5775,12 +5768,12 @@ paths: Labels: com.example.some-label: "some-value" com.example.some-other-label: "some-other-value" - tags: - - "Network" + tags: ["Network"] + /networks/{id}/connect: post: summary: "Connect a container to a network" - operationId: "PostNetworksConnect" + operationId: "NetworksConnect" consumes: - "application/octet-stream" responses: @@ -5789,15 +5782,15 @@ paths: 403: description: "Operation not supported for swarm scoped networks" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 404: description: "Network or container not found" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 500: description: "Server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "id" in: "path" @@ -5821,12 +5814,12 @@ paths: IPAMConfig: IPv4Address: "172.24.56.89" IPv6Address: "2001:db8::5689" - tags: - - "Network" + tags: ["Network"] + /networks/{id}/disconnect: post: summary: "Disconnect a container from a network" - operationId: "PostNetworksDisconnect" + operationId: "NetworksDisconnect" consumes: - "application/json" responses: @@ -5835,15 +5828,15 @@ paths: 403: description: "Operation not supported for swarm scoped networks" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 404: description: "Network or container not found" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 500: description: "Server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "id" in: "path" @@ -5862,15 +5855,14 @@ paths: Force: type: "boolean" description: "Force the container to disconnect from the network." - tags: - - "Network" + tags: ["Network"] + /plugins: get: summary: "List plugins" - operationId: "GetPluginsList" + operationId: "PluginsList" description: "Returns information about installed plugins." - produces: - - "application/json" + produces: ["application/json"] responses: 200: description: "No error" @@ -5956,9 +5948,9 @@ paths: 500: description: "Server error" schema: - $ref: "#/definitions/Error" - tags: - - "Plugins" + $ref: "#/definitions/ErrorResponse" + tags: ["Plugins"] + /plugins/pull: post: summary: "Install a plugin" @@ -6000,7 +5992,7 @@ paths: 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "name" in: "query" @@ -6028,11 +6020,11 @@ paths: 404: description: "plugin is not installed" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "name" in: "path" @@ -6052,11 +6044,11 @@ paths: 404: description: "plugin is not installed" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "name" in: "path" @@ -6080,7 +6072,7 @@ paths: 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "name" in: "path" @@ -6099,7 +6091,7 @@ paths: 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "name" in: "path" @@ -6122,7 +6114,7 @@ paths: 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "filters" in: "query" @@ -6149,11 +6141,11 @@ paths: 404: description: "no such node" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "id" in: "path" @@ -6171,11 +6163,11 @@ paths: 404: description: "no such node" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "id" in: "path" @@ -6199,11 +6191,11 @@ paths: 404: description: "no such node" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "id" in: "path" @@ -6270,7 +6262,7 @@ paths: 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" tags: - "Swarm" /swarm/init: @@ -6290,15 +6282,15 @@ paths: 400: description: "bad parameter" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 406: description: "node is already part of a swarm" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "body" in: "body" @@ -6338,15 +6330,15 @@ paths: 400: description: "bad parameter" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 406: description: "node is already part of a swarm" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "body" in: "body" @@ -6384,11 +6376,11 @@ paths: 406: description: "node is not part of a swarm" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "force" description: "Force leave swarm, even if this is the last manager or that it will break the cluster." @@ -6407,15 +6399,15 @@ paths: 400: description: "bad parameter" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 406: description: "node is not part of a swarm" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "body" in: "body" @@ -6454,7 +6446,7 @@ paths: 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "filters" in: "query" @@ -6488,15 +6480,15 @@ paths: 406: description: "server error or node is not part of a swarm" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 409: description: "name conflicts with an existing service" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "body" in: "body" @@ -6567,11 +6559,11 @@ paths: 404: description: "no such service" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "id" in: "path" @@ -6589,11 +6581,11 @@ paths: 404: description: "no such service" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "id" in: "path" @@ -6612,11 +6604,11 @@ paths: 404: description: "no such service" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "id" in: "path" @@ -6791,7 +6783,7 @@ paths: 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "filters" in: "query" @@ -6821,11 +6813,11 @@ paths: 404: description: "no such task" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" 500: description: "server error" schema: - $ref: "#/definitions/Error" + $ref: "#/definitions/ErrorResponse" parameters: - name: "id" in: "path" diff --git a/api/templates/server/operation.gotmpl b/api/templates/server/operation.gotmpl new file mode 100644 index 0000000000..3a3d7527da --- /dev/null +++ b/api/templates/server/operation.gotmpl @@ -0,0 +1,26 @@ +package {{ .Package }} + +// ---------------------------------------------------------------------------- +// DO NOT EDIT THIS FILE +// This file was generated by `swagger generate operation` +// +// See hack/swagger-gen.sh +// ---------------------------------------------------------------------------- + +import ( + "net/http" + + context "golang.org/x/net/context" + + {{ range .DefaultImports }}{{ printf "%q" . }} + {{ end }} + {{ range $key, $value := .Imports }}{{ $key }} {{ printf "%q" $value }} + {{ end }} +) + + +{{ range .ExtraSchemas }} +// {{ .Name }} {{ template "docstring" . }} +// swagger:model {{ .Name }} +{{ template "schema" . }} +{{ end }} diff --git a/api/types/container/container_create.go b/api/types/container/container_create.go new file mode 100644 index 0000000000..d028e3b121 --- /dev/null +++ b/api/types/container/container_create.go @@ -0,0 +1,21 @@ +package container + +// ---------------------------------------------------------------------------- +// DO NOT EDIT THIS FILE +// This file was generated by `swagger generate operation` +// +// See hack/swagger-gen.sh +// ---------------------------------------------------------------------------- + +// ContainerCreateCreatedBody container create created body +// swagger:model ContainerCreateCreatedBody +type ContainerCreateCreatedBody struct { + + // The ID of the created container + // Required: true + ID string `json:"Id"` + + // Warnings encountered when creating the container + // Required: true + Warnings []string `json:"Warnings"` +} diff --git a/api/types/container/container_update.go b/api/types/container/container_update.go new file mode 100644 index 0000000000..81ee12c678 --- /dev/null +++ b/api/types/container/container_update.go @@ -0,0 +1,17 @@ +package container + +// ---------------------------------------------------------------------------- +// DO NOT EDIT THIS FILE +// This file was generated by `swagger generate operation` +// +// See hack/swagger-gen.sh +// ---------------------------------------------------------------------------- + +// ContainerUpdateOKBody container update o k body +// swagger:model ContainerUpdateOKBody +type ContainerUpdateOKBody struct { + + // warnings + // Required: true + Warnings []string `json:"Warnings"` +} diff --git a/api/types/container/container_wait.go b/api/types/container/container_wait.go new file mode 100644 index 0000000000..16cf335321 --- /dev/null +++ b/api/types/container/container_wait.go @@ -0,0 +1,17 @@ +package container + +// ---------------------------------------------------------------------------- +// DO NOT EDIT THIS FILE +// This file was generated by `swagger generate operation` +// +// See hack/swagger-gen.sh +// ---------------------------------------------------------------------------- + +// ContainerWaitOKBody container wait o k body +// swagger:model ContainerWaitOKBody +type ContainerWaitOKBody struct { + + // Exit code of the container + // Required: true + StatusCode int64 `json:"StatusCode"` +} diff --git a/api/types/error_response.go b/api/types/error_response.go new file mode 100644 index 0000000000..dc942d9d9e --- /dev/null +++ b/api/types/error_response.go @@ -0,0 +1,13 @@ +package types + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +// ErrorResponse Represents an error. +// swagger:model ErrorResponse +type ErrorResponse struct { + + // The error message. + // Required: true + Message string `json:"message"` +} diff --git a/api/types/errors.go b/api/types/errors.go deleted file mode 100644 index 649ab95131..0000000000 --- a/api/types/errors.go +++ /dev/null @@ -1,6 +0,0 @@ -package types - -// ErrorResponse is the response body of API errors. -type ErrorResponse struct { - Message string `json:"message"` -} diff --git a/api/types/id_response.go b/api/types/id_response.go new file mode 100644 index 0000000000..7592d2f8b1 --- /dev/null +++ b/api/types/id_response.go @@ -0,0 +1,13 @@ +package types + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +// IDResponse Response to an API call that returns just an Id +// swagger:model IdResponse +type IDResponse struct { + + // The id of the newly created object. + // Required: true + ID string `json:"Id"` +} diff --git a/api/types/registry/authenticate.go b/api/types/registry/authenticate.go new file mode 100644 index 0000000000..5e37d19bd4 --- /dev/null +++ b/api/types/registry/authenticate.go @@ -0,0 +1,21 @@ +package registry + +// ---------------------------------------------------------------------------- +// DO NOT EDIT THIS FILE +// This file was generated by `swagger generate operation` +// +// See hack/swagger-gen.sh +// ---------------------------------------------------------------------------- + +// AuthenticateOKBody authenticate o k body +// swagger:model AuthenticateOKBody +type AuthenticateOKBody struct { + + // An opaque token used to authenticate a user after a successful login + // Required: true + IdentityToken string `json:"IdentityToken"` + + // The status of the authentication + // Required: true + Status string `json:"Status"` +} diff --git a/api/types/types.go b/api/types/types.go index 0477592e19..bd9bf7bf6a 100644 --- a/api/types/types.go +++ b/api/types/types.go @@ -13,54 +13,6 @@ import ( "github.com/docker/go-connections/nat" ) -// ContainerCreateResponse contains the information returned to a client on the -// creation of a new container. -type ContainerCreateResponse struct { - // ID is the ID of the created container. - ID string `json:"Id"` - - // Warnings are any warnings encountered during the creation of the container. - Warnings []string `json:"Warnings"` -} - -// ContainerExecCreateResponse contains response of Remote API: -// POST "/containers/{name:.*}/exec" -type ContainerExecCreateResponse struct { - // ID is the exec ID. - ID string `json:"Id"` -} - -// ContainerUpdateResponse contains response of Remote API: -// POST "/containers/{name:.*}/update" -type ContainerUpdateResponse struct { - // Warnings are any warnings encountered during the updating of the container. - Warnings []string `json:"Warnings"` -} - -// AuthResponse contains response of Remote API: -// POST "/auth" -type AuthResponse struct { - // Status is the authentication status - Status string `json:"Status"` - - // IdentityToken is an opaque token used for authenticating - // a user after a successful login. - IdentityToken string `json:"IdentityToken,omitempty"` -} - -// ContainerWaitResponse contains response of Remote API: -// POST "/containers/"+containerID+"/wait" -type ContainerWaitResponse struct { - // StatusCode is the status code of the wait job - 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 { @@ -410,22 +362,6 @@ type MountPoint struct { Propagation mount.Propagation } -// VolumesListResponse contains the response for the remote API: -// GET "/volumes" -type VolumesListResponse struct { - Volumes []*Volume // Volumes is the list of volumes being returned - Warnings []string // Warnings is a list of warnings that occurred when getting the list from the volume drivers -} - -// VolumeCreateRequest contains the request for the remote API: -// POST "/volumes/create" -type VolumeCreateRequest struct { - Name string // Name is the requested name of the volume - Driver string // Driver is the name of the driver that should be used to create the volume - DriverOpts map[string]string // DriverOpts holds the driver specific options to use for when creating the volume. - Labels map[string]string // Labels holds metadata specific to the volume being created. -} - // NetworkResource is the body of the "get network" http response message type NetworkResource struct { Name string // Name is the requested name of the network diff --git a/api/types/volume/volumes_create.go b/api/types/volume/volumes_create.go new file mode 100644 index 0000000000..5f9513a227 --- /dev/null +++ b/api/types/volume/volumes_create.go @@ -0,0 +1,29 @@ +package volume + +// ---------------------------------------------------------------------------- +// DO NOT EDIT THIS FILE +// This file was generated by `swagger generate operation` +// +// See hack/swagger-gen.sh +// ---------------------------------------------------------------------------- + +// VolumesCreateBody volumes create body +// swagger:model VolumesCreateBody +type VolumesCreateBody struct { + + // Name of the volume driver to use. + // Required: true + Driver string `json:"Driver"` + + // A mapping of driver options and values. These options are passed directly to the driver and are driver specific. + // Required: true + DriverOpts map[string]string `json:"DriverOpts"` + + // A mapping of arbitrary key/value data to set on the volume. + // Required: true + Labels map[string]string `json:"Labels"` + + // The new volume's name. If not specified, Docker generates a name. + // Required: true + Name string `json:"Name"` +} diff --git a/api/types/volume/volumes_list.go b/api/types/volume/volumes_list.go new file mode 100644 index 0000000000..7770bcb8fc --- /dev/null +++ b/api/types/volume/volumes_list.go @@ -0,0 +1,23 @@ +package volume + +// ---------------------------------------------------------------------------- +// DO NOT EDIT THIS FILE +// This file was generated by `swagger generate operation` +// +// See hack/swagger-gen.sh +// ---------------------------------------------------------------------------- + +import "github.com/docker/docker/api/types" + +// VolumesListOKBody volumes list o k body +// swagger:model VolumesListOKBody +type VolumesListOKBody struct { + + // List of volumes + // Required: true + Volumes []*types.Volume `json:"Volumes"` + + // Warnings that occurred when fetching the list of volumes + // Required: true + Warnings []string `json:"Warnings"` +} diff --git a/builder/builder.go b/builder/builder.go index 0ed052731d..4aed1cb575 100644 --- a/builder/builder.go +++ b/builder/builder.go @@ -116,7 +116,7 @@ type Backend interface { // ContainerAttachRaw attaches to container. ContainerAttachRaw(cID string, stdin io.ReadCloser, stdout, stderr io.Writer, stream bool) error // ContainerCreate creates a new Docker container and returns potential warnings - ContainerCreate(config types.ContainerCreateConfig, validateHostname bool) (types.ContainerCreateResponse, error) + ContainerCreate(config types.ContainerCreateConfig, validateHostname bool) (container.ContainerCreateCreatedBody, error) // ContainerRm removes a container specified by `id`. ContainerRm(name string, config *types.ContainerRmConfig) error // Commit creates a new Docker image from an existing Docker container. diff --git a/cli/command/container/create.go b/cli/command/container/create.go index 7bd3856971..7dc644d28c 100644 --- a/cli/command/container/create.go +++ b/cli/command/container/create.go @@ -148,7 +148,7 @@ func newCIDFile(path string) (*cidFile, error) { return &cidFile{path: path, file: f}, nil } -func createContainer(ctx context.Context, dockerCli *command.DockerCli, config *container.Config, hostConfig *container.HostConfig, networkingConfig *networktypes.NetworkingConfig, cidfile, name string) (*types.ContainerCreateResponse, error) { +func createContainer(ctx context.Context, dockerCli *command.DockerCli, config *container.Config, hostConfig *container.HostConfig, networkingConfig *networktypes.NetworkingConfig, cidfile, name string) (*container.ContainerCreateCreatedBody, error) { stderr := dockerCli.Err() var containerIDFile *cidFile diff --git a/cli/command/volume/create.go b/cli/command/volume/create.go index fbf62a5ef1..7b2a7e3318 100644 --- a/cli/command/volume/create.go +++ b/cli/command/volume/create.go @@ -5,7 +5,7 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/types" + volumetypes "github.com/docker/docker/api/types/volume" "github.com/docker/docker/cli" "github.com/docker/docker/cli/command" "github.com/docker/docker/opts" @@ -55,7 +55,7 @@ func newCreateCommand(dockerCli *command.DockerCli) *cobra.Command { func runCreate(dockerCli *command.DockerCli, opts createOptions) error { client := dockerCli.Client() - volReq := types.VolumeCreateRequest{ + volReq := volumetypes.VolumesCreateBody{ Driver: opts.driver, DriverOpts: opts.driverOpts.GetAll(), Name: opts.name, diff --git a/client/container_commit.go b/client/container_commit.go index 363950cc24..c766d62e40 100644 --- a/client/container_commit.go +++ b/client/container_commit.go @@ -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 diff --git a/client/container_commit_test.go b/client/container_commit_test.go index 8f1b58be81..a844675368 100644 --- a/client/container_commit_test.go +++ b/client/container_commit_test.go @@ -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 { diff --git a/client/container_create.go b/client/container_create.go index a862172956..c042b17468 100644 --- a/client/container_create.go +++ b/client/container_create.go @@ -5,7 +5,6 @@ import ( "net/url" "strings" - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/network" "golang.org/x/net/context" @@ -19,8 +18,8 @@ type configWrapper struct { // ContainerCreate creates a new container based in 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, containerName string) (types.ContainerCreateResponse, error) { - var response types.ContainerCreateResponse +func (cli *Client) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, containerName string) (container.ContainerCreateCreatedBody, error) { + var response container.ContainerCreateCreatedBody query := url.Values{} if containerName != "" { query.Set("name", containerName) diff --git a/client/container_create_test.go b/client/container_create_test.go index 5325156beb..89641038f7 100644 --- a/client/container_create_test.go +++ b/client/container_create_test.go @@ -9,7 +9,6 @@ import ( "strings" "testing" - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" "golang.org/x/net/context" ) @@ -54,7 +53,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(types.ContainerCreateResponse{ + b, err := json.Marshal(container.ContainerCreateCreatedBody{ ID: "container_id", }) if err != nil { diff --git a/client/container_exec.go b/client/container_exec.go index 34173d3194..f6df722918 100644 --- a/client/container_exec.go +++ b/client/container_exec.go @@ -8,8 +8,8 @@ import ( ) // ContainerExecCreate creates a new exec configuration to run an exec process. -func (cli *Client) ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.ContainerExecCreateResponse, error) { - var response types.ContainerExecCreateResponse +func (cli *Client) ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error) { + var response types.IDResponse resp, err := cli.post(ctx, "/containers/"+container+"/exec", nil, config, nil) if err != nil { return response, err diff --git a/client/container_exec_test.go b/client/container_exec_test.go index 42146ae8a5..0e296a50ad 100644 --- a/client/container_exec_test.go +++ b/client/container_exec_test.go @@ -45,7 +45,7 @@ func TestContainerExecCreate(t *testing.T) { if execConfig.User != "user" { return nil, fmt.Errorf("expected an execConfig with User == 'user', got %v", execConfig) } - b, err := json.Marshal(types.ContainerExecCreateResponse{ + b, err := json.Marshal(types.IDResponse{ ID: "exec_id", }) if err != nil { diff --git a/client/container_update.go b/client/container_update.go index 48b75bee30..5082f22dfa 100644 --- a/client/container_update.go +++ b/client/container_update.go @@ -3,14 +3,13 @@ package client import ( "encoding/json" - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" "golang.org/x/net/context" ) // ContainerUpdate updates resources of a container -func (cli *Client) ContainerUpdate(ctx context.Context, containerID string, updateConfig container.UpdateConfig) (types.ContainerUpdateResponse, error) { - var response types.ContainerUpdateResponse +func (cli *Client) ContainerUpdate(ctx context.Context, containerID string, updateConfig container.UpdateConfig) (container.ContainerUpdateOKBody, error) { + var response container.ContainerUpdateOKBody serverResp, err := cli.post(ctx, "/containers/"+containerID+"/update", nil, updateConfig, nil) if err != nil { return response, err diff --git a/client/container_update_test.go b/client/container_update_test.go index e151637a2b..715bb7ca23 100644 --- a/client/container_update_test.go +++ b/client/container_update_test.go @@ -9,7 +9,6 @@ import ( "strings" "testing" - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" "golang.org/x/net/context" ) @@ -33,7 +32,7 @@ func TestContainerUpdate(t *testing.T) { return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL) } - b, err := json.Marshal(types.ContainerUpdateResponse{}) + b, err := json.Marshal(container.ContainerUpdateOKBody{}) if err != nil { return nil, err } diff --git a/client/container_wait.go b/client/container_wait.go index 8a858f0ea3..93212c70ee 100644 --- a/client/container_wait.go +++ b/client/container_wait.go @@ -5,19 +5,19 @@ import ( "golang.org/x/net/context" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" ) // ContainerWait pauses execution until a container exits. // It returns the API status code as response of its readiness. -func (cli *Client) ContainerWait(ctx context.Context, containerID string) (int, error) { +func (cli *Client) ContainerWait(ctx context.Context, containerID string) (int64, error) { resp, err := cli.post(ctx, "/containers/"+containerID+"/wait", nil, nil, nil) if err != nil { return -1, err } defer ensureReaderClosed(resp) - var res types.ContainerWaitResponse + var res container.ContainerWaitOKBody if err := json.NewDecoder(resp.body).Decode(&res); err != nil { return -1, err } diff --git a/client/container_wait_test.go b/client/container_wait_test.go index dab5acbdd3..9300bc0a54 100644 --- a/client/container_wait_test.go +++ b/client/container_wait_test.go @@ -11,7 +11,7 @@ import ( "testing" "time" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" "golang.org/x/net/context" ) @@ -36,7 +36,7 @@ func TestContainerWait(t *testing.T) { if !strings.HasPrefix(req.URL.Path, expectedURL) { return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL) } - b, err := json.Marshal(types.ContainerWaitResponse{ + b, err := json.Marshal(container.ContainerWaitOKBody{ StatusCode: 15, }) if err != nil { diff --git a/client/interface.go b/client/interface.go index 8abdb0f6fc..a78cb759cd 100644 --- a/client/interface.go +++ b/client/interface.go @@ -11,6 +11,7 @@ import ( "github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/registry" "github.com/docker/docker/api/types/swarm" + volumetypes "github.com/docker/docker/api/types/volume" "golang.org/x/net/context" ) @@ -32,11 +33,11 @@ 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) - ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, containerName string) (types.ContainerCreateResponse, 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) - ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.ContainerExecCreateResponse, error) + ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error) ContainerExecInspect(ctx context.Context, execID string) (types.ContainerExecInspect, error) ContainerExecResize(ctx context.Context, execID string, options types.ResizeOptions) error ContainerExecStart(ctx context.Context, execID string, config types.ExecStartCheck) error @@ -57,8 +58,8 @@ type ContainerAPIClient interface { ContainerStop(ctx context.Context, container string, timeout *time.Duration) error ContainerTop(ctx context.Context, container string, arguments []string) (types.ContainerProcessList, error) ContainerUnpause(ctx context.Context, container string) error - ContainerUpdate(ctx context.Context, container string, updateConfig container.UpdateConfig) (types.ContainerUpdateResponse, error) - ContainerWait(ctx context.Context, container string) (int, error) + ContainerUpdate(ctx context.Context, container string, updateConfig container.UpdateConfig) (container.ContainerUpdateOKBody, error) + ContainerWait(ctx context.Context, container string) (int64, error) CopyFromContainer(ctx context.Context, container, srcPath string) (io.ReadCloser, types.ContainerPathStat, error) CopyToContainer(ctx context.Context, container, path string, content io.Reader, options types.CopyToContainerOptions) error ContainersPrune(ctx context.Context, cfg types.ContainersPruneConfig) (types.ContainersPruneReport, error) @@ -126,17 +127,17 @@ type SwarmAPIClient interface { type SystemAPIClient interface { Events(ctx context.Context, options types.EventsOptions) (<-chan events.Message, <-chan error) Info(ctx context.Context) (types.Info, error) - RegistryLogin(ctx context.Context, auth types.AuthConfig) (types.AuthResponse, error) + RegistryLogin(ctx context.Context, auth types.AuthConfig) (registry.AuthenticateOKBody, error) DiskUsage(ctx context.Context) (types.DiskUsage, error) Ping(ctx context.Context) (bool, error) } // VolumeAPIClient defines API client methods for the volumes type VolumeAPIClient interface { - VolumeCreate(ctx context.Context, options types.VolumeCreateRequest) (types.Volume, error) + VolumeCreate(ctx context.Context, options volumetypes.VolumesCreateBody) (types.Volume, error) VolumeInspect(ctx context.Context, volumeID string) (types.Volume, error) VolumeInspectWithRaw(ctx context.Context, volumeID string) (types.Volume, []byte, error) - VolumeList(ctx context.Context, filter filters.Args) (types.VolumesListResponse, error) + VolumeList(ctx context.Context, filter filters.Args) (volumetypes.VolumesListOKBody, error) VolumeRemove(ctx context.Context, volumeID string, force bool) error VolumesPrune(ctx context.Context, cfg types.VolumesPruneConfig) (types.VolumesPruneReport, error) } diff --git a/client/login.go b/client/login.go index d8d277ccba..600dc7196f 100644 --- a/client/login.go +++ b/client/login.go @@ -6,22 +6,23 @@ import ( "net/url" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/registry" "golang.org/x/net/context" ) // RegistryLogin authenticates the docker server with a given docker registry. // It returns UnauthorizerError when the authentication fails. -func (cli *Client) RegistryLogin(ctx context.Context, auth types.AuthConfig) (types.AuthResponse, error) { +func (cli *Client) RegistryLogin(ctx context.Context, auth types.AuthConfig) (registry.AuthenticateOKBody, error) { resp, err := cli.post(ctx, "/auth", url.Values{}, auth, nil) if resp.statusCode == http.StatusUnauthorized { - return types.AuthResponse{}, unauthorizedError{err} + return registry.AuthenticateOKBody{}, unauthorizedError{err} } if err != nil { - return types.AuthResponse{}, err + return registry.AuthenticateOKBody{}, err } - var response types.AuthResponse + var response registry.AuthenticateOKBody err = json.NewDecoder(resp.body).Decode(&response) ensureReaderClosed(resp) return response, err diff --git a/client/volume_create.go b/client/volume_create.go index f3a79f1e11..9620c87cbf 100644 --- a/client/volume_create.go +++ b/client/volume_create.go @@ -4,11 +4,12 @@ import ( "encoding/json" "github.com/docker/docker/api/types" + volumetypes "github.com/docker/docker/api/types/volume" "golang.org/x/net/context" ) // VolumeCreate creates a volume in the docker host. -func (cli *Client) VolumeCreate(ctx context.Context, options types.VolumeCreateRequest) (types.Volume, error) { +func (cli *Client) VolumeCreate(ctx context.Context, options volumetypes.VolumesCreateBody) (types.Volume, error) { var volume types.Volume resp, err := cli.post(ctx, "/volumes/create", nil, options, nil) if err != nil { diff --git a/client/volume_create_test.go b/client/volume_create_test.go index 75085296cc..9f1b2540b5 100644 --- a/client/volume_create_test.go +++ b/client/volume_create_test.go @@ -10,6 +10,7 @@ import ( "testing" "github.com/docker/docker/api/types" + volumetypes "github.com/docker/docker/api/types/volume" "golang.org/x/net/context" ) @@ -18,7 +19,7 @@ func TestVolumeCreateError(t *testing.T) { client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), } - _, err := client.VolumeCreate(context.Background(), types.VolumeCreateRequest{}) + _, err := client.VolumeCreate(context.Background(), volumetypes.VolumesCreateBody{}) if err == nil || err.Error() != "Error response from daemon: Server error" { t.Fatalf("expected a Server Error, got %v", err) } @@ -52,7 +53,7 @@ func TestVolumeCreate(t *testing.T) { }), } - volume, err := client.VolumeCreate(context.Background(), types.VolumeCreateRequest{ + volume, err := client.VolumeCreate(context.Background(), volumetypes.VolumesCreateBody{ Name: "myvolume", Driver: "mydriver", DriverOpts: map[string]string{ diff --git a/client/volume_list.go b/client/volume_list.go index 44f03cfac7..32247ce115 100644 --- a/client/volume_list.go +++ b/client/volume_list.go @@ -4,14 +4,14 @@ import ( "encoding/json" "net/url" - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" + volumetypes "github.com/docker/docker/api/types/volume" "golang.org/x/net/context" ) // VolumeList returns the volumes configured in the docker host. -func (cli *Client) VolumeList(ctx context.Context, filter filters.Args) (types.VolumesListResponse, error) { - var volumes types.VolumesListResponse +func (cli *Client) VolumeList(ctx context.Context, filter filters.Args) (volumetypes.VolumesListOKBody, error) { + var volumes volumetypes.VolumesListOKBody query := url.Values{} if filter.Len() > 0 { diff --git a/client/volume_list_test.go b/client/volume_list_test.go index 0af420eaff..f29639be23 100644 --- a/client/volume_list_test.go +++ b/client/volume_list_test.go @@ -11,6 +11,7 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" + volumetypes "github.com/docker/docker/api/types/volume" "golang.org/x/net/context" ) @@ -68,7 +69,7 @@ func TestVolumeList(t *testing.T) { if actualFilters != listCase.expectedFilters { return nil, fmt.Errorf("filters not set in URL query properly. Expected '%s', got %s", listCase.expectedFilters, actualFilters) } - content, err := json.Marshal(types.VolumesListResponse{ + content, err := json.Marshal(volumetypes.VolumesListOKBody{ Volumes: []*types.Volume{ { Name: "volume", diff --git a/daemon/cluster/executor/backend.go b/daemon/cluster/executor/backend.go index 2f91e78784..fba4adec18 100644 --- a/daemon/cluster/executor/backend.go +++ b/daemon/cluster/executor/backend.go @@ -23,7 +23,7 @@ type Backend interface { FindNetwork(idName string) (libnetwork.Network, error) SetupIngress(req clustertypes.NetworkCreateRequest, nodeIP string) error PullImage(ctx context.Context, image, tag string, metaHeaders map[string][]string, authConfig *types.AuthConfig, outStream io.Writer) error - CreateManagedContainer(config types.ContainerCreateConfig, validateHostname bool) (types.ContainerCreateResponse, error) + CreateManagedContainer(config types.ContainerCreateConfig, validateHostname bool) (container.ContainerCreateCreatedBody, error) ContainerStart(name string, hostConfig *container.HostConfig, validateHostname bool, checkpoint string, checkpointDir string) error ContainerStop(name string, seconds *int) error ConnectContainerToNetwork(containerName, networkName string, endpointConfig *network.EndpointSettings) error diff --git a/daemon/cluster/executor/container/adapter.go b/daemon/cluster/executor/container/adapter.go index 7b6d1069ef..bd5745cc5b 100644 --- a/daemon/cluster/executor/container/adapter.go +++ b/daemon/cluster/executor/container/adapter.go @@ -12,6 +12,7 @@ import ( "github.com/Sirupsen/logrus" "github.com/docker/docker/api/server/httputils" "github.com/docker/docker/api/types" + containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/events" "github.com/docker/docker/api/types/versions" executorpkg "github.com/docker/docker/daemon/cluster/executor" @@ -187,7 +188,7 @@ func (c *containerAdapter) waitForDetach(ctx context.Context) error { } func (c *containerAdapter) create(ctx context.Context) error { - var cr types.ContainerCreateResponse + var cr containertypes.ContainerCreateCreatedBody var err error version := httputils.VersionFromContext(ctx) validateHostname := versions.GreaterThanOrEqualTo(version, "1.24") diff --git a/daemon/cluster/executor/container/container.go b/daemon/cluster/executor/container/container.go index 7b5203715f..10b2a371f7 100644 --- a/daemon/cluster/executor/container/container.go +++ b/daemon/cluster/executor/container/container.go @@ -14,6 +14,7 @@ import ( "github.com/docker/docker/api/types/events" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/network" + volumetypes "github.com/docker/docker/api/types/volume" clustertypes "github.com/docker/docker/daemon/cluster/provider" "github.com/docker/docker/reference" "github.com/docker/swarmkit/agent/exec" @@ -335,7 +336,7 @@ func (c *containerConfig) hostConfig() *enginecontainer.HostConfig { } // This handles the case of volumes that are defined inside a service Mount -func (c *containerConfig) volumeCreateRequest(mount *api.Mount) *types.VolumeCreateRequest { +func (c *containerConfig) volumeCreateRequest(mount *api.Mount) *volumetypes.VolumesCreateBody { var ( driverName string driverOpts map[string]string @@ -349,7 +350,7 @@ func (c *containerConfig) volumeCreateRequest(mount *api.Mount) *types.VolumeCre } if mount.VolumeOptions != nil { - return &types.VolumeCreateRequest{ + return &volumetypes.VolumesCreateBody{ Name: mount.Source, Driver: driverName, DriverOpts: driverOpts, diff --git a/daemon/create.go b/daemon/create.go index bbb1cbc8ad..4ec17c486b 100644 --- a/daemon/create.go +++ b/daemon/create.go @@ -22,29 +22,29 @@ import ( ) // CreateManagedContainer creates a container that is managed by a Service -func (daemon *Daemon) CreateManagedContainer(params types.ContainerCreateConfig, validateHostname bool) (types.ContainerCreateResponse, error) { +func (daemon *Daemon) CreateManagedContainer(params types.ContainerCreateConfig, validateHostname bool) (containertypes.ContainerCreateCreatedBody, error) { return daemon.containerCreate(params, true, validateHostname) } // ContainerCreate creates a regular container -func (daemon *Daemon) ContainerCreate(params types.ContainerCreateConfig, validateHostname bool) (types.ContainerCreateResponse, error) { +func (daemon *Daemon) ContainerCreate(params types.ContainerCreateConfig, validateHostname bool) (containertypes.ContainerCreateCreatedBody, error) { return daemon.containerCreate(params, false, validateHostname) } -func (daemon *Daemon) containerCreate(params types.ContainerCreateConfig, managed bool, validateHostname bool) (types.ContainerCreateResponse, error) { +func (daemon *Daemon) containerCreate(params types.ContainerCreateConfig, managed bool, validateHostname bool) (containertypes.ContainerCreateCreatedBody, error) { start := time.Now() if params.Config == nil { - return types.ContainerCreateResponse{}, fmt.Errorf("Config cannot be empty in order to create a container") + return containertypes.ContainerCreateCreatedBody{}, fmt.Errorf("Config cannot be empty in order to create a container") } warnings, err := daemon.verifyContainerSettings(params.HostConfig, params.Config, false, validateHostname) if err != nil { - return types.ContainerCreateResponse{Warnings: warnings}, err + return containertypes.ContainerCreateCreatedBody{Warnings: warnings}, err } err = daemon.verifyNetworkingConfig(params.NetworkingConfig) if err != nil { - return types.ContainerCreateResponse{Warnings: warnings}, err + return containertypes.ContainerCreateCreatedBody{Warnings: warnings}, err } if params.HostConfig == nil { @@ -52,15 +52,16 @@ func (daemon *Daemon) containerCreate(params types.ContainerCreateConfig, manage } err = daemon.adaptContainerSettings(params.HostConfig, params.AdjustCPUShares) if err != nil { - return types.ContainerCreateResponse{Warnings: warnings}, err + return containertypes.ContainerCreateCreatedBody{Warnings: warnings}, err } container, err := daemon.create(params, managed) if err != nil { - return types.ContainerCreateResponse{Warnings: warnings}, daemon.imageNotExistToErrcode(err) + return containertypes.ContainerCreateCreatedBody{Warnings: warnings}, daemon.imageNotExistToErrcode(err) } containerActions.WithValues("create").UpdateSince(start) - return types.ContainerCreateResponse{ID: container.ID, Warnings: warnings}, nil + + return containertypes.ContainerCreateCreatedBody{ID: container.ID, Warnings: warnings}, nil } // Create creates a new container from the given configuration with a given name. diff --git a/daemon/update.go b/daemon/update.go index 46a3d35e5f..3e05047ae2 100644 --- a/daemon/update.go +++ b/daemon/update.go @@ -3,24 +3,23 @@ package daemon import ( "fmt" - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" ) // ContainerUpdate updates configuration of the container -func (daemon *Daemon) ContainerUpdate(name string, hostConfig *container.HostConfig, validateHostname bool) (types.ContainerUpdateResponse, error) { +func (daemon *Daemon) ContainerUpdate(name string, hostConfig *container.HostConfig, validateHostname bool) (container.ContainerUpdateOKBody, error) { var warnings []string warnings, err := daemon.verifyContainerSettings(hostConfig, nil, true, validateHostname) if err != nil { - return types.ContainerUpdateResponse{Warnings: warnings}, err + return container.ContainerUpdateOKBody{Warnings: warnings}, err } if err := daemon.update(name, hostConfig); err != nil { - return types.ContainerUpdateResponse{Warnings: warnings}, err + return container.ContainerUpdateOKBody{Warnings: warnings}, err } - return types.ContainerUpdateResponse{Warnings: warnings}, nil + return container.ContainerUpdateOKBody{Warnings: warnings}, nil } // ContainerUpdateCmdOnBuild updates Path and Args for the container with ID cID. diff --git a/hack/generate-swagger-api.sh b/hack/generate-swagger-api.sh index c33900eb04..d46eaa33de 100755 --- a/hack/generate-swagger-api.sh +++ b/hack/generate-swagger-api.sh @@ -2,8 +2,20 @@ set -eu swagger generate model -f api/swagger.yaml \ - -t api -m types --skip-validator \ + -t api -m types --skip-validator -C api/swagger-gen.yaml \ -n Volume \ -n Port \ -n ImageSummary \ - -n Plugin -n PluginDevice -n PluginMount -n PluginEnv -n PluginInterfaceType + -n Plugin -n PluginDevice -n PluginMount -n PluginEnv -n PluginInterfaceType \ + -n ErrorResponse \ + -n IdResponse + +swagger generate operation -f api/swagger.yaml \ + -t api -a types -m types -C api/swagger-gen.yaml \ + -T api/templates --skip-responses --skip-parameters --skip-validator \ + -n VolumesList \ + -n VolumesCreate \ + -n ContainerCreate \ + -n ContainerUpdate \ + -n Authenticate \ + -n ContainerWait diff --git a/integration-cli/docker_api_containers_test.go b/integration-cli/docker_api_containers_test.go index 97ae216378..766d676be9 100644 --- a/integration-cli/docker_api_containers_test.go +++ b/integration-cli/docker_api_containers_test.go @@ -574,7 +574,7 @@ func (s *DockerSuite) TestContainerAPICreateWithHostName(c *check.C) { c.Assert(err, checker.IsNil) c.Assert(status, checker.Equals, http.StatusCreated) - var container types.ContainerCreateResponse + var container containertypes.ContainerCreateCreatedBody c.Assert(json.Unmarshal(body, &container), checker.IsNil) status, body, err = sockRequest("GET", "/containers/"+container.ID+"/json", nil) @@ -597,7 +597,7 @@ func (s *DockerSuite) TestContainerAPICreateWithDomainName(c *check.C) { c.Assert(err, checker.IsNil) c.Assert(status, checker.Equals, http.StatusCreated) - var container types.ContainerCreateResponse + var container containertypes.ContainerCreateCreatedBody c.Assert(json.Unmarshal(body, &container), checker.IsNil) status, body, err = sockRequest("GET", "/containers/"+container.ID+"/json", nil) @@ -632,7 +632,7 @@ func UtilCreateNetworkMode(c *check.C, networkMode string) { c.Assert(err, checker.IsNil) c.Assert(status, checker.Equals, http.StatusCreated) - var container types.ContainerCreateResponse + var container containertypes.ContainerCreateCreatedBody c.Assert(json.Unmarshal(body, &container), checker.IsNil) status, body, err = sockRequest("GET", "/containers/"+container.ID+"/json", nil) @@ -657,7 +657,7 @@ func (s *DockerSuite) TestContainerAPICreateWithCpuSharesCpuset(c *check.C) { c.Assert(err, checker.IsNil) c.Assert(status, checker.Equals, http.StatusCreated) - var container types.ContainerCreateResponse + var container containertypes.ContainerCreateCreatedBody c.Assert(json.Unmarshal(body, &container), checker.IsNil) status, body, err = sockRequest("GET", "/containers/"+container.ID+"/json", nil) @@ -957,9 +957,9 @@ func (s *DockerSuite) TestContainerAPIWait(c *check.C) { c.Assert(status, checker.Equals, http.StatusOK) c.Assert(waitInspect(name, "{{ .State.Running }}", "false", 60*time.Second), checker.IsNil) - var waitres types.ContainerWaitResponse + var waitres containertypes.ContainerWaitOKBody c.Assert(json.Unmarshal(body, &waitres), checker.IsNil) - c.Assert(waitres.StatusCode, checker.Equals, 0) + c.Assert(waitres.StatusCode, checker.Equals, int64(0)) } func (s *DockerSuite) TestContainerAPICopyNotExistsAnyMore(c *check.C) { @@ -1349,7 +1349,7 @@ func (s *DockerSuite) TestPostContainersCreateShmSizeHostConfigOmitted(c *check. c.Assert(err, check.IsNil) c.Assert(status, check.Equals, http.StatusCreated) - var container types.ContainerCreateResponse + var container containertypes.ContainerCreateCreatedBody c.Assert(json.Unmarshal(body, &container), check.IsNil) status, body, err = sockRequest("GET", "/containers/"+container.ID+"/json", nil) @@ -1381,7 +1381,7 @@ func (s *DockerSuite) TestPostContainersCreateShmSizeOmitted(c *check.C) { c.Assert(err, check.IsNil) c.Assert(status, check.Equals, http.StatusCreated) - var container types.ContainerCreateResponse + var container containertypes.ContainerCreateCreatedBody c.Assert(json.Unmarshal(body, &container), check.IsNil) status, body, err = sockRequest("GET", "/containers/"+container.ID+"/json", nil) @@ -1413,7 +1413,7 @@ func (s *DockerSuite) TestPostContainersCreateWithShmSize(c *check.C) { c.Assert(err, check.IsNil) c.Assert(status, check.Equals, http.StatusCreated) - var container types.ContainerCreateResponse + var container containertypes.ContainerCreateCreatedBody c.Assert(json.Unmarshal(body, &container), check.IsNil) status, body, err = sockRequest("GET", "/containers/"+container.ID+"/json", nil) @@ -1443,7 +1443,7 @@ func (s *DockerSuite) TestPostContainersCreateMemorySwappinessHostConfigOmitted( c.Assert(err, check.IsNil) c.Assert(status, check.Equals, http.StatusCreated) - var container types.ContainerCreateResponse + var container containertypes.ContainerCreateCreatedBody c.Assert(json.Unmarshal(body, &container), check.IsNil) status, body, err = sockRequest("GET", "/containers/"+container.ID+"/json", nil) diff --git a/integration-cli/docker_api_volumes_test.go b/integration-cli/docker_api_volumes_test.go index 5809932ef1..d1d44005e0 100644 --- a/integration-cli/docker_api_volumes_test.go +++ b/integration-cli/docker_api_volumes_test.go @@ -6,6 +6,7 @@ import ( "path/filepath" "github.com/docker/docker/api/types" + volumetypes "github.com/docker/docker/api/types/volume" "github.com/docker/docker/pkg/integration/checker" "github.com/go-check/check" ) @@ -18,14 +19,14 @@ func (s *DockerSuite) TestVolumesAPIList(c *check.C) { c.Assert(err, checker.IsNil) c.Assert(status, checker.Equals, http.StatusOK) - var volumes types.VolumesListResponse + var volumes volumetypes.VolumesListOKBody c.Assert(json.Unmarshal(b, &volumes), checker.IsNil) c.Assert(len(volumes.Volumes), checker.Equals, 1, check.Commentf("\n%v", volumes.Volumes)) } func (s *DockerSuite) TestVolumesAPICreate(c *check.C) { - config := types.VolumeCreateRequest{ + config := volumetypes.VolumesCreateBody{ Name: "test", } status, b, err := sockRequest("POST", "/volumes/create", config) @@ -47,7 +48,7 @@ func (s *DockerSuite) TestVolumesAPIRemove(c *check.C) { c.Assert(err, checker.IsNil) c.Assert(status, checker.Equals, http.StatusOK) - var volumes types.VolumesListResponse + var volumes volumetypes.VolumesListOKBody c.Assert(json.Unmarshal(b, &volumes), checker.IsNil) c.Assert(len(volumes.Volumes), checker.Equals, 1, check.Commentf("\n%v", volumes.Volumes)) @@ -64,7 +65,7 @@ func (s *DockerSuite) TestVolumesAPIRemove(c *check.C) { } func (s *DockerSuite) TestVolumesAPIInspect(c *check.C) { - config := types.VolumeCreateRequest{ + config := volumetypes.VolumesCreateBody{ Name: "test", } status, b, err := sockRequest("POST", "/volumes/create", config) @@ -75,7 +76,7 @@ func (s *DockerSuite) TestVolumesAPIInspect(c *check.C) { c.Assert(err, checker.IsNil) c.Assert(status, checker.Equals, http.StatusOK, check.Commentf(string(b))) - var volumes types.VolumesListResponse + var volumes volumetypes.VolumesListOKBody c.Assert(json.Unmarshal(b, &volumes), checker.IsNil) c.Assert(len(volumes.Volumes), checker.Equals, 1, check.Commentf("\n%v", volumes.Volumes)) diff --git a/integration-cli/docker_utils.go b/integration-cli/docker_utils.go index 87bbc6b8b1..91dc88647b 100644 --- a/integration-cli/docker_utils.go +++ b/integration-cli/docker_utils.go @@ -23,6 +23,7 @@ import ( "time" "github.com/docker/docker/api/types" + volumetypes "github.com/docker/docker/api/types/volume" "github.com/docker/docker/opts" "github.com/docker/docker/pkg/httputils" icmd "github.com/docker/docker/pkg/integration/cmd" @@ -325,7 +326,7 @@ func deleteAllVolumes() error { } func getAllVolumes() ([]*types.Volume, error) { - var volumes types.VolumesListResponse + var volumes volumetypes.VolumesListOKBody _, b, err := sockRequest("GET", "/volumes", nil) if err != nil { return nil, err