1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Fix swagger volume type generation

This was broken by bf6a790f00

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
Brian Goff 2018-05-14 11:03:48 -04:00
parent a79d04ae55
commit b16b125bb4
14 changed files with 29 additions and 28 deletions

View file

@ -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"))

View file

@ -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 // VolumeCreateBody
// swagger:model VolumesCreateBody // swagger:model VolumeCreateBody
type VolumesCreateBody struct { type VolumeCreateBody struct {
// Name of the volume driver to use. // Name of the volume driver to use.
// Required: true // Required: true

View file

@ -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 // VolumeListOKBody
// swagger:model VolumesListOKBody // swagger:model VolumeListOKBody
type VolumesListOKBody struct { type VolumeListOKBody struct {
// List of volumes // List of volumes
// Required: true // Required: true

View file

@ -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)
} }

View file

@ -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 {

View file

@ -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{

View file

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

View file

@ -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",

View file

@ -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,

View file

@ -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 VolumeCreate \
-n VolumesList -n VolumeList

View file

@ -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,
}) })

View file

@ -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/"],

View file

@ -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)))

View file

@ -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)