mirror of
https://github.com/moby/moby.git
synced 2026-08-05 07:30:57 +00:00
api/types/system: move DiskUsage, DiskUsageOptions to api/types/backend
These types were introduced inf07242f6d7, but while their description mentions it's the type used for the response, it actually isn't, and it's used by the backend, but ultimately marshaled to the "types.DiskUsage" struct;7dc46c6e0c/daemon/server/router/system/system_routes.go (L254-L270)Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
29
api/types/backend/disk_usage.go
Normal file
29
api/types/backend/disk_usage.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package backend
|
||||
|
||||
import (
|
||||
"github.com/moby/moby/api/types/build"
|
||||
"github.com/moby/moby/api/types/container"
|
||||
"github.com/moby/moby/api/types/image"
|
||||
"github.com/moby/moby/api/types/volume"
|
||||
)
|
||||
|
||||
// DiskUsageOptions holds parameters for system disk usage query.
|
||||
type DiskUsageOptions struct {
|
||||
// Containers controls whether container disk usage should be computed.
|
||||
Containers bool
|
||||
|
||||
// Images controls whether image disk usage should be computed.
|
||||
Images bool
|
||||
|
||||
// Volumes controls whether volume disk usage should be computed.
|
||||
Volumes bool
|
||||
}
|
||||
|
||||
// DiskUsage contains the information returned by the backend for the
|
||||
// GET "/system/df" endpoint.
|
||||
type DiskUsage struct {
|
||||
Images *image.DiskUsage
|
||||
Containers *container.DiskUsage
|
||||
Volumes *volume.DiskUsage
|
||||
BuildCache *build.CacheDiskUsage
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"github.com/moby/moby/api/types/build"
|
||||
"github.com/moby/moby/api/types/container"
|
||||
"github.com/moby/moby/api/types/image"
|
||||
"github.com/moby/moby/api/types/volume"
|
||||
)
|
||||
|
||||
// DiskUsage contains response of Engine API for API 1.49 and greater:
|
||||
// GET "/system/df"
|
||||
type DiskUsage struct {
|
||||
Images *image.DiskUsage
|
||||
Containers *container.DiskUsage
|
||||
Volumes *volume.DiskUsage
|
||||
BuildCache *build.CacheDiskUsage
|
||||
}
|
||||
@@ -4,11 +4,10 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/docker/docker/daemon/server/router/system"
|
||||
"github.com/moby/moby/api/types/backend"
|
||||
"github.com/moby/moby/api/types/container"
|
||||
"github.com/moby/moby/api/types/filters"
|
||||
"github.com/moby/moby/api/types/image"
|
||||
systemtypes "github.com/moby/moby/api/types/system"
|
||||
"github.com/moby/moby/api/types/volume"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/sync/errgroup"
|
||||
@@ -103,10 +102,10 @@ func (daemon *Daemon) layerDiskUsage(ctx context.Context) (int64, error) {
|
||||
|
||||
// SystemDiskUsage returns information about the daemon data disk usage.
|
||||
// Callers must not mutate contents of the returned fields.
|
||||
func (daemon *Daemon) SystemDiskUsage(ctx context.Context, opts system.DiskUsageOptions) (*systemtypes.DiskUsage, error) {
|
||||
func (daemon *Daemon) SystemDiskUsage(ctx context.Context, opts backend.DiskUsageOptions) (*backend.DiskUsage, error) {
|
||||
eg, ctx := errgroup.WithContext(ctx)
|
||||
|
||||
du := &systemtypes.DiskUsage{}
|
||||
du := &backend.DiskUsage{}
|
||||
if opts.Containers {
|
||||
eg.Go(func() (err error) {
|
||||
du.Containers, err = daemon.containerDiskUsage(ctx)
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/moby/moby/api/types"
|
||||
"github.com/moby/moby/api/types/backend"
|
||||
"github.com/moby/moby/api/types/build"
|
||||
"github.com/moby/moby/api/types/events"
|
||||
"github.com/moby/moby/api/types/filters"
|
||||
@@ -13,24 +14,12 @@ import (
|
||||
"github.com/moby/moby/api/types/system"
|
||||
)
|
||||
|
||||
// DiskUsageOptions holds parameters for system disk usage query.
|
||||
type DiskUsageOptions struct {
|
||||
// Containers controls whether container disk usage should be computed.
|
||||
Containers bool
|
||||
|
||||
// Images controls whether image disk usage should be computed.
|
||||
Images bool
|
||||
|
||||
// Volumes controls whether volume disk usage should be computed.
|
||||
Volumes bool
|
||||
}
|
||||
|
||||
// Backend is the methods that need to be implemented to provide
|
||||
// system specific functionality.
|
||||
type Backend interface {
|
||||
SystemInfo(context.Context) (*system.Info, error)
|
||||
SystemVersion(context.Context) (types.Version, error)
|
||||
SystemDiskUsage(ctx context.Context, opts DiskUsageOptions) (*system.DiskUsage, error)
|
||||
SystemDiskUsage(ctx context.Context, opts backend.DiskUsageOptions) (*backend.DiskUsage, error)
|
||||
SubscribeToEvents(since, until time.Time, ef filters.Args) ([]events.Message, chan interface{})
|
||||
UnsubscribeFromEvents(chan interface{})
|
||||
AuthenticateToRegistry(ctx context.Context, authConfig *registry.AuthConfig) (string, error)
|
||||
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
"github.com/docker/docker/daemon/server/router/build"
|
||||
"github.com/docker/docker/pkg/ioutils"
|
||||
"github.com/moby/moby/api/types"
|
||||
"github.com/moby/moby/api/types/backend"
|
||||
buildtypes "github.com/moby/moby/api/types/build"
|
||||
"github.com/moby/moby/api/types/events"
|
||||
"github.com/moby/moby/api/types/filters"
|
||||
@@ -183,11 +184,11 @@ func (s *systemRouter) getDiskUsage(ctx context.Context, w http.ResponseWriter,
|
||||
|
||||
eg, ctx := errgroup.WithContext(ctx)
|
||||
|
||||
var systemDiskUsage *system.DiskUsage
|
||||
var systemDiskUsage *backend.DiskUsage
|
||||
if getContainers || getImages || getVolumes {
|
||||
eg.Go(func() error {
|
||||
var err error
|
||||
systemDiskUsage, err = s.backend.SystemDiskUsage(ctx, DiskUsageOptions{
|
||||
systemDiskUsage, err = s.backend.SystemDiskUsage(ctx, backend.DiskUsageOptions{
|
||||
Containers: getContainers,
|
||||
Images: getImages,
|
||||
Volumes: getVolumes,
|
||||
@@ -238,7 +239,7 @@ func (s *systemRouter) getDiskUsage(ctx context.Context, w http.ResponseWriter,
|
||||
}
|
||||
}
|
||||
|
||||
du := system.DiskUsage{}
|
||||
du := backend.DiskUsage{}
|
||||
if getBuildCache {
|
||||
du.BuildCache = &buildtypes.CacheDiskUsage{
|
||||
TotalSize: builderSize,
|
||||
|
||||
29
vendor/github.com/moby/moby/api/types/backend/disk_usage.go
generated
vendored
Normal file
29
vendor/github.com/moby/moby/api/types/backend/disk_usage.go
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
package backend
|
||||
|
||||
import (
|
||||
"github.com/moby/moby/api/types/build"
|
||||
"github.com/moby/moby/api/types/container"
|
||||
"github.com/moby/moby/api/types/image"
|
||||
"github.com/moby/moby/api/types/volume"
|
||||
)
|
||||
|
||||
// DiskUsageOptions holds parameters for system disk usage query.
|
||||
type DiskUsageOptions struct {
|
||||
// Containers controls whether container disk usage should be computed.
|
||||
Containers bool
|
||||
|
||||
// Images controls whether image disk usage should be computed.
|
||||
Images bool
|
||||
|
||||
// Volumes controls whether volume disk usage should be computed.
|
||||
Volumes bool
|
||||
}
|
||||
|
||||
// DiskUsage contains the information returned by the backend for the
|
||||
// GET "/system/df" endpoint.
|
||||
type DiskUsage struct {
|
||||
Images *image.DiskUsage
|
||||
Containers *container.DiskUsage
|
||||
Volumes *volume.DiskUsage
|
||||
BuildCache *build.CacheDiskUsage
|
||||
}
|
||||
17
vendor/github.com/moby/moby/api/types/system/disk_usage.go
generated
vendored
17
vendor/github.com/moby/moby/api/types/system/disk_usage.go
generated
vendored
@@ -1,17 +0,0 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"github.com/moby/moby/api/types/build"
|
||||
"github.com/moby/moby/api/types/container"
|
||||
"github.com/moby/moby/api/types/image"
|
||||
"github.com/moby/moby/api/types/volume"
|
||||
)
|
||||
|
||||
// DiskUsage contains response of Engine API for API 1.49 and greater:
|
||||
// GET "/system/df"
|
||||
type DiskUsage struct {
|
||||
Images *image.DiskUsage
|
||||
Containers *container.DiskUsage
|
||||
Volumes *volume.DiskUsage
|
||||
BuildCache *build.CacheDiskUsage
|
||||
}
|
||||
Reference in New Issue
Block a user