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
|
// 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) (volumetypes.VolumesListOKBody, error)
|
VolumeList(ctx context.Context, filter filters.Args) (volumetypes.VolumesListOKBody, error)
|
||||||
|
|
|
@ -3,12 +3,13 @@ package client
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
|
volumetypes "github.com/docker/docker/api/server/types/volume"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"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 {
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
volumetypes "github.com/docker/docker/api/server/types/volume"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"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{
|
||||||
|
|
Loading…
Reference in New Issue