Signed-off-by: Daniel Nephin <dnephin@docker.com>
| ... | ... |
@@ -43,7 +43,7 @@ func (v *volumeRouter) postVolumesCreate(ctx context.Context, w http.ResponseWri |
| 43 | 43 |
return err |
| 44 | 44 |
} |
| 45 | 45 |
|
| 46 |
- var req types.VolumeCreateRequest |
|
| 46 |
+ var req volumetypes.VolumesCreateBody |
|
| 47 | 47 |
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
| 48 | 48 |
return err |
| 49 | 49 |
} |
| 50 | 50 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,39 @@ |
| 0 |
+package volume |
|
| 1 |
+ |
|
| 2 |
+// ---------------------------------------------------------------------------- |
|
| 3 |
+// DO NOT EDIT THIS FILE |
|
| 4 |
+// This file was generated by `swagger generate operation` |
|
| 5 |
+// |
|
| 6 |
+// See hack/swagger-gen.sh |
|
| 7 |
+// ---------------------------------------------------------------------------- |
|
| 8 |
+ |
|
| 9 |
+/*VolumesCreateBody volumes create body |
|
| 10 |
+ |
|
| 11 |
+swagger:model VolumesCreateBody |
|
| 12 |
+*/ |
|
| 13 |
+type VolumesCreateBody struct {
|
|
| 14 |
+ |
|
| 15 |
+ /* Name of the volume driver to use. |
|
| 16 |
+ |
|
| 17 |
+ Required: true |
|
| 18 |
+ */ |
|
| 19 |
+ Driver string `json:"Driver"` |
|
| 20 |
+ |
|
| 21 |
+ /* A mapping of driver options and values. These options are passed directly to the driver and are driver specific. |
|
| 22 |
+ |
|
| 23 |
+ Required: true |
|
| 24 |
+ */ |
|
| 25 |
+ DriverOpts map[string]string `json:"DriverOpts"` |
|
| 26 |
+ |
|
| 27 |
+ /* A mapping of arbitrary key/value data to set on the volume. |
|
| 28 |
+ |
|
| 29 |
+ Required: true |
|
| 30 |
+ */ |
|
| 31 |
+ Labels map[string]string `json:"Labels"` |
|
| 32 |
+ |
|
| 33 |
+ /* The new volume's name. If not specified, Docker generates a name. |
|
| 34 |
+ |
|
| 35 |
+ Required: true |
|
| 36 |
+ */ |
|
| 37 |
+ Name string `json:"Name"` |
|
| 38 |
+} |
| ... | ... |
@@ -5480,10 +5480,12 @@ paths: |
| 5480 | 5480 |
Name: |
| 5481 | 5481 |
description: "The new volume's name. If not specified, Docker generates a name." |
| 5482 | 5482 |
type: "string" |
| 5483 |
+ x-nullable: false |
|
| 5483 | 5484 |
Driver: |
| 5484 | 5485 |
description: "Name of the volume driver to use." |
| 5485 | 5486 |
type: "string" |
| 5486 | 5487 |
default: "local" |
| 5488 |
+ x-nullable: false |
|
| 5487 | 5489 |
DriverOpts: |
| 5488 | 5490 |
description: "A mapping of driver options and values. These options are passed directly to the driver and are driver specific." |
| 5489 | 5491 |
type: "object" |
| ... | ... |
@@ -410,15 +410,6 @@ type MountPoint struct {
|
| 410 | 410 |
Propagation mount.Propagation |
| 411 | 411 |
} |
| 412 | 412 |
|
| 413 |
-// VolumeCreateRequest contains the request for the remote API: |
|
| 414 |
-// POST "/volumes/create" |
|
| 415 |
-type VolumeCreateRequest struct {
|
|
| 416 |
- Name string // Name is the requested name of the volume |
|
| 417 |
- Driver string // Driver is the name of the driver that should be used to create the volume |
|
| 418 |
- DriverOpts map[string]string // DriverOpts holds the driver specific options to use for when creating the volume. |
|
| 419 |
- Labels map[string]string // Labels holds metadata specific to the volume being created. |
|
| 420 |
-} |
|
| 421 |
- |
|
| 422 | 413 |
// NetworkResource is the body of the "get network" http response message |
| 423 | 414 |
type NetworkResource struct {
|
| 424 | 415 |
Name string // Name is the requested name of the network |
| ... | ... |
@@ -5,7 +5,7 @@ import ( |
| 5 | 5 |
|
| 6 | 6 |
"golang.org/x/net/context" |
| 7 | 7 |
|
| 8 |
- "github.com/docker/docker/api/types" |
|
| 8 |
+ volumetypes "github.com/docker/docker/api/server/types/volume" |
|
| 9 | 9 |
"github.com/docker/docker/cli" |
| 10 | 10 |
"github.com/docker/docker/cli/command" |
| 11 | 11 |
"github.com/docker/docker/opts" |
| ... | ... |
@@ -55,7 +55,7 @@ func newCreateCommand(dockerCli *command.DockerCli) *cobra.Command {
|
| 55 | 55 |
func runCreate(dockerCli *command.DockerCli, opts createOptions) error {
|
| 56 | 56 |
client := dockerCli.Client() |
| 57 | 57 |
|
| 58 |
- volReq := types.VolumeCreateRequest{
|
|
| 58 |
+ volReq := volumetypes.VolumesCreateBody{
|
|
| 59 | 59 |
Driver: opts.driver, |
| 60 | 60 |
DriverOpts: opts.driverOpts.GetAll(), |
| 61 | 61 |
Name: opts.name, |
| ... | ... |
@@ -134,7 +134,7 @@ type SystemAPIClient interface {
|
| 134 | 134 |
|
| 135 | 135 |
// VolumeAPIClient defines API client methods for the volumes |
| 136 | 136 |
type VolumeAPIClient interface {
|
| 137 |
- VolumeCreate(ctx context.Context, options types.VolumeCreateRequest) (types.Volume, error) |
|
| 137 |
+ VolumeCreate(ctx context.Context, options volumetypes.VolumesCreateBody) (types.Volume, error) |
|
| 138 | 138 |
VolumeInspect(ctx context.Context, volumeID string) (types.Volume, error) |
| 139 | 139 |
VolumeInspectWithRaw(ctx context.Context, volumeID string) (types.Volume, []byte, error) |
| 140 | 140 |
VolumeList(ctx context.Context, filter filters.Args) (volumetypes.VolumesListOKBody, error) |
| ... | ... |
@@ -3,12 +3,13 @@ package client |
| 3 | 3 |
import ( |
| 4 | 4 |
"encoding/json" |
| 5 | 5 |
|
| 6 |
+ volumetypes "github.com/docker/docker/api/server/types/volume" |
|
| 6 | 7 |
"github.com/docker/docker/api/types" |
| 7 | 8 |
"golang.org/x/net/context" |
| 8 | 9 |
) |
| 9 | 10 |
|
| 10 | 11 |
// VolumeCreate creates a volume in the docker host. |
| 11 |
-func (cli *Client) VolumeCreate(ctx context.Context, options types.VolumeCreateRequest) (types.Volume, error) {
|
|
| 12 |
+func (cli *Client) VolumeCreate(ctx context.Context, options volumetypes.VolumesCreateBody) (types.Volume, error) {
|
|
| 12 | 13 |
var volume types.Volume |
| 13 | 14 |
resp, err := cli.post(ctx, "/volumes/create", nil, options, nil) |
| 14 | 15 |
if err != nil {
|
| ... | ... |
@@ -9,6 +9,7 @@ import ( |
| 9 | 9 |
"strings" |
| 10 | 10 |
"testing" |
| 11 | 11 |
|
| 12 |
+ volumetypes "github.com/docker/docker/api/server/types/volume" |
|
| 12 | 13 |
"github.com/docker/docker/api/types" |
| 13 | 14 |
"golang.org/x/net/context" |
| 14 | 15 |
) |
| ... | ... |
@@ -18,7 +19,7 @@ func TestVolumeCreateError(t *testing.T) {
|
| 18 | 18 |
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), |
| 19 | 19 |
} |
| 20 | 20 |
|
| 21 |
- _, err := client.VolumeCreate(context.Background(), types.VolumeCreateRequest{})
|
|
| 21 |
+ _, err := client.VolumeCreate(context.Background(), volumetypes.VolumesCreateBody{})
|
|
| 22 | 22 |
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
| 23 | 23 |
t.Fatalf("expected a Server Error, got %v", err)
|
| 24 | 24 |
} |
| ... | ... |
@@ -52,7 +53,7 @@ func TestVolumeCreate(t *testing.T) {
|
| 52 | 52 |
}), |
| 53 | 53 |
} |
| 54 | 54 |
|
| 55 |
- volume, err := client.VolumeCreate(context.Background(), types.VolumeCreateRequest{
|
|
| 55 |
+ volume, err := client.VolumeCreate(context.Background(), volumetypes.VolumesCreateBody{
|
|
| 56 | 56 |
Name: "myvolume", |
| 57 | 57 |
Driver: "mydriver", |
| 58 | 58 |
DriverOpts: map[string]string{
|
| ... | ... |
@@ -9,6 +9,7 @@ import ( |
| 9 | 9 |
|
| 10 | 10 |
"github.com/Sirupsen/logrus" |
| 11 | 11 |
|
| 12 |
+ volumetypes "github.com/docker/docker/api/server/types/volume" |
|
| 12 | 13 |
"github.com/docker/docker/api/types" |
| 13 | 14 |
enginecontainer "github.com/docker/docker/api/types/container" |
| 14 | 15 |
"github.com/docker/docker/api/types/events" |
| ... | ... |
@@ -335,7 +336,7 @@ func (c *containerConfig) hostConfig() *enginecontainer.HostConfig {
|
| 335 | 335 |
} |
| 336 | 336 |
|
| 337 | 337 |
// This handles the case of volumes that are defined inside a service Mount |
| 338 |
-func (c *containerConfig) volumeCreateRequest(mount *api.Mount) *types.VolumeCreateRequest {
|
|
| 338 |
+func (c *containerConfig) volumeCreateRequest(mount *api.Mount) *volumetypes.VolumesCreateBody {
|
|
| 339 | 339 |
var ( |
| 340 | 340 |
driverName string |
| 341 | 341 |
driverOpts map[string]string |
| ... | ... |
@@ -349,7 +350,7 @@ func (c *containerConfig) volumeCreateRequest(mount *api.Mount) *types.VolumeCre |
| 349 | 349 |
} |
| 350 | 350 |
|
| 351 | 351 |
if mount.VolumeOptions != nil {
|
| 352 |
- return &types.VolumeCreateRequest{
|
|
| 352 |
+ return &volumetypes.VolumesCreateBody{
|
|
| 353 | 353 |
Name: mount.Source, |
| 354 | 354 |
Driver: driverName, |
| 355 | 355 |
DriverOpts: driverOpts, |
| ... | ... |
@@ -12,4 +12,5 @@ swagger generate model -f api/swagger.yaml \ |
| 12 | 12 |
swagger generate operation -f api/swagger.yaml \ |
| 13 | 13 |
-t api -s server -a types -m types \ |
| 14 | 14 |
-T api/templates --skip-responses --skip-parameters --skip-validator \ |
| 15 |
- -n VolumesList |
|
| 15 |
+ -n VolumesList \ |
|
| 16 |
+ -n VolumesCreate |
| ... | ... |
@@ -26,7 +26,7 @@ func (s *DockerSuite) TestVolumesAPIList(c *check.C) {
|
| 26 | 26 |
} |
| 27 | 27 |
|
| 28 | 28 |
func (s *DockerSuite) TestVolumesAPICreate(c *check.C) {
|
| 29 |
- config := types.VolumeCreateRequest{
|
|
| 29 |
+ config := volumetypes.VolumesCreateBody{
|
|
| 30 | 30 |
Name: "test", |
| 31 | 31 |
} |
| 32 | 32 |
status, b, err := sockRequest("POST", "/volumes/create", config)
|
| ... | ... |
@@ -65,7 +65,7 @@ func (s *DockerSuite) TestVolumesAPIRemove(c *check.C) {
|
| 65 | 65 |
} |
| 66 | 66 |
|
| 67 | 67 |
func (s *DockerSuite) TestVolumesAPIInspect(c *check.C) {
|
| 68 |
- config := types.VolumeCreateRequest{
|
|
| 68 |
+ config := volumetypes.VolumesCreateBody{
|
|
| 69 | 69 |
Name: "test", |
| 70 | 70 |
} |
| 71 | 71 |
status, b, err := sockRequest("POST", "/volumes/create", config)
|