mirror of https://github.com/docker/cli.git
Generate VolumesCreateRequest from the swagger spec.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
3e13296c4e
commit
0325c474b8
|
@ -134,7 +134,7 @@ type SystemAPIClient interface {
|
|||
|
||||
// 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) (volumetypes.VolumesListOKBody, error)
|
||||
|
|
|
@ -3,12 +3,13 @@ package client
|
|||
import (
|
||||
"encoding/json"
|
||||
|
||||
volumetypes "github.com/docker/docker/api/server/types/volume"
|
||||
"github.com/docker/docker/api/types"
|
||||
"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 {
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
volumetypes "github.com/docker/docker/api/server/types/volume"
|
||||
"github.com/docker/docker/api/types"
|
||||
"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{
|
||||
|
|
Loading…
Reference in New Issue