Generate VolumeList response from the swagger spec

Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
Daniel Nephin 2016-10-04 11:40:17 -04:00
parent e9089b55ee
commit 3e13296c4e
3 changed files with 7 additions and 5 deletions

View File

@ -4,6 +4,7 @@ import (
"io" "io"
"time" "time"
volumetypes "github.com/docker/docker/api/server/types/volume"
"github.com/docker/docker/api/types" "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/events" "github.com/docker/docker/api/types/events"
@ -136,7 +137,7 @@ type VolumeAPIClient interface {
VolumeCreate(ctx context.Context, options types.VolumeCreateRequest) (types.Volume, error) VolumeCreate(ctx context.Context, options types.VolumeCreateRequest) (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

@ -4,14 +4,14 @@ import (
"encoding/json" "encoding/json"
"net/url" "net/url"
"github.com/docker/docker/api/types" volumetypes "github.com/docker/docker/api/server/types/volume"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"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

@ -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"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"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",