Sfoglia il codice sorgente

Fix swagger volume type generation

This was broken by bf6a790f00ab96bb8857e3c73502909ee5e36217

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Brian Goff 7 anni fa
parent
commit
b16b125bb4

+ 2 - 2
api/server/router/volume/volume_routes.go

@@ -22,7 +22,7 @@ func (v *volumeRouter) getVolumesList(ctx context.Context, w http.ResponseWriter
 	if err != nil {
 	if err != nil {
 		return err
 		return err
 	}
 	}
-	return httputils.WriteJSON(w, http.StatusOK, &volumetypes.VolumesListOKBody{Volumes: volumes, Warnings: warnings})
+	return httputils.WriteJSON(w, http.StatusOK, &volumetypes.VolumeListOKBody{Volumes: volumes, Warnings: warnings})
 }
 }
 
 
 func (v *volumeRouter) getVolumeByName(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
 func (v *volumeRouter) getVolumeByName(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
@@ -46,7 +46,7 @@ func (v *volumeRouter) postVolumesCreate(ctx context.Context, w http.ResponseWri
 		return err
 		return err
 	}
 	}
 
 
-	var req volumetypes.VolumesCreateBody
+	var req volumetypes.VolumeCreateBody
 	if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
 	if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
 		if err == io.EOF {
 		if err == io.EOF {
 			return errdefs.InvalidParameter(errors.New("got EOF while reading request body"))
 			return errdefs.InvalidParameter(errors.New("got EOF while reading request body"))

+ 4 - 4
api/types/volume/volumes_create.go → api/types/volume/volume_create.go

@@ -1,4 +1,4 @@
-package volume // import "github.com/docker/docker/api/types/volume"
+package volume
 
 
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 // DO NOT EDIT THIS FILE
 // DO NOT EDIT THIS FILE
@@ -7,9 +7,9 @@ package volume // import "github.com/docker/docker/api/types/volume"
 // See hack/generate-swagger-api.sh
 // See hack/generate-swagger-api.sh
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 
 
-// VolumesCreateBody volumes create body
-// swagger:model VolumesCreateBody
-type VolumesCreateBody struct {
+// VolumeCreateBody
+// swagger:model VolumeCreateBody
+type VolumeCreateBody struct {
 
 
 	// Name of the volume driver to use.
 	// Name of the volume driver to use.
 	// Required: true
 	// Required: true

+ 4 - 4
api/types/volume/volumes_list.go → api/types/volume/volume_list.go

@@ -1,4 +1,4 @@
-package volume // import "github.com/docker/docker/api/types/volume"
+package volume
 
 
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 // DO NOT EDIT THIS FILE
 // DO NOT EDIT THIS FILE
@@ -9,9 +9,9 @@ package volume // import "github.com/docker/docker/api/types/volume"
 
 
 import "github.com/docker/docker/api/types"
 import "github.com/docker/docker/api/types"
 
 
-// VolumesListOKBody volumes list o k body
-// swagger:model VolumesListOKBody
-type VolumesListOKBody struct {
+// VolumeListOKBody
+// swagger:model VolumeListOKBody
+type VolumeListOKBody struct {
 
 
 	// List of volumes
 	// List of volumes
 	// Required: true
 	// Required: true

+ 2 - 2
client/interface.go

@@ -168,10 +168,10 @@ 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 volumetypes.VolumesCreateBody) (types.Volume, error)
+	VolumeCreate(ctx context.Context, options volumetypes.VolumeCreateBody) (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.VolumeListOKBody, error)
 	VolumeRemove(ctx context.Context, volumeID string, force bool) error
 	VolumeRemove(ctx context.Context, volumeID string, force bool) error
 	VolumesPrune(ctx context.Context, pruneFilter filters.Args) (types.VolumesPruneReport, error)
 	VolumesPrune(ctx context.Context, pruneFilter filters.Args) (types.VolumesPruneReport, error)
 }
 }

+ 1 - 1
client/volume_create.go

@@ -9,7 +9,7 @@ import (
 )
 )
 
 
 // VolumeCreate creates a volume in the docker host.
 // VolumeCreate creates a volume in the docker host.
-func (cli *Client) VolumeCreate(ctx context.Context, options volumetypes.VolumesCreateBody) (types.Volume, error) {
+func (cli *Client) VolumeCreate(ctx context.Context, options volumetypes.VolumeCreateBody) (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 {

+ 2 - 2
client/volume_create_test.go

@@ -19,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(), volumetypes.VolumesCreateBody{})
+	_, err := client.VolumeCreate(context.Background(), volumetypes.VolumeCreateBody{})
 	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)
 	}
 	}
@@ -53,7 +53,7 @@ func TestVolumeCreate(t *testing.T) {
 		}),
 		}),
 	}
 	}
 
 
-	volume, err := client.VolumeCreate(context.Background(), volumetypes.VolumesCreateBody{
+	volume, err := client.VolumeCreate(context.Background(), volumetypes.VolumeCreateBody{
 		Name:   "myvolume",
 		Name:   "myvolume",
 		Driver: "mydriver",
 		Driver: "mydriver",
 		DriverOpts: map[string]string{
 		DriverOpts: map[string]string{

+ 2 - 2
client/volume_list.go

@@ -10,8 +10,8 @@ import (
 )
 )
 
 
 // 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) (volumetypes.VolumesListOKBody, error) {
-	var volumes volumetypes.VolumesListOKBody
+func (cli *Client) VolumeList(ctx context.Context, filter filters.Args) (volumetypes.VolumeListOKBody, error) {
+	var volumes volumetypes.VolumeListOKBody
 	query := url.Values{}
 	query := url.Values{}
 
 
 	if filter.Len() > 0 {
 	if filter.Len() > 0 {

+ 1 - 1
client/volume_list_test.go

@@ -69,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(volumetypes.VolumesListOKBody{
+				content, err := json.Marshal(volumetypes.VolumeListOKBody{
 					Volumes: []*types.Volume{
 					Volumes: []*types.Volume{
 						{
 						{
 							Name:   "volume",
 							Name:   "volume",

+ 2 - 2
daemon/cluster/executor/container/container.go

@@ -398,7 +398,7 @@ func (c *containerConfig) hostConfig() *enginecontainer.HostConfig {
 }
 }
 
 
 // This handles the case of volumes that are defined inside a service Mount
 // This handles the case of volumes that are defined inside a service Mount
-func (c *containerConfig) volumeCreateRequest(mount *api.Mount) *volumetypes.VolumesCreateBody {
+func (c *containerConfig) volumeCreateRequest(mount *api.Mount) *volumetypes.VolumeCreateBody {
 	var (
 	var (
 		driverName string
 		driverName string
 		driverOpts map[string]string
 		driverOpts map[string]string
@@ -412,7 +412,7 @@ func (c *containerConfig) volumeCreateRequest(mount *api.Mount) *volumetypes.Vol
 	}
 	}
 
 
 	if mount.VolumeOptions != nil {
 	if mount.VolumeOptions != nil {
-		return &volumetypes.VolumesCreateBody{
+		return &volumetypes.VolumeCreateBody{
 			Name:       mount.Source,
 			Name:       mount.Source,
 			Driver:     driverName,
 			Driver:     driverName,
 			DriverOpts: driverOpts,
 			DriverOpts: driverOpts,

+ 2 - 2
hack/generate-swagger-api.sh

@@ -23,5 +23,5 @@ swagger generate operation -f api/swagger.yaml \
     -n ContainerUpdate \
     -n ContainerUpdate \
     -n ContainerWait \
     -n ContainerWait \
     -n ImageHistory \
     -n ImageHistory \
-    -n VolumesCreate \
-    -n VolumesList
+    -n VolumeCreate \
+    -n VolumeList

+ 1 - 1
hack/integration-cli-on-swarm/host/volume.go

@@ -41,7 +41,7 @@ func createTar(data map[string][]byte) (io.Reader, error) {
 // which is attached to the container.
 // which is attached to the container.
 func createVolumeWithData(cli *client.Client, volumeName string, data map[string][]byte, image string) error {
 func createVolumeWithData(cli *client.Client, volumeName string, data map[string][]byte, image string) error {
 	_, err := cli.VolumeCreate(context.Background(),
 	_, err := cli.VolumeCreate(context.Background(),
-		volume.VolumesCreateBody{
+		volume.VolumeCreateBody{
 			Driver: "local",
 			Driver: "local",
 			Name:   volumeName,
 			Name:   volumeName,
 		})
 		})

+ 1 - 0
hack/validate/gometalinter.json

@@ -6,6 +6,7 @@
     ".*\\.pb\\.go",
     ".*\\.pb\\.go",
     "dockerversion/version_autogen.go",
     "dockerversion/version_autogen.go",
     "api/types/container/container_.*",
     "api/types/container/container_.*",
+    "api/types/volume/volume_.*",
     "integration-cli/"
     "integration-cli/"
   ],
   ],
   "Skip": ["integration-cli/"],
   "Skip": ["integration-cli/"],

+ 3 - 3
integration/plugin/authz/authz_plugin_v2_test.go

@@ -77,7 +77,7 @@ func TestAuthZPluginV2Disable(t *testing.T) {
 	d.Restart(t, "--authorization-plugin="+authzPluginNameWithTag)
 	d.Restart(t, "--authorization-plugin="+authzPluginNameWithTag)
 	d.LoadBusybox(t)
 	d.LoadBusybox(t)
 
 
-	_, err = client.VolumeCreate(context.Background(), volumetypes.VolumesCreateBody{Driver: "local"})
+	_, err = client.VolumeCreate(context.Background(), volumetypes.VolumeCreateBody{Driver: "local"})
 	assert.Assert(t, err != nil)
 	assert.Assert(t, err != nil)
 	assert.Assert(t, strings.Contains(err.Error(), fmt.Sprintf("Error response from daemon: plugin %s failed with error:", authzPluginNameWithTag)))
 	assert.Assert(t, strings.Contains(err.Error(), fmt.Sprintf("Error response from daemon: plugin %s failed with error:", authzPluginNameWithTag)))
 
 
@@ -86,7 +86,7 @@ func TestAuthZPluginV2Disable(t *testing.T) {
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 
 
 	// now test to see if the docker api works.
 	// now test to see if the docker api works.
-	_, err = client.VolumeCreate(context.Background(), volumetypes.VolumesCreateBody{Driver: "local"})
+	_, err = client.VolumeCreate(context.Background(), volumetypes.VolumeCreateBody{Driver: "local"})
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 }
 }
 
 
@@ -104,7 +104,7 @@ func TestAuthZPluginV2RejectVolumeRequests(t *testing.T) {
 	// restart the daemon with the plugin
 	// restart the daemon with the plugin
 	d.Restart(t, "--authorization-plugin="+authzPluginNameWithTag)
 	d.Restart(t, "--authorization-plugin="+authzPluginNameWithTag)
 
 
-	_, err = client.VolumeCreate(context.Background(), volumetypes.VolumesCreateBody{Driver: "local"})
+	_, err = client.VolumeCreate(context.Background(), volumetypes.VolumeCreateBody{Driver: "local"})
 	assert.Assert(t, err != nil)
 	assert.Assert(t, err != nil)
 	assert.Assert(t, strings.Contains(err.Error(), fmt.Sprintf("Error response from daemon: plugin %s failed with error:", authzPluginNameWithTag)))
 	assert.Assert(t, strings.Contains(err.Error(), fmt.Sprintf("Error response from daemon: plugin %s failed with error:", authzPluginNameWithTag)))
 
 

+ 2 - 2
integration/volume/volume_test.go

@@ -26,7 +26,7 @@ func TestVolumesCreateAndList(t *testing.T) {
 	ctx := context.Background()
 	ctx := context.Background()
 
 
 	name := t.Name()
 	name := t.Name()
-	vol, err := client.VolumeCreate(ctx, volumetypes.VolumesCreateBody{
+	vol, err := client.VolumeCreate(ctx, volumetypes.VolumeCreateBody{
 		Name: name,
 		Name: name,
 	})
 	})
 	assert.NilError(t, err)
 	assert.NilError(t, err)
@@ -83,7 +83,7 @@ func TestVolumesInspect(t *testing.T) {
 	now := time.Now().Truncate(time.Minute)
 	now := time.Now().Truncate(time.Minute)
 
 
 	name := t.Name()
 	name := t.Name()
-	_, err := client.VolumeCreate(ctx, volumetypes.VolumesCreateBody{
+	_, err := client.VolumeCreate(ctx, volumetypes.VolumeCreateBody{
 		Name: name,
 		Name: name,
 	})
 	})
 	assert.NilError(t, err)
 	assert.NilError(t, err)