Signed-off-by: Daniel Nephin <dnephin@docker.com>
| ... | ... |
@@ -5,6 +5,7 @@ import ( |
| 5 | 5 |
"net/http" |
| 6 | 6 |
|
| 7 | 7 |
"github.com/docker/docker/api/server/httputils" |
| 8 |
+ volumetypes "github.com/docker/docker/api/server/types/volume" |
|
| 8 | 9 |
"github.com/docker/docker/api/types" |
| 9 | 10 |
"golang.org/x/net/context" |
| 10 | 11 |
) |
| ... | ... |
@@ -18,7 +19,7 @@ func (v *volumeRouter) getVolumesList(ctx context.Context, w http.ResponseWriter |
| 18 | 18 |
if err != nil {
|
| 19 | 19 |
return err |
| 20 | 20 |
} |
| 21 |
- return httputils.WriteJSON(w, http.StatusOK, &types.VolumesListResponse{Volumes: volumes, Warnings: warnings})
|
|
| 21 |
+ return httputils.WriteJSON(w, http.StatusOK, &volumetypes.VolumesListOKBody{Volumes: volumes, Warnings: warnings})
|
|
| 22 | 22 |
} |
| 23 | 23 |
|
| 24 | 24 |
func (v *volumeRouter) getVolumeByName(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
| 25 | 25 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,29 @@ |
| 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 |
+import "github.com/docker/docker/api/types" |
|
| 10 |
+ |
|
| 11 |
+/*VolumesListOKBody volumes list o k body |
|
| 12 |
+ |
|
| 13 |
+swagger:model VolumesListOKBody |
|
| 14 |
+*/ |
|
| 15 |
+type VolumesListOKBody struct {
|
|
| 16 |
+ |
|
| 17 |
+ /* List of volumes |
|
| 18 |
+ |
|
| 19 |
+ Required: true |
|
| 20 |
+ */ |
|
| 21 |
+ Volumes []*types.Volume `json:"Volumes"` |
|
| 22 |
+ |
|
| 23 |
+ /* Warnings that occurred when fetching the list of volumes |
|
| 24 |
+ |
|
| 25 |
+ Required: true |
|
| 26 |
+ */ |
|
| 27 |
+ Warnings []string `json:"Warnings"` |
|
| 28 |
+} |
| 0 | 29 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,27 @@ |
| 0 |
+package {{ .Package }}
|
|
| 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 |
+import ( |
|
| 10 |
+ "net/http" |
|
| 11 |
+ |
|
| 12 |
+ context "golang.org/x/net/context" |
|
| 13 |
+ |
|
| 14 |
+ {{ range .DefaultImports }}{{ printf "%q" . }}
|
|
| 15 |
+ {{ end }}
|
|
| 16 |
+ {{ range $key, $value := .Imports }}{{ $key }} {{ printf "%q" $value }}
|
|
| 17 |
+ {{ end }}
|
|
| 18 |
+) |
|
| 19 |
+ |
|
| 20 |
+ |
|
| 21 |
+{{ range .ExtraSchemas }}
|
|
| 22 |
+/*{{ .Name }} {{ template "docstring" . }}
|
|
| 23 |
+swagger:model {{ .Name }}
|
|
| 24 |
+*/ |
|
| 25 |
+{{ template "schema" . }}
|
|
| 26 |
+{{ end }}
|
| ... | ... |
@@ -410,13 +410,6 @@ type MountPoint struct {
|
| 410 | 410 |
Propagation mount.Propagation |
| 411 | 411 |
} |
| 412 | 412 |
|
| 413 |
-// VolumesListResponse contains the response for the remote API: |
|
| 414 |
-// GET "/volumes" |
|
| 415 |
-type VolumesListResponse struct {
|
|
| 416 |
- Volumes []*Volume // Volumes is the list of volumes being returned |
|
| 417 |
- Warnings []string // Warnings is a list of warnings that occurred when getting the list from the volume drivers |
|
| 418 |
-} |
|
| 419 |
- |
|
| 420 | 413 |
// VolumeCreateRequest contains the request for the remote API: |
| 421 | 414 |
// POST "/volumes/create" |
| 422 | 415 |
type VolumeCreateRequest struct {
|
| ... | ... |
@@ -4,6 +4,7 @@ import ( |
| 4 | 4 |
"io" |
| 5 | 5 |
"time" |
| 6 | 6 |
|
| 7 |
+ volumetypes "github.com/docker/docker/api/server/types/volume" |
|
| 7 | 8 |
"github.com/docker/docker/api/types" |
| 8 | 9 |
"github.com/docker/docker/api/types/container" |
| 9 | 10 |
"github.com/docker/docker/api/types/events" |
| ... | ... |
@@ -136,7 +137,7 @@ type VolumeAPIClient interface {
|
| 136 | 136 |
VolumeCreate(ctx context.Context, options types.VolumeCreateRequest) (types.Volume, error) |
| 137 | 137 |
VolumeInspect(ctx context.Context, volumeID string) (types.Volume, error) |
| 138 | 138 |
VolumeInspectWithRaw(ctx context.Context, volumeID string) (types.Volume, []byte, error) |
| 139 |
- VolumeList(ctx context.Context, filter filters.Args) (types.VolumesListResponse, error) |
|
| 139 |
+ VolumeList(ctx context.Context, filter filters.Args) (volumetypes.VolumesListOKBody, error) |
|
| 140 | 140 |
VolumeRemove(ctx context.Context, volumeID string, force bool) error |
| 141 | 141 |
VolumesPrune(ctx context.Context, cfg types.VolumesPruneConfig) (types.VolumesPruneReport, error) |
| 142 | 142 |
} |
| ... | ... |
@@ -4,14 +4,14 @@ import ( |
| 4 | 4 |
"encoding/json" |
| 5 | 5 |
"net/url" |
| 6 | 6 |
|
| 7 |
- "github.com/docker/docker/api/types" |
|
| 7 |
+ volumetypes "github.com/docker/docker/api/server/types/volume" |
|
| 8 | 8 |
"github.com/docker/docker/api/types/filters" |
| 9 | 9 |
"golang.org/x/net/context" |
| 10 | 10 |
) |
| 11 | 11 |
|
| 12 | 12 |
// VolumeList returns the volumes configured in the docker host. |
| 13 |
-func (cli *Client) VolumeList(ctx context.Context, filter filters.Args) (types.VolumesListResponse, error) {
|
|
| 14 |
- var volumes types.VolumesListResponse |
|
| 13 |
+func (cli *Client) VolumeList(ctx context.Context, filter filters.Args) (volumetypes.VolumesListOKBody, error) {
|
|
| 14 |
+ var volumes volumetypes.VolumesListOKBody |
|
| 15 | 15 |
query := url.Values{}
|
| 16 | 16 |
|
| 17 | 17 |
if filter.Len() > 0 {
|
| ... | ... |
@@ -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 |
"github.com/docker/docker/api/types/filters" |
| 14 | 15 |
"golang.org/x/net/context" |
| ... | ... |
@@ -68,7 +69,7 @@ func TestVolumeList(t *testing.T) {
|
| 68 | 68 |
if actualFilters != listCase.expectedFilters {
|
| 69 | 69 |
return nil, fmt.Errorf("filters not set in URL query properly. Expected '%s', got %s", listCase.expectedFilters, actualFilters)
|
| 70 | 70 |
} |
| 71 |
- content, err := json.Marshal(types.VolumesListResponse{
|
|
| 71 |
+ content, err := json.Marshal(volumetypes.VolumesListOKBody{
|
|
| 72 | 72 |
Volumes: []*types.Volume{
|
| 73 | 73 |
{
|
| 74 | 74 |
Name: "volume", |
| ... | ... |
@@ -7,3 +7,8 @@ swagger generate model -f api/swagger.yaml \ |
| 7 | 7 |
-n Port \ |
| 8 | 8 |
-n ImageSummary \ |
| 9 | 9 |
-n Plugin -n PluginDevice -n PluginMount -n PluginEnv -n PluginInterfaceType |
| 10 |
+ |
|
| 11 |
+swagger generate operation -f api/swagger.yaml \ |
|
| 12 |
+ -t api -s server -a types -m types \ |
|
| 13 |
+ -T api/templates --skip-responses --skip-parameters --skip-validator \ |
|
| 14 |
+ -n VolumesList |
| ... | ... |
@@ -5,6 +5,7 @@ import ( |
| 5 | 5 |
"net/http" |
| 6 | 6 |
"path/filepath" |
| 7 | 7 |
|
| 8 |
+ volumetypes "github.com/docker/docker/api/server/types/volume" |
|
| 8 | 9 |
"github.com/docker/docker/api/types" |
| 9 | 10 |
"github.com/docker/docker/pkg/integration/checker" |
| 10 | 11 |
"github.com/go-check/check" |
| ... | ... |
@@ -18,7 +19,7 @@ func (s *DockerSuite) TestVolumesAPIList(c *check.C) {
|
| 18 | 18 |
c.Assert(err, checker.IsNil) |
| 19 | 19 |
c.Assert(status, checker.Equals, http.StatusOK) |
| 20 | 20 |
|
| 21 |
- var volumes types.VolumesListResponse |
|
| 21 |
+ var volumes volumetypes.VolumesListOKBody |
|
| 22 | 22 |
c.Assert(json.Unmarshal(b, &volumes), checker.IsNil) |
| 23 | 23 |
|
| 24 | 24 |
c.Assert(len(volumes.Volumes), checker.Equals, 1, check.Commentf("\n%v", volumes.Volumes))
|
| ... | ... |
@@ -47,7 +48,7 @@ func (s *DockerSuite) TestVolumesAPIRemove(c *check.C) {
|
| 47 | 47 |
c.Assert(err, checker.IsNil) |
| 48 | 48 |
c.Assert(status, checker.Equals, http.StatusOK) |
| 49 | 49 |
|
| 50 |
- var volumes types.VolumesListResponse |
|
| 50 |
+ var volumes volumetypes.VolumesListOKBody |
|
| 51 | 51 |
c.Assert(json.Unmarshal(b, &volumes), checker.IsNil) |
| 52 | 52 |
c.Assert(len(volumes.Volumes), checker.Equals, 1, check.Commentf("\n%v", volumes.Volumes))
|
| 53 | 53 |
|
| ... | ... |
@@ -75,7 +76,7 @@ func (s *DockerSuite) TestVolumesAPIInspect(c *check.C) {
|
| 75 | 75 |
c.Assert(err, checker.IsNil) |
| 76 | 76 |
c.Assert(status, checker.Equals, http.StatusOK, check.Commentf(string(b))) |
| 77 | 77 |
|
| 78 |
- var volumes types.VolumesListResponse |
|
| 78 |
+ var volumes volumetypes.VolumesListOKBody |
|
| 79 | 79 |
c.Assert(json.Unmarshal(b, &volumes), checker.IsNil) |
| 80 | 80 |
c.Assert(len(volumes.Volumes), checker.Equals, 1, check.Commentf("\n%v", volumes.Volumes))
|
| 81 | 81 |
|
| ... | ... |
@@ -22,6 +22,7 @@ import ( |
| 22 | 22 |
"strings" |
| 23 | 23 |
"time" |
| 24 | 24 |
|
| 25 |
+ volumetypes "github.com/docker/docker/api/server/types/volume" |
|
| 25 | 26 |
"github.com/docker/docker/api/types" |
| 26 | 27 |
"github.com/docker/docker/opts" |
| 27 | 28 |
"github.com/docker/docker/pkg/httputils" |
| ... | ... |
@@ -325,7 +326,7 @@ func deleteAllVolumes() error {
|
| 325 | 325 |
} |
| 326 | 326 |
|
| 327 | 327 |
func getAllVolumes() ([]*types.Volume, error) {
|
| 328 |
- var volumes types.VolumesListResponse |
|
| 328 |
+ var volumes volumetypes.VolumesListOKBody |
|
| 329 | 329 |
_, b, err := sockRequest("GET", "/volumes", nil)
|
| 330 | 330 |
if err != nil {
|
| 331 | 331 |
return nil, err |