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"
"time"
volumetypes "github.com/docker/docker/api/server/types/volume"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/events"
@ -136,7 +137,7 @@ type VolumeAPIClient interface {
VolumeCreate(ctx context.Context, options types.VolumeCreateRequest) (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) (types.VolumesListResponse, error)
VolumeList(ctx context.Context, filter filters.Args) (volumetypes.VolumesListOKBody, error)
VolumeRemove(ctx context.Context, volumeID string, force bool) error
VolumesPrune(ctx context.Context, cfg types.VolumesPruneConfig) (types.VolumesPruneReport, error)
}

View File

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

View File

@ -9,6 +9,7 @@ import (
"strings"
"testing"
volumetypes "github.com/docker/docker/api/server/types/volume"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters"
"golang.org/x/net/context"
@ -68,7 +69,7 @@ func TestVolumeList(t *testing.T) {
if actualFilters != listCase.expectedFilters {
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{
{
Name: "volume",