1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #27648 from dnephin/swagger-gen-operations

Generated more api types from swagger spec
This commit is contained in:
Brian Goff 2016-10-31 15:33:16 -04:00 committed by GitHub
commit 2fc760496b
47 changed files with 532 additions and 399 deletions

View file

@ -32,7 +32,7 @@ type copyBackend interface {
// stateBackend includes functions to implement to provide container state lifecycle functionality. // stateBackend includes functions to implement to provide container state lifecycle functionality.
type stateBackend interface { 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 ContainerKill(name string, sig uint64) error
ContainerPause(name string) error ContainerPause(name string) error
ContainerRename(oldName, newName 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 ContainerStart(name string, hostConfig *container.HostConfig, validateHostname bool, checkpoint string, checkpointDir string) error
ContainerStop(name string, seconds *int) error ContainerStop(name string, seconds *int) error
ContainerUnpause(name string) 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) ContainerWait(name string, timeout time.Duration) (int, error)
} }

View file

@ -283,8 +283,8 @@ func (s *containerRouter) postContainersWait(ctx context.Context, w http.Respons
return err return err
} }
return httputils.WriteJSON(w, http.StatusOK, &types.ContainerWaitResponse{ return httputils.WriteJSON(w, http.StatusOK, &container.ContainerWaitOKBody{
StatusCode: status, StatusCode: int64(status),
}) })
} }

View file

@ -49,7 +49,7 @@ func (s *containerRouter) postContainerExecCreate(ctx context.Context, w http.Re
return err return err
} }
return httputils.WriteJSON(w, http.StatusCreated, &types.ContainerExecCreateResponse{ return httputils.WriteJSON(w, http.StatusCreated, &types.IDResponse{
ID: id, ID: id,
}) })
} }

View file

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

View file

@ -13,6 +13,7 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/events" "github.com/docker/docker/api/types/events"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/registry"
timetypes "github.com/docker/docker/api/types/time" timetypes "github.com/docker/docker/api/types/time"
"github.com/docker/docker/api/types/versions" "github.com/docker/docker/api/types/versions"
"github.com/docker/docker/pkg/ioutils" "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 { if err != nil {
return err return err
} }
return httputils.WriteJSON(w, http.StatusOK, &types.AuthResponse{ return httputils.WriteJSON(w, http.StatusOK, &registry.AuthenticateOKBody{
Status: status, Status: status,
IdentityToken: token, IdentityToken: token,
}) })

View file

@ -6,6 +6,7 @@ import (
"github.com/docker/docker/api/server/httputils" "github.com/docker/docker/api/server/httputils"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
volumetypes "github.com/docker/docker/api/types/volume"
"golang.org/x/net/context" "golang.org/x/net/context"
) )
@ -18,7 +19,7 @@ func (v *volumeRouter) getVolumesList(ctx context.Context, w http.ResponseWriter
if err != nil { if err != nil {
return err 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 { 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 return err
} }
var req types.VolumeCreateRequest var req volumetypes.VolumesCreateBody
if err := json.NewDecoder(r.Body).Decode(&req); err != nil { if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
return err return err
} }

12
api/swagger-gen.yaml Normal file
View file

@ -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"

File diff suppressed because it is too large Load diff

View file

@ -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 }}

View file

@ -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"`
}

View file

@ -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"`
}

View file

@ -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"`
}

View file

@ -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"`
}

View file

@ -1,6 +0,0 @@
package types
// ErrorResponse is the response body of API errors.
type ErrorResponse struct {
Message string `json:"message"`
}

13
api/types/id_response.go Normal file
View file

@ -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"`
}

View file

@ -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"`
}

View file

@ -13,54 +13,6 @@ import (
"github.com/docker/go-connections/nat" "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: // ContainerChange contains response of Remote API:
// GET "/containers/{name:.*}/changes" // GET "/containers/{name:.*}/changes"
type ContainerChange struct { type ContainerChange struct {
@ -410,22 +362,6 @@ type MountPoint struct {
Propagation mount.Propagation 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 // NetworkResource is the body of the "get network" http response message
type NetworkResource struct { type NetworkResource struct {
Name string // Name is the requested name of the network Name string // Name is the requested name of the network

View file

@ -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"`
}

View file

@ -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"`
}

View file

@ -116,7 +116,7 @@ type Backend interface {
// ContainerAttachRaw attaches to container. // ContainerAttachRaw attaches to container.
ContainerAttachRaw(cID string, stdin io.ReadCloser, stdout, stderr io.Writer, stream bool) error ContainerAttachRaw(cID string, stdin io.ReadCloser, stdout, stderr io.Writer, stream bool) error
// ContainerCreate creates a new Docker container and returns potential warnings // 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 removes a container specified by `id`.
ContainerRm(name string, config *types.ContainerRmConfig) error ContainerRm(name string, config *types.ContainerRmConfig) error
// Commit creates a new Docker image from an existing Docker container. // Commit creates a new Docker image from an existing Docker container.

View file

@ -148,7 +148,7 @@ func newCIDFile(path string) (*cidFile, error) {
return &cidFile{path: path, file: f}, nil 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() stderr := dockerCli.Err()
var containerIDFile *cidFile var containerIDFile *cidFile

View file

@ -5,7 +5,7 @@ import (
"golang.org/x/net/context" "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"
"github.com/docker/docker/cli/command" "github.com/docker/docker/cli/command"
"github.com/docker/docker/opts" "github.com/docker/docker/opts"
@ -55,7 +55,7 @@ func newCreateCommand(dockerCli *command.DockerCli) *cobra.Command {
func runCreate(dockerCli *command.DockerCli, opts createOptions) error { func runCreate(dockerCli *command.DockerCli, opts createOptions) error {
client := dockerCli.Client() client := dockerCli.Client()
volReq := types.VolumeCreateRequest{ volReq := volumetypes.VolumesCreateBody{
Driver: opts.driver, Driver: opts.driver,
DriverOpts: opts.driverOpts.GetAll(), DriverOpts: opts.driverOpts.GetAll(),
Name: opts.name, Name: opts.name,

View file

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

View file

@ -67,7 +67,7 @@ func TestContainerCommit(t *testing.T) {
if len(changes) != len(expectedChanges) { if len(changes) != len(expectedChanges) {
return nil, fmt.Errorf("expected container changes size to be '%d', got %d", len(expectedChanges), len(changes)) 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", ID: "new_container_id",
}) })
if err != nil { if err != nil {

View file

@ -5,7 +5,6 @@ import (
"net/url" "net/url"
"strings" "strings"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/network"
"golang.org/x/net/context" "golang.org/x/net/context"
@ -19,8 +18,8 @@ type configWrapper struct {
// ContainerCreate creates a new container based in the given configuration. // ContainerCreate creates a new container based in the given configuration.
// It can be associated with a name, but it's not mandatory. // 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) { func (cli *Client) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, containerName string) (container.ContainerCreateCreatedBody, error) {
var response types.ContainerCreateResponse var response container.ContainerCreateCreatedBody
query := url.Values{} query := url.Values{}
if containerName != "" { if containerName != "" {
query.Set("name", containerName) query.Set("name", containerName)

View file

@ -9,7 +9,6 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/container"
"golang.org/x/net/context" "golang.org/x/net/context"
) )
@ -54,7 +53,7 @@ func TestContainerCreateWithName(t *testing.T) {
if name != "container_name" { if name != "container_name" {
return nil, fmt.Errorf("container name not set in URL query properly. Expected `container_name`, got %s", 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", ID: "container_id",
}) })
if err != nil { if err != nil {

View file

@ -8,8 +8,8 @@ import (
) )
// ContainerExecCreate creates a new exec configuration to run an exec process. // 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) { func (cli *Client) ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error) {
var response types.ContainerExecCreateResponse var response types.IDResponse
resp, err := cli.post(ctx, "/containers/"+container+"/exec", nil, config, nil) resp, err := cli.post(ctx, "/containers/"+container+"/exec", nil, config, nil)
if err != nil { if err != nil {
return response, err return response, err

View file

@ -45,7 +45,7 @@ func TestContainerExecCreate(t *testing.T) {
if execConfig.User != "user" { if execConfig.User != "user" {
return nil, fmt.Errorf("expected an execConfig with User == 'user', got %v", execConfig) 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", ID: "exec_id",
}) })
if err != nil { if err != nil {

View file

@ -3,14 +3,13 @@ package client
import ( import (
"encoding/json" "encoding/json"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/container"
"golang.org/x/net/context" "golang.org/x/net/context"
) )
// ContainerUpdate updates resources of a container // ContainerUpdate updates resources of a container
func (cli *Client) ContainerUpdate(ctx context.Context, containerID string, updateConfig container.UpdateConfig) (types.ContainerUpdateResponse, error) { func (cli *Client) ContainerUpdate(ctx context.Context, containerID string, updateConfig container.UpdateConfig) (container.ContainerUpdateOKBody, error) {
var response types.ContainerUpdateResponse var response container.ContainerUpdateOKBody
serverResp, err := cli.post(ctx, "/containers/"+containerID+"/update", nil, updateConfig, nil) serverResp, err := cli.post(ctx, "/containers/"+containerID+"/update", nil, updateConfig, nil)
if err != nil { if err != nil {
return response, err return response, err

View file

@ -9,7 +9,6 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/container"
"golang.org/x/net/context" "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) 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 { if err != nil {
return nil, err return nil, err
} }

View file

@ -5,19 +5,19 @@ import (
"golang.org/x/net/context" "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. // ContainerWait pauses execution until a container exits.
// It returns the API status code as response of its readiness. // 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) resp, err := cli.post(ctx, "/containers/"+containerID+"/wait", nil, nil, nil)
if err != nil { if err != nil {
return -1, err return -1, err
} }
defer ensureReaderClosed(resp) defer ensureReaderClosed(resp)
var res types.ContainerWaitResponse var res container.ContainerWaitOKBody
if err := json.NewDecoder(resp.body).Decode(&res); err != nil { if err := json.NewDecoder(resp.body).Decode(&res); err != nil {
return -1, err return -1, err
} }

View file

@ -11,7 +11,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container"
"golang.org/x/net/context" "golang.org/x/net/context"
) )
@ -36,7 +36,7 @@ func TestContainerWait(t *testing.T) {
if !strings.HasPrefix(req.URL.Path, expectedURL) { if !strings.HasPrefix(req.URL.Path, expectedURL) {
return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL) 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, StatusCode: 15,
}) })
if err != nil { if err != nil {

View file

@ -11,6 +11,7 @@ import (
"github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/registry" "github.com/docker/docker/api/types/registry"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
volumetypes "github.com/docker/docker/api/types/volume"
"golang.org/x/net/context" "golang.org/x/net/context"
) )
@ -32,11 +33,11 @@ type CommonAPIClient interface {
// ContainerAPIClient defines API client methods for the containers // ContainerAPIClient defines API client methods for the containers
type ContainerAPIClient interface { type ContainerAPIClient interface {
ContainerAttach(ctx context.Context, container string, options types.ContainerAttachOptions) (types.HijackedResponse, error) 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) (types.ContainerCreateResponse, 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) ContainerDiff(ctx context.Context, container string) ([]types.ContainerChange, error)
ContainerExecAttach(ctx context.Context, execID string, config types.ExecConfig) (types.HijackedResponse, 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) ContainerExecInspect(ctx context.Context, execID string) (types.ContainerExecInspect, error)
ContainerExecResize(ctx context.Context, execID string, options types.ResizeOptions) error ContainerExecResize(ctx context.Context, execID string, options types.ResizeOptions) error
ContainerExecStart(ctx context.Context, execID string, config types.ExecStartCheck) 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 ContainerStop(ctx context.Context, container string, timeout *time.Duration) error
ContainerTop(ctx context.Context, container string, arguments []string) (types.ContainerProcessList, error) ContainerTop(ctx context.Context, container string, arguments []string) (types.ContainerProcessList, error)
ContainerUnpause(ctx context.Context, container string) error ContainerUnpause(ctx context.Context, container string) error
ContainerUpdate(ctx context.Context, container string, updateConfig container.UpdateConfig) (types.ContainerUpdateResponse, error) ContainerUpdate(ctx context.Context, container string, updateConfig container.UpdateConfig) (container.ContainerUpdateOKBody, error)
ContainerWait(ctx context.Context, container string) (int, error) ContainerWait(ctx context.Context, container string) (int64, error)
CopyFromContainer(ctx context.Context, container, srcPath string) (io.ReadCloser, types.ContainerPathStat, 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 CopyToContainer(ctx context.Context, container, path string, content io.Reader, options types.CopyToContainerOptions) error
ContainersPrune(ctx context.Context, cfg types.ContainersPruneConfig) (types.ContainersPruneReport, error) ContainersPrune(ctx context.Context, cfg types.ContainersPruneConfig) (types.ContainersPruneReport, error)
@ -126,17 +127,17 @@ type SwarmAPIClient interface {
type SystemAPIClient interface { type SystemAPIClient interface {
Events(ctx context.Context, options types.EventsOptions) (<-chan events.Message, <-chan error) Events(ctx context.Context, options types.EventsOptions) (<-chan events.Message, <-chan error)
Info(ctx context.Context) (types.Info, 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) DiskUsage(ctx context.Context) (types.DiskUsage, error)
Ping(ctx context.Context) (bool, error) Ping(ctx context.Context) (bool, error)
} }
// VolumeAPIClient defines API client methods for the volumes // VolumeAPIClient defines API client methods for the volumes
type VolumeAPIClient interface { 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) VolumeInspect(ctx context.Context, volumeID string) (types.Volume, error)
VolumeInspectWithRaw(ctx context.Context, volumeID string) (types.Volume, []byte, 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 VolumeRemove(ctx context.Context, volumeID string, force bool) error
VolumesPrune(ctx context.Context, cfg types.VolumesPruneConfig) (types.VolumesPruneReport, error) VolumesPrune(ctx context.Context, cfg types.VolumesPruneConfig) (types.VolumesPruneReport, error)
} }

View file

@ -6,22 +6,23 @@ import (
"net/url" "net/url"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/registry"
"golang.org/x/net/context" "golang.org/x/net/context"
) )
// RegistryLogin authenticates the docker server with a given docker registry. // RegistryLogin authenticates the docker server with a given docker registry.
// It returns UnauthorizerError when the authentication fails. // 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) resp, err := cli.post(ctx, "/auth", url.Values{}, auth, nil)
if resp.statusCode == http.StatusUnauthorized { if resp.statusCode == http.StatusUnauthorized {
return types.AuthResponse{}, unauthorizedError{err} return registry.AuthenticateOKBody{}, unauthorizedError{err}
} }
if err != nil { 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) err = json.NewDecoder(resp.body).Decode(&response)
ensureReaderClosed(resp) ensureReaderClosed(resp)
return response, err return response, err

View file

@ -4,11 +4,12 @@ import (
"encoding/json" "encoding/json"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
volumetypes "github.com/docker/docker/api/types/volume"
"golang.org/x/net/context" "golang.org/x/net/context"
) )
// VolumeCreate creates a volume in the docker host. // 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 var volume types.Volume
resp, err := cli.post(ctx, "/volumes/create", nil, options, nil) resp, err := cli.post(ctx, "/volumes/create", nil, options, nil)
if err != nil { if err != nil {

View file

@ -10,6 +10,7 @@ import (
"testing" "testing"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
volumetypes "github.com/docker/docker/api/types/volume"
"golang.org/x/net/context" "golang.org/x/net/context"
) )
@ -18,7 +19,7 @@ func TestVolumeCreateError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), 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" { if err == nil || err.Error() != "Error response from daemon: Server error" {
t.Fatalf("expected a Server Error, got %v", err) 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", Name: "myvolume",
Driver: "mydriver", Driver: "mydriver",
DriverOpts: map[string]string{ DriverOpts: map[string]string{

View file

@ -4,14 +4,14 @@ import (
"encoding/json" "encoding/json"
"net/url" "net/url"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
volumetypes "github.com/docker/docker/api/types/volume"
"golang.org/x/net/context" "golang.org/x/net/context"
) )
// VolumeList returns the volumes configured in the docker host. // VolumeList returns the volumes configured in the docker host.
func (cli *Client) VolumeList(ctx context.Context, filter filters.Args) (types.VolumesListResponse, error) { func (cli *Client) VolumeList(ctx context.Context, filter filters.Args) (volumetypes.VolumesListOKBody, error) {
var volumes types.VolumesListResponse var volumes volumetypes.VolumesListOKBody
query := url.Values{} query := url.Values{}
if filter.Len() > 0 { if filter.Len() > 0 {

View file

@ -11,6 +11,7 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
volumetypes "github.com/docker/docker/api/types/volume"
"golang.org/x/net/context" "golang.org/x/net/context"
) )
@ -68,7 +69,7 @@ func TestVolumeList(t *testing.T) {
if actualFilters != listCase.expectedFilters { if actualFilters != listCase.expectedFilters {
return nil, fmt.Errorf("filters not set in URL query properly. Expected '%s', got %s", listCase.expectedFilters, actualFilters) 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{ Volumes: []*types.Volume{
{ {
Name: "volume", Name: "volume",

View file

@ -23,7 +23,7 @@ type Backend interface {
FindNetwork(idName string) (libnetwork.Network, error) FindNetwork(idName string) (libnetwork.Network, error)
SetupIngress(req clustertypes.NetworkCreateRequest, nodeIP string) 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 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 ContainerStart(name string, hostConfig *container.HostConfig, validateHostname bool, checkpoint string, checkpointDir string) error
ContainerStop(name string, seconds *int) error ContainerStop(name string, seconds *int) error
ConnectContainerToNetwork(containerName, networkName string, endpointConfig *network.EndpointSettings) error ConnectContainerToNetwork(containerName, networkName string, endpointConfig *network.EndpointSettings) error

View file

@ -12,6 +12,7 @@ import (
"github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
"github.com/docker/docker/api/server/httputils" "github.com/docker/docker/api/server/httputils"
"github.com/docker/docker/api/types" "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/events"
"github.com/docker/docker/api/types/versions" "github.com/docker/docker/api/types/versions"
executorpkg "github.com/docker/docker/daemon/cluster/executor" 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 { func (c *containerAdapter) create(ctx context.Context) error {
var cr types.ContainerCreateResponse var cr containertypes.ContainerCreateCreatedBody
var err error var err error
version := httputils.VersionFromContext(ctx) version := httputils.VersionFromContext(ctx)
validateHostname := versions.GreaterThanOrEqualTo(version, "1.24") validateHostname := versions.GreaterThanOrEqualTo(version, "1.24")

View file

@ -14,6 +14,7 @@ import (
"github.com/docker/docker/api/types/events" "github.com/docker/docker/api/types/events"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/network"
volumetypes "github.com/docker/docker/api/types/volume"
clustertypes "github.com/docker/docker/daemon/cluster/provider" clustertypes "github.com/docker/docker/daemon/cluster/provider"
"github.com/docker/docker/reference" "github.com/docker/docker/reference"
"github.com/docker/swarmkit/agent/exec" "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 // 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 ( var (
driverName string driverName string
driverOpts map[string]string driverOpts map[string]string
@ -349,7 +350,7 @@ func (c *containerConfig) volumeCreateRequest(mount *api.Mount) *types.VolumeCre
} }
if mount.VolumeOptions != nil { if mount.VolumeOptions != nil {
return &types.VolumeCreateRequest{ return &volumetypes.VolumesCreateBody{
Name: mount.Source, Name: mount.Source,
Driver: driverName, Driver: driverName,
DriverOpts: driverOpts, DriverOpts: driverOpts,

View file

@ -22,29 +22,29 @@ import (
) )
// CreateManagedContainer creates a container that is managed by a Service // 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) return daemon.containerCreate(params, true, validateHostname)
} }
// ContainerCreate creates a regular container // 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) 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() start := time.Now()
if params.Config == nil { 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) warnings, err := daemon.verifyContainerSettings(params.HostConfig, params.Config, false, validateHostname)
if err != nil { if err != nil {
return types.ContainerCreateResponse{Warnings: warnings}, err return containertypes.ContainerCreateCreatedBody{Warnings: warnings}, err
} }
err = daemon.verifyNetworkingConfig(params.NetworkingConfig) err = daemon.verifyNetworkingConfig(params.NetworkingConfig)
if err != nil { if err != nil {
return types.ContainerCreateResponse{Warnings: warnings}, err return containertypes.ContainerCreateCreatedBody{Warnings: warnings}, err
} }
if params.HostConfig == nil { if params.HostConfig == nil {
@ -52,15 +52,16 @@ func (daemon *Daemon) containerCreate(params types.ContainerCreateConfig, manage
} }
err = daemon.adaptContainerSettings(params.HostConfig, params.AdjustCPUShares) err = daemon.adaptContainerSettings(params.HostConfig, params.AdjustCPUShares)
if err != nil { if err != nil {
return types.ContainerCreateResponse{Warnings: warnings}, err return containertypes.ContainerCreateCreatedBody{Warnings: warnings}, err
} }
container, err := daemon.create(params, managed) container, err := daemon.create(params, managed)
if err != nil { if err != nil {
return types.ContainerCreateResponse{Warnings: warnings}, daemon.imageNotExistToErrcode(err) return containertypes.ContainerCreateCreatedBody{Warnings: warnings}, daemon.imageNotExistToErrcode(err)
} }
containerActions.WithValues("create").UpdateSince(start) 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. // Create creates a new container from the given configuration with a given name.

View file

@ -3,24 +3,23 @@ package daemon
import ( import (
"fmt" "fmt"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/container"
) )
// ContainerUpdate updates configuration of the 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 var warnings []string
warnings, err := daemon.verifyContainerSettings(hostConfig, nil, true, validateHostname) warnings, err := daemon.verifyContainerSettings(hostConfig, nil, true, validateHostname)
if err != nil { if err != nil {
return types.ContainerUpdateResponse{Warnings: warnings}, err return container.ContainerUpdateOKBody{Warnings: warnings}, err
} }
if err := daemon.update(name, hostConfig); err != nil { 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. // ContainerUpdateCmdOnBuild updates Path and Args for the container with ID cID.

View file

@ -2,8 +2,20 @@
set -eu set -eu
swagger generate model -f api/swagger.yaml \ 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 Volume \
-n Port \ -n Port \
-n ImageSummary \ -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

View file

@ -574,7 +574,7 @@ func (s *DockerSuite) TestContainerAPICreateWithHostName(c *check.C) {
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
c.Assert(status, checker.Equals, http.StatusCreated) c.Assert(status, checker.Equals, http.StatusCreated)
var container types.ContainerCreateResponse var container containertypes.ContainerCreateCreatedBody
c.Assert(json.Unmarshal(body, &container), checker.IsNil) c.Assert(json.Unmarshal(body, &container), checker.IsNil)
status, body, err = sockRequest("GET", "/containers/"+container.ID+"/json", nil) 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(err, checker.IsNil)
c.Assert(status, checker.Equals, http.StatusCreated) c.Assert(status, checker.Equals, http.StatusCreated)
var container types.ContainerCreateResponse var container containertypes.ContainerCreateCreatedBody
c.Assert(json.Unmarshal(body, &container), checker.IsNil) c.Assert(json.Unmarshal(body, &container), checker.IsNil)
status, body, err = sockRequest("GET", "/containers/"+container.ID+"/json", nil) 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(err, checker.IsNil)
c.Assert(status, checker.Equals, http.StatusCreated) c.Assert(status, checker.Equals, http.StatusCreated)
var container types.ContainerCreateResponse var container containertypes.ContainerCreateCreatedBody
c.Assert(json.Unmarshal(body, &container), checker.IsNil) c.Assert(json.Unmarshal(body, &container), checker.IsNil)
status, body, err = sockRequest("GET", "/containers/"+container.ID+"/json", nil) 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(err, checker.IsNil)
c.Assert(status, checker.Equals, http.StatusCreated) c.Assert(status, checker.Equals, http.StatusCreated)
var container types.ContainerCreateResponse var container containertypes.ContainerCreateCreatedBody
c.Assert(json.Unmarshal(body, &container), checker.IsNil) c.Assert(json.Unmarshal(body, &container), checker.IsNil)
status, body, err = sockRequest("GET", "/containers/"+container.ID+"/json", nil) 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(status, checker.Equals, http.StatusOK)
c.Assert(waitInspect(name, "{{ .State.Running }}", "false", 60*time.Second), checker.IsNil) 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(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) { func (s *DockerSuite) TestContainerAPICopyNotExistsAnyMore(c *check.C) {
@ -1349,7 +1349,7 @@ func (s *DockerSuite) TestPostContainersCreateShmSizeHostConfigOmitted(c *check.
c.Assert(err, check.IsNil) c.Assert(err, check.IsNil)
c.Assert(status, check.Equals, http.StatusCreated) c.Assert(status, check.Equals, http.StatusCreated)
var container types.ContainerCreateResponse var container containertypes.ContainerCreateCreatedBody
c.Assert(json.Unmarshal(body, &container), check.IsNil) c.Assert(json.Unmarshal(body, &container), check.IsNil)
status, body, err = sockRequest("GET", "/containers/"+container.ID+"/json", nil) 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(err, check.IsNil)
c.Assert(status, check.Equals, http.StatusCreated) c.Assert(status, check.Equals, http.StatusCreated)
var container types.ContainerCreateResponse var container containertypes.ContainerCreateCreatedBody
c.Assert(json.Unmarshal(body, &container), check.IsNil) c.Assert(json.Unmarshal(body, &container), check.IsNil)
status, body, err = sockRequest("GET", "/containers/"+container.ID+"/json", nil) 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(err, check.IsNil)
c.Assert(status, check.Equals, http.StatusCreated) c.Assert(status, check.Equals, http.StatusCreated)
var container types.ContainerCreateResponse var container containertypes.ContainerCreateCreatedBody
c.Assert(json.Unmarshal(body, &container), check.IsNil) c.Assert(json.Unmarshal(body, &container), check.IsNil)
status, body, err = sockRequest("GET", "/containers/"+container.ID+"/json", nil) 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(err, check.IsNil)
c.Assert(status, check.Equals, http.StatusCreated) c.Assert(status, check.Equals, http.StatusCreated)
var container types.ContainerCreateResponse var container containertypes.ContainerCreateCreatedBody
c.Assert(json.Unmarshal(body, &container), check.IsNil) c.Assert(json.Unmarshal(body, &container), check.IsNil)
status, body, err = sockRequest("GET", "/containers/"+container.ID+"/json", nil) status, body, err = sockRequest("GET", "/containers/"+container.ID+"/json", nil)

View file

@ -6,6 +6,7 @@ import (
"path/filepath" "path/filepath"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
volumetypes "github.com/docker/docker/api/types/volume"
"github.com/docker/docker/pkg/integration/checker" "github.com/docker/docker/pkg/integration/checker"
"github.com/go-check/check" "github.com/go-check/check"
) )
@ -18,14 +19,14 @@ func (s *DockerSuite) TestVolumesAPIList(c *check.C) {
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
c.Assert(status, checker.Equals, http.StatusOK) 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(json.Unmarshal(b, &volumes), checker.IsNil)
c.Assert(len(volumes.Volumes), checker.Equals, 1, check.Commentf("\n%v", volumes.Volumes)) c.Assert(len(volumes.Volumes), checker.Equals, 1, check.Commentf("\n%v", volumes.Volumes))
} }
func (s *DockerSuite) TestVolumesAPICreate(c *check.C) { func (s *DockerSuite) TestVolumesAPICreate(c *check.C) {
config := types.VolumeCreateRequest{ config := volumetypes.VolumesCreateBody{
Name: "test", Name: "test",
} }
status, b, err := sockRequest("POST", "/volumes/create", config) 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(err, checker.IsNil)
c.Assert(status, checker.Equals, http.StatusOK) 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(json.Unmarshal(b, &volumes), checker.IsNil)
c.Assert(len(volumes.Volumes), checker.Equals, 1, check.Commentf("\n%v", volumes.Volumes)) 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) { func (s *DockerSuite) TestVolumesAPIInspect(c *check.C) {
config := types.VolumeCreateRequest{ config := volumetypes.VolumesCreateBody{
Name: "test", Name: "test",
} }
status, b, err := sockRequest("POST", "/volumes/create", config) 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(err, checker.IsNil)
c.Assert(status, checker.Equals, http.StatusOK, check.Commentf(string(b))) 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(json.Unmarshal(b, &volumes), checker.IsNil)
c.Assert(len(volumes.Volumes), checker.Equals, 1, check.Commentf("\n%v", volumes.Volumes)) c.Assert(len(volumes.Volumes), checker.Equals, 1, check.Commentf("\n%v", volumes.Volumes))

View file

@ -23,6 +23,7 @@ import (
"time" "time"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
volumetypes "github.com/docker/docker/api/types/volume"
"github.com/docker/docker/opts" "github.com/docker/docker/opts"
"github.com/docker/docker/pkg/httputils" "github.com/docker/docker/pkg/httputils"
icmd "github.com/docker/docker/pkg/integration/cmd" icmd "github.com/docker/docker/pkg/integration/cmd"
@ -325,7 +326,7 @@ func deleteAllVolumes() error {
} }
func getAllVolumes() ([]*types.Volume, error) { func getAllVolumes() ([]*types.Volume, error) {
var volumes types.VolumesListResponse var volumes volumetypes.VolumesListOKBody
_, b, err := sockRequest("GET", "/volumes", nil) _, b, err := sockRequest("GET", "/volumes", nil)
if err != nil { if err != nil {
return nil, err return nil, err