From 3cae9fef16936e1c987443b6f2545c491f9a1019 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sat, 5 Mar 2022 10:51:34 +0100 Subject: [PATCH] imports: remove "volumetypes" aliases for api/types/volume Signed-off-by: Sebastiaan van Stijn --- api/server/router/volume/volume_routes.go | 12 ++++++------ client/volume_inspect_test.go | 4 ++-- client/volume_list.go | 6 +++--- daemon/cluster/executor/container/container.go | 9 ++++----- integration/plugin/authz/authz_plugin_v2_test.go | 8 ++++---- 5 files changed, 19 insertions(+), 20 deletions(-) diff --git a/api/server/router/volume/volume_routes.go b/api/server/router/volume/volume_routes.go index 195bc8b409..5705b08699 100644 --- a/api/server/router/volume/volume_routes.go +++ b/api/server/router/volume/volume_routes.go @@ -6,7 +6,7 @@ import ( "github.com/docker/docker/api/server/httputils" "github.com/docker/docker/api/types/filters" - volumetypes "github.com/docker/docker/api/types/volume" + "github.com/docker/docker/api/types/volume" "github.com/docker/docker/volume/service/opts" "github.com/pkg/errors" ) @@ -24,7 +24,7 @@ func (v *volumeRouter) getVolumesList(ctx context.Context, w http.ResponseWriter if err != nil { return err } - return httputils.WriteJSON(w, http.StatusOK, &volumetypes.VolumeListOKBody{Volumes: volumes, Warnings: warnings}) + return httputils.WriteJSON(w, http.StatusOK, &volume.VolumeListOKBody{Volumes: volumes, Warnings: warnings}) } func (v *volumeRouter) getVolumeByName(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error { @@ -32,11 +32,11 @@ func (v *volumeRouter) getVolumeByName(ctx context.Context, w http.ResponseWrite return err } - volume, err := v.backend.Get(ctx, vars["name"], opts.WithGetResolveStatus) + vol, err := v.backend.Get(ctx, vars["name"], opts.WithGetResolveStatus) if err != nil { return err } - return httputils.WriteJSON(w, http.StatusOK, volume) + return httputils.WriteJSON(w, http.StatusOK, vol) } func (v *volumeRouter) postVolumesCreate(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error { @@ -49,11 +49,11 @@ func (v *volumeRouter) postVolumesCreate(ctx context.Context, w http.ResponseWri return err } - volume, err := v.backend.Create(ctx, req.Name, req.Driver, opts.WithCreateOptions(req.DriverOpts), opts.WithCreateLabels(req.Labels)) + vol, err := v.backend.Create(ctx, req.Name, req.Driver, opts.WithCreateOptions(req.DriverOpts), opts.WithCreateLabels(req.Labels)) if err != nil { return err } - return httputils.WriteJSON(w, http.StatusCreated, volume) + return httputils.WriteJSON(w, http.StatusCreated, vol) } func (v *volumeRouter) deleteVolumes(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error { diff --git a/client/volume_inspect_test.go b/client/volume_inspect_test.go index 70b82729b8..be88f5f103 100644 --- a/client/volume_inspect_test.go +++ b/client/volume_inspect_test.go @@ -76,7 +76,7 @@ func TestVolumeInspect(t *testing.T) { }), } - volume, err := client.VolumeInspect(context.Background(), "volume_id") + vol, err := client.VolumeInspect(context.Background(), "volume_id") assert.NilError(t, err) - assert.Check(t, is.DeepEqual(expected, volume)) + assert.Check(t, is.DeepEqual(expected, vol)) } diff --git a/client/volume_list.go b/client/volume_list.go index 942498dde2..3ad8bf22a9 100644 --- a/client/volume_list.go +++ b/client/volume_list.go @@ -6,12 +6,12 @@ import ( "net/url" "github.com/docker/docker/api/types/filters" - volumetypes "github.com/docker/docker/api/types/volume" + "github.com/docker/docker/api/types/volume" ) // VolumeList returns the volumes configured in the docker host. -func (cli *Client) VolumeList(ctx context.Context, filter filters.Args) (volumetypes.VolumeListOKBody, error) { - var volumes volumetypes.VolumeListOKBody +func (cli *Client) VolumeList(ctx context.Context, filter filters.Args) (volume.VolumeListOKBody, error) { + var volumes volume.VolumeListOKBody query := url.Values{} if filter.Len() > 0 { diff --git a/daemon/cluster/executor/container/container.go b/daemon/cluster/executor/container/container.go index ecc8483036..2c8c63d028 100644 --- a/daemon/cluster/executor/container/container.go +++ b/daemon/cluster/executor/container/container.go @@ -7,8 +7,6 @@ import ( "strconv" "strings" - "github.com/sirupsen/logrus" - "github.com/docker/distribution/reference" "github.com/docker/docker/api/types" enginecontainer "github.com/docker/docker/api/types/container" @@ -16,7 +14,7 @@ import ( "github.com/docker/docker/api/types/filters" enginemount "github.com/docker/docker/api/types/mount" "github.com/docker/docker/api/types/network" - volumetypes "github.com/docker/docker/api/types/volume" + "github.com/docker/docker/api/types/volume" "github.com/docker/docker/daemon/cluster/convert" executorpkg "github.com/docker/docker/daemon/cluster/executor" clustertypes "github.com/docker/docker/daemon/cluster/provider" @@ -28,6 +26,7 @@ import ( "github.com/moby/swarmkit/v2/api" "github.com/moby/swarmkit/v2/api/genericresource" "github.com/moby/swarmkit/v2/template" + "github.com/sirupsen/logrus" ) const ( @@ -406,7 +405,7 @@ func (c *containerConfig) hostConfig() *enginecontainer.HostConfig { } // This handles the case of volumes that are defined inside a service Mount -func (c *containerConfig) volumeCreateRequest(mount *api.Mount) *volumetypes.VolumeCreateBody { +func (c *containerConfig) volumeCreateRequest(mount *api.Mount) *volume.VolumeCreateBody { var ( driverName string driverOpts map[string]string @@ -420,7 +419,7 @@ func (c *containerConfig) volumeCreateRequest(mount *api.Mount) *volumetypes.Vol } if mount.VolumeOptions != nil { - return &volumetypes.VolumeCreateBody{ + return &volume.VolumeCreateBody{ Name: mount.Source, Driver: driverName, DriverOpts: driverOpts, diff --git a/integration/plugin/authz/authz_plugin_v2_test.go b/integration/plugin/authz/authz_plugin_v2_test.go index 173d0a5df6..17f1b2964d 100644 --- a/integration/plugin/authz/authz_plugin_v2_test.go +++ b/integration/plugin/authz/authz_plugin_v2_test.go @@ -13,7 +13,7 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" - volumetypes "github.com/docker/docker/api/types/volume" + "github.com/docker/docker/api/types/volume" "github.com/docker/docker/client" "github.com/docker/docker/integration/internal/container" "github.com/docker/docker/integration/internal/requirement" @@ -75,7 +75,7 @@ func TestAuthZPluginV2Disable(t *testing.T) { d.Restart(t, "--authorization-plugin="+authzPluginNameWithTag) d.LoadBusybox(t) - _, err = c.VolumeCreate(context.Background(), volumetypes.VolumeCreateBody{Driver: "local"}) + _, err = c.VolumeCreate(context.Background(), volume.VolumeCreateBody{Driver: "local"}) assert.Assert(t, err != nil) assert.Assert(t, strings.Contains(err.Error(), fmt.Sprintf("Error response from daemon: plugin %s failed with error:", authzPluginNameWithTag))) @@ -84,7 +84,7 @@ func TestAuthZPluginV2Disable(t *testing.T) { assert.NilError(t, err) // now test to see if the docker api works. - _, err = c.VolumeCreate(context.Background(), volumetypes.VolumeCreateBody{Driver: "local"}) + _, err = c.VolumeCreate(context.Background(), volume.VolumeCreateBody{Driver: "local"}) assert.NilError(t, err) } @@ -101,7 +101,7 @@ func TestAuthZPluginV2RejectVolumeRequests(t *testing.T) { // restart the daemon with the plugin d.Restart(t, "--authorization-plugin="+authzPluginNameWithTag) - _, err = c.VolumeCreate(context.Background(), volumetypes.VolumeCreateBody{Driver: "local"}) + _, err = c.VolumeCreate(context.Background(), volume.VolumeCreateBody{Driver: "local"}) assert.Assert(t, err != nil) assert.Assert(t, strings.Contains(err.Error(), fmt.Sprintf("Error response from daemon: plugin %s failed with error:", authzPluginNameWithTag)))