api/types: move disk usage structs to per type packages

Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
This commit is contained in:
Austin Vazquez
2025-11-05 10:00:05 -06:00
parent 689776a4fa
commit fabdccbe10
15 changed files with 87 additions and 116 deletions

View File

@@ -2061,8 +2061,10 @@ definitions:
ImagesDiskUsage:
type: "object"
x-go-name: "DiskUsage"
x-go-package: "github.com/moby/moby/api/types/image"
description: |
ImagesDiskUsage represents system data usage for image resources.
represents system data usage for image resources.
properties:
ActiveImages:
description: |
@@ -2097,8 +2099,6 @@ definitions:
x-nullable: true
x-go-type:
type: Summary
import:
package: github.com/moby/moby/api/types/image
AuthConfig:
type: "object"
@@ -2244,8 +2244,10 @@ definitions:
VolumesDiskUsage:
type: "object"
x-go-name: "DiskUsage"
x-go-package: "github.com/moby/moby/api/types/volume"
description: |
VolumesDiskUsage represents system data usage for volume resources.
represents system data usage for volume resources.
properties:
ActiveVolumes:
description: |
@@ -2280,8 +2282,6 @@ definitions:
x-nullable: true
x-go-type:
type: Volume
import:
package: github.com/moby/moby/api/types/volume
VolumeCreateRequest:
description: "Volume configuration"
@@ -2858,8 +2858,10 @@ definitions:
BuildCacheDiskUsage:
type: "object"
x-go-name: "DiskUsage"
x-go-package: "github.com/moby/moby/api/types/build"
description: |
BuildCacheDiskUsage represents system data usage for build cache resources.
represents system data usage for build cache resources.
properties:
ActiveBuildCacheRecords:
description: |
@@ -2894,8 +2896,6 @@ definitions:
x-nullable: true
x-go-type:
type: CacheRecord
import:
package: github.com/moby/moby/api/types/build
ImageID:
type: "object"
@@ -5582,8 +5582,10 @@ definitions:
ContainersDiskUsage:
type: "object"
x-go-name: "DiskUsage"
x-go-package: "github.com/moby/moby/api/types/container"
description: |
ContainersDiskUsage provides system data usage information for container resources.
represents system data usage information for container resources.
properties:
ActiveContainers:
description: |
@@ -5618,8 +5620,6 @@ definitions:
x-nullable: true
x-go-type:
type: Summary
import:
package: github.com/moby/moby/api/types/container
Driver:
description: "Driver represents a driver (network, logging, secrets)."

View File

@@ -2061,8 +2061,10 @@ definitions:
ImagesDiskUsage:
type: "object"
x-go-name: "DiskUsage"
x-go-package: "github.com/moby/moby/api/types/image"
description: |
ImagesDiskUsage represents system data usage for image resources.
represents system data usage for image resources.
properties:
ActiveImages:
description: |
@@ -2097,8 +2099,6 @@ definitions:
x-nullable: true
x-go-type:
type: Summary
import:
package: github.com/moby/moby/api/types/image
AuthConfig:
type: "object"
@@ -2244,8 +2244,10 @@ definitions:
VolumesDiskUsage:
type: "object"
x-go-name: "DiskUsage"
x-go-package: "github.com/moby/moby/api/types/volume"
description: |
VolumesDiskUsage represents system data usage for volume resources.
represents system data usage for volume resources.
properties:
ActiveVolumes:
description: |
@@ -2280,8 +2282,6 @@ definitions:
x-nullable: true
x-go-type:
type: Volume
import:
package: github.com/moby/moby/api/types/volume
VolumeCreateRequest:
description: "Volume configuration"
@@ -2858,8 +2858,10 @@ definitions:
BuildCacheDiskUsage:
type: "object"
x-go-name: "DiskUsage"
x-go-package: "github.com/moby/moby/api/types/build"
description: |
BuildCacheDiskUsage represents system data usage for build cache resources.
represents system data usage for build cache resources.
properties:
ActiveBuildCacheRecords:
description: |
@@ -2894,8 +2896,6 @@ definitions:
x-nullable: true
x-go-type:
type: CacheRecord
import:
package: github.com/moby/moby/api/types/build
ImageID:
type: "object"
@@ -5582,8 +5582,10 @@ definitions:
ContainersDiskUsage:
type: "object"
x-go-name: "DiskUsage"
x-go-package: "github.com/moby/moby/api/types/container"
description: |
ContainersDiskUsage provides system data usage information for container resources.
represents system data usage information for container resources.
properties:
ActiveContainers:
description: |
@@ -5618,8 +5620,6 @@ definitions:
x-nullable: true
x-go-type:
type: Summary
import:
package: github.com/moby/moby/api/types/container
Driver:
description: "Driver represents a driver (network, logging, secrets)."

View File

@@ -1,18 +1,14 @@
// Code generated by go-swagger; DO NOT EDIT.
package system
package build
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"github.com/moby/moby/api/types/build"
)
// BuildCacheDiskUsage BuildCacheDiskUsage represents system data usage for build cache resources.
// DiskUsage represents system data usage for build cache resources.
//
// swagger:model BuildCacheDiskUsage
type BuildCacheDiskUsage struct {
// swagger:model DiskUsage
type DiskUsage struct {
// Count of active build cache records.
//
@@ -21,7 +17,7 @@ type BuildCacheDiskUsage struct {
// List of build cache records.
//
Items []*build.CacheRecord `json:"Items,omitempty"`
Items []*CacheRecord `json:"Items,omitempty"`
// Disk space that can be reclaimed by removing inactive build cache records.
//

View File

@@ -1,18 +1,14 @@
// Code generated by go-swagger; DO NOT EDIT.
package system
package container
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"github.com/moby/moby/api/types/container"
)
// ContainersDiskUsage ContainersDiskUsage provides system data usage information for container resources.
// DiskUsage represents system data usage information for container resources.
//
// swagger:model ContainersDiskUsage
type ContainersDiskUsage struct {
// swagger:model DiskUsage
type DiskUsage struct {
// Count of active containers.
//
@@ -21,7 +17,7 @@ type ContainersDiskUsage struct {
// List of container summaries.
//
Items []*container.Summary `json:"Items,omitempty"`
Items []*Summary `json:"Items,omitempty"`
// Disk space that can be reclaimed by removing inactive containers.
//

View File

@@ -1,18 +1,14 @@
// Code generated by go-swagger; DO NOT EDIT.
package system
package image
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"github.com/moby/moby/api/types/image"
)
// ImagesDiskUsage ImagesDiskUsage represents system data usage for image resources.
// DiskUsage represents system data usage for image resources.
//
// swagger:model ImagesDiskUsage
type ImagesDiskUsage struct {
// swagger:model DiskUsage
type DiskUsage struct {
// Count of active images.
//
@@ -21,7 +17,7 @@ type ImagesDiskUsage struct {
// List of image summaries.
//
Items []*image.Summary `json:"Items,omitempty"`
Items []*Summary `json:"Items,omitempty"`
// Disk space that can be reclaimed by removing unused images.
//

View File

@@ -26,10 +26,10 @@ const (
type DiskUsage struct {
LegacyDiskUsage
ImageUsage *ImagesDiskUsage `json:"ImageUsage,omitempty"`
ContainerUsage *ContainersDiskUsage `json:"ContainerUsage,omitempty"`
VolumeUsage *VolumesDiskUsage `json:"VolumeUsage,omitempty"`
BuildCacheUsage *BuildCacheDiskUsage `json:"BuildCacheUsage,omitempty"`
ImageUsage *image.DiskUsage `json:"ImageUsage,omitempty"`
ContainerUsage *container.DiskUsage `json:"ContainerUsage,omitempty"`
VolumeUsage *volume.DiskUsage `json:"VolumeUsage,omitempty"`
BuildCacheUsage *build.DiskUsage `json:"BuildCacheUsage,omitempty"`
}
type LegacyDiskUsage struct {

View File

@@ -1,18 +1,14 @@
// Code generated by go-swagger; DO NOT EDIT.
package system
package volume
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"github.com/moby/moby/api/types/volume"
)
// VolumesDiskUsage VolumesDiskUsage represents system data usage for volume resources.
// DiskUsage represents system data usage for volume resources.
//
// swagger:model VolumesDiskUsage
type VolumesDiskUsage struct {
// swagger:model DiskUsage
type DiskUsage struct {
// Count of active volumes.
//
@@ -21,7 +17,7 @@ type VolumesDiskUsage struct {
// List of volumes.
//
Items []*volume.Volume `json:"Items,omitempty"`
Items []*Volume `json:"Items,omitempty"`
// Disk space that can be reclaimed by removing inactive volumes.
//

View File

@@ -28,7 +28,7 @@ func TestDiskUsage(t *testing.T) {
}
return mockJSONResponse(http.StatusOK, nil, system.DiskUsage{
ImageUsage: &system.ImagesDiskUsage{
ImageUsage: &image.DiskUsage{
ActiveImages: 0,
TotalImages: 0,
Reclaimable: 0,

View File

@@ -13,10 +13,13 @@ import (
"github.com/moby/moby/api/pkg/authconfig"
"github.com/moby/moby/api/types"
buildtypes "github.com/moby/moby/api/types/build"
"github.com/moby/moby/api/types/container"
"github.com/moby/moby/api/types/events"
"github.com/moby/moby/api/types/image"
"github.com/moby/moby/api/types/registry"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/api/types/system"
"github.com/moby/moby/api/types/volume"
"github.com/moby/moby/v2/daemon/internal/compat"
"github.com/moby/moby/v2/daemon/internal/filters"
"github.com/moby/moby/v2/daemon/internal/timestamp"
@@ -216,7 +219,7 @@ func (s *systemRouter) getDiskUsage(ctx context.Context, w http.ResponseWriter,
var v system.DiskUsage
if systemDiskUsage != nil && systemDiskUsage.Images != nil {
v.ImageUsage = &system.ImagesDiskUsage{
v.ImageUsage = &image.DiskUsage{
ActiveImages: systemDiskUsage.Images.ActiveCount,
Reclaimable: systemDiskUsage.Images.Reclaimable,
TotalImages: systemDiskUsage.Images.TotalCount,
@@ -231,7 +234,7 @@ func (s *systemRouter) getDiskUsage(ctx context.Context, w http.ResponseWriter,
}
}
if systemDiskUsage != nil && systemDiskUsage.Containers != nil {
v.ContainerUsage = &system.ContainersDiskUsage{
v.ContainerUsage = &container.DiskUsage{
ActiveContainers: systemDiskUsage.Containers.ActiveCount,
Reclaimable: systemDiskUsage.Containers.Reclaimable,
TotalContainers: systemDiskUsage.Containers.TotalCount,
@@ -245,7 +248,7 @@ func (s *systemRouter) getDiskUsage(ctx context.Context, w http.ResponseWriter,
}
}
if systemDiskUsage != nil && systemDiskUsage.Volumes != nil {
v.VolumeUsage = &system.VolumesDiskUsage{
v.VolumeUsage = &volume.DiskUsage{
ActiveVolumes: systemDiskUsage.Volumes.ActiveCount,
TotalSize: systemDiskUsage.Volumes.TotalSize,
Reclaimable: systemDiskUsage.Volumes.Reclaimable,
@@ -259,7 +262,7 @@ func (s *systemRouter) getDiskUsage(ctx context.Context, w http.ResponseWriter,
}
}
if getBuildCache {
v.BuildCacheUsage = &system.BuildCacheDiskUsage{
v.BuildCacheUsage = &buildtypes.DiskUsage{
TotalBuildCacheRecords: int64(len(buildCache)),
}

View File

@@ -37,6 +37,10 @@ generate_operation() {
#region -------- Models --------
generate_model types/build <<- 'EOT'
BuildCacheDiskUsage
EOT
generate_model types/common <<- 'EOT'
ErrorResponse
IDResponse
@@ -49,12 +53,14 @@ generate_model types/container <<- 'EOT'
ContainerUpdateResponse
ContainerWaitExitError
ContainerWaitResponse
ContainersDiskUsage
FilesystemChange
PortSummary
EOT
generate_model types/image <<- 'EOT'
ImageDeleteResponseItem
ImagesDiskUsage
EOT
# ImageSummary
# TODO: Restore when go-swagger is updated
@@ -95,13 +101,6 @@ generate_model types/storage <<- 'EOT'
Storage
EOT
generate_model types/system <<- 'EOT'
BuildCacheDiskUsage
ContainersDiskUsage
ImagesDiskUsage
VolumesDiskUsage
EOT
generate_model types/swarm <<- 'EOT'
ServiceCreateResponse
ServiceUpdateResponse
@@ -111,6 +110,7 @@ generate_model types/volume <<- 'EOT'
Volume
VolumeCreateRequest
VolumeListResponse
VolumesDiskUsage
EOT
#endregion

View File

@@ -1,18 +1,14 @@
// Code generated by go-swagger; DO NOT EDIT.
package system
package build
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"github.com/moby/moby/api/types/build"
)
// BuildCacheDiskUsage BuildCacheDiskUsage represents system data usage for build cache resources.
// DiskUsage represents system data usage for build cache resources.
//
// swagger:model BuildCacheDiskUsage
type BuildCacheDiskUsage struct {
// swagger:model DiskUsage
type DiskUsage struct {
// Count of active build cache records.
//
@@ -21,7 +17,7 @@ type BuildCacheDiskUsage struct {
// List of build cache records.
//
Items []*build.CacheRecord `json:"Items,omitempty"`
Items []*CacheRecord `json:"Items,omitempty"`
// Disk space that can be reclaimed by removing inactive build cache records.
//

View File

@@ -1,18 +1,14 @@
// Code generated by go-swagger; DO NOT EDIT.
package system
package container
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"github.com/moby/moby/api/types/container"
)
// ContainersDiskUsage ContainersDiskUsage provides system data usage information for container resources.
// DiskUsage represents system data usage information for container resources.
//
// swagger:model ContainersDiskUsage
type ContainersDiskUsage struct {
// swagger:model DiskUsage
type DiskUsage struct {
// Count of active containers.
//
@@ -21,7 +17,7 @@ type ContainersDiskUsage struct {
// List of container summaries.
//
Items []*container.Summary `json:"Items,omitempty"`
Items []*Summary `json:"Items,omitempty"`
// Disk space that can be reclaimed by removing inactive containers.
//

View File

@@ -1,18 +1,14 @@
// Code generated by go-swagger; DO NOT EDIT.
package system
package image
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"github.com/moby/moby/api/types/image"
)
// ImagesDiskUsage ImagesDiskUsage represents system data usage for image resources.
// DiskUsage represents system data usage for image resources.
//
// swagger:model ImagesDiskUsage
type ImagesDiskUsage struct {
// swagger:model DiskUsage
type DiskUsage struct {
// Count of active images.
//
@@ -21,7 +17,7 @@ type ImagesDiskUsage struct {
// List of image summaries.
//
Items []*image.Summary `json:"Items,omitempty"`
Items []*Summary `json:"Items,omitempty"`
// Disk space that can be reclaimed by removing unused images.
//

View File

@@ -26,10 +26,10 @@ const (
type DiskUsage struct {
LegacyDiskUsage
ImageUsage *ImagesDiskUsage `json:"ImageUsage,omitempty"`
ContainerUsage *ContainersDiskUsage `json:"ContainerUsage,omitempty"`
VolumeUsage *VolumesDiskUsage `json:"VolumeUsage,omitempty"`
BuildCacheUsage *BuildCacheDiskUsage `json:"BuildCacheUsage,omitempty"`
ImageUsage *image.DiskUsage `json:"ImageUsage,omitempty"`
ContainerUsage *container.DiskUsage `json:"ContainerUsage,omitempty"`
VolumeUsage *volume.DiskUsage `json:"VolumeUsage,omitempty"`
BuildCacheUsage *build.DiskUsage `json:"BuildCacheUsage,omitempty"`
}
type LegacyDiskUsage struct {

View File

@@ -1,18 +1,14 @@
// Code generated by go-swagger; DO NOT EDIT.
package system
package volume
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"github.com/moby/moby/api/types/volume"
)
// VolumesDiskUsage VolumesDiskUsage represents system data usage for volume resources.
// DiskUsage represents system data usage for volume resources.
//
// swagger:model VolumesDiskUsage
type VolumesDiskUsage struct {
// swagger:model DiskUsage
type DiskUsage struct {
// Count of active volumes.
//
@@ -21,7 +17,7 @@ type VolumesDiskUsage struct {
// List of volumes.
//
Items []*volume.Volume `json:"Items,omitempty"`
Items []*Volume `json:"Items,omitempty"`
// Disk space that can be reclaimed by removing inactive volumes.
//