8000 api/types: move more types to sub-packages by thaJeztah · Pull Request #47936 · moby/moby · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
api/types: move VolumesPruneReport to api/types/volume
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
  • Loading branch information
thaJeztah committed Jun 10, 2024
commit 162ef4f8d1f043d93d9079c53d5c5bc0e1c8be46
6 changes: 2 additions & 4 deletions api/server/router/volume/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ package volume // import "github.com/docker/docker/api/server/router/volume"
import (
"context"

"github.com/docker/docker/volume/service/opts"
// TODO return types need to be refactored into pkg
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/volume"
"github.com/docker/docker/volume/service/opts"
)

// Backend is the methods that need to be implemented to provide
Expand All @@ -17,7 +15,7 @@ type Backend interface {
Get(ctx context.Context, name string, opts ...opts.GetOption) (*volume.Volume, error)
Create(ctx context.Context, name, driverName string, opts ...opts.CreateOption) (*volume.Volume, error)
Remove(ctx context.Context, name string, opts ...opts.RemoveOption) error
Prune(ctx context.Context, pruneFilters filters.Args) (*types.VolumesPruneReport, error)
Prune(ctx context.Context, pruneFilters filters.Args) (*volume.PruneReport, error)
}

// ClusterBackend is the backend used for Swarm Cluster Volumes. Regular
Expand Down
3 changes: 1 addition & 2 deletions api/server/router/volume/volume_routes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"gotest.tools/v3/assert"

"github.com/docker/docker/api/server/httputils"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/volume"
"github.com/docker/docker/errdefs"
Expand Down Expand Up @@ -636,7 +635,7 @@ func (b *fakeVolumeBackend) Remove(_ context.Context, name string, o ...opts.Rem
return nil
}

func (b *fakeVolumeBackend) Prune(_ context.Context, _ filters.Args) (*types.VolumesPruneReport, error) {
func (b *fakeVolumeBackend) Prune(_ context.Context, _ filters.Args) (*volume.PruneReport, error) {
return nil, nil
}

Expand Down
7 changes: 0 additions & 7 deletions api/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,13 +419,6 @@ type DiskUsage struct {
BuilderSize int64 `json:",omitempty"` // Deprecated: deprecated in API 1.38, and no longer used since API 1.40.
}

// VolumesPruneReport contains the response for Engine API:
// POST "/volumes/prune"
type VolumesPruneReport struct {
VolumesDeleted []string
SpaceReclaimed uint64
}

// ImagesPruneReport contains the response for Engine API:
// POST "/images/prune"
type ImagesPruneReport struct {
Expand Down
7 changes: 7 additions & 0 deletions api/types/types_deprecated.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@ package types
import (
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/volume"
)

// VolumesPruneReport contains the response for Engine API:
// POST "/volumes/prune".
//
// Deprecated: use [volume.PruneReport].
type VolumesPruneReport = volume.PruneReport

// NetworkCreateRequest is the request message sent to the server for network create call.
//
// Deprecated: use [network.CreateRequest].
Expand Down
7 changes: 7 additions & 0 deletions api/types/volume/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,10 @@ import "github.com/docker/docker/api/types/filters"
type ListOptions struct {
Filters filters.Args
}

// PruneReport contains the response for Engine API:
// POST "/volumes/prune"
type PruneReport struct {
VolumesDeleted []string
SpaceReclaimed uint64
}
2 changes: 1 addition & 1 deletion client/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ type VolumeAPIClient interface {
VolumeInspectWithRaw(ctx context.Context, volumeID string) (volume.Volume, []byte, error)
VolumeList(ctx context.Context, options volume.ListOptions) (volume.ListResponse, 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) (volume.PruneReport, error)
VolumeUpdate(ctx context.Context, volumeID string, version swarm.Version, options volume.UpdateOptions) error
}

Expand Down
6 changes: 3 additions & 3 deletions client/volume_prune.go
< 9E88 /tr>
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import (
"encoding/json"
"fmt"

"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/volume"
)

// VolumesPrune requests the daemon to delete unused data
func (cli *Client) VolumesPrune(ctx context.Context, pruneFilters filters.Args) (types.VolumesPruneReport, error) {
var report types.VolumesPruneReport
func (cli *Client) VolumesPrune(ctx context.Context, pruneFilters filters.Args) (volume.PruneReport, error) {
var report volume.PruneReport

if err := cli.NewVersionError(ctx, "1.25", "volume prune"); err != nil {
return report, err
Expand Down
5 changes: 2 additions & 3 deletions volume/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"sync/atomic"

"github.com/containerd/log"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/events"
"github.com/docker/docker/api/types/filters"
volumetypes "github.com/docker/docker/api/types/volume"
Expand Down Expand Up @@ -204,7 +203,7 @@ func (s *VolumesService) LocalVolumesSize(ctx context.Context) ([]*volumetypes.V
// Prune removes (local) volumes which match the past in filter arguments.
// Note that this intentionally skips volumes with mount options as there would
// be no space reclaimed in this case.
func (s *VolumesService) Prune(ctx context.Context, filter filters.Args) (*types.VolumesPruneReport, error) {
func (s *VolumesService) Prune(ctx context.Context, filter filters.Args) (*volumetypes.PruneReport, error) {
if !atomic.CompareAndSwapInt32(&s.pruneRunning, 0, 1) {
return nil, errdefs.Conflict(errors.New("a prune operation is already running"))
}
Expand All @@ -226,7 +225,7 @@ func (s *VolumesService) Prune(ctx context.Context, filter filters.Args) (*types
return nil, err
}

rep := &types.VolumesPruneReport{VolumesDeleted: make([]string, 0, len(ls))}
rep := &volumetypes.PruneReport{VolumesDeleted: make([]string, 0, len(ls))}
< 46EA span class='blob-code-inner blob-code-marker ' data-code-marker=" "> for _, v := range ls {
select {
case <-ctx.Done():
Expand Down
0