From fabdccbe10e6f083b0bb2808201b8ca2c43f55f2 Mon Sep 17 00:00:00 2001 From: Austin Vazquez Date: Wed, 5 Nov 2025 10:00:05 -0600 Subject: [PATCH] api/types: move disk usage structs to per type packages Signed-off-by: Austin Vazquez --- api/docs/v1.52.yaml | 24 +++++++++---------- api/swagger.yaml | 24 +++++++++---------- .../disk_usage.go} | 14 ++++------- .../types/container/disk_usage.go | 14 ++++------- .../types/image/disk_usage.go | 14 ++++------- api/types/system/disk_usage.go | 8 +++---- .../types/volume/disk_usage.go | 14 ++++------- client/system_disk_usage_test.go | 2 +- daemon/server/router/system/system_routes.go | 11 +++++---- hack/generate-swagger-api.sh | 14 +++++------ .../disk_usage.go} | 14 ++++------- .../moby/api/types/container/disk_usage.go | 14 ++++------- .../moby/moby/api/types/image/disk_usage.go | 14 ++++------- .../moby/moby/api/types/system/disk_usage.go | 8 +++---- .../moby/moby/api/types/volume/disk_usage.go | 14 ++++------- 15 files changed, 87 insertions(+), 116 deletions(-) rename api/types/{system/build_cache_disk_usage.go => build/disk_usage.go} (72%) rename vendor/github.com/moby/moby/api/types/system/containers_disk_usage.go => api/types/container/disk_usage.go (69%) rename vendor/github.com/moby/moby/api/types/system/images_disk_usage.go => api/types/image/disk_usage.go (71%) rename vendor/github.com/moby/moby/api/types/system/volumes_disk_usage.go => api/types/volume/disk_usage.go (71%) rename vendor/github.com/moby/moby/api/types/{system/build_cache_disk_usage.go => build/disk_usage.go} (72%) rename api/types/system/containers_disk_usage.go => vendor/github.com/moby/moby/api/types/container/disk_usage.go (69%) rename api/types/system/images_disk_usage.go => vendor/github.com/moby/moby/api/types/image/disk_usage.go (71%) rename api/types/system/volumes_disk_usage.go => vendor/github.com/moby/moby/api/types/volume/disk_usage.go (71%) diff --git a/api/docs/v1.52.yaml b/api/docs/v1.52.yaml index 52e0e5c18b..36668afb2a 100644 --- a/api/docs/v1.52.yaml +++ b/api/docs/v1.52.yaml @@ -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)." diff --git a/api/swagger.yaml b/api/swagger.yaml index 52e0e5c18b..36668afb2a 100644 --- a/api/swagger.yaml +++ b/api/swagger.yaml @@ -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)." diff --git a/api/types/system/build_cache_disk_usage.go b/api/types/build/disk_usage.go similarity index 72% rename from api/types/system/build_cache_disk_usage.go rename to api/types/build/disk_usage.go index 2bf617b869..872d389f75 100644 --- a/api/types/system/build_cache_disk_usage.go +++ b/api/types/build/disk_usage.go @@ -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. // diff --git a/vendor/github.com/moby/moby/api/types/system/containers_disk_usage.go b/api/types/container/disk_usage.go similarity index 69% rename from vendor/github.com/moby/moby/api/types/system/containers_disk_usage.go rename to api/types/container/disk_usage.go index b7eda27e48..d708e22d84 100644 --- a/vendor/github.com/moby/moby/api/types/system/containers_disk_usage.go +++ b/api/types/container/disk_usage.go @@ -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. // diff --git a/vendor/github.com/moby/moby/api/types/system/images_disk_usage.go b/api/types/image/disk_usage.go similarity index 71% rename from vendor/github.com/moby/moby/api/types/system/images_disk_usage.go rename to api/types/image/disk_usage.go index 7ebe1986c9..0b694e3d66 100644 --- a/vendor/github.com/moby/moby/api/types/system/images_disk_usage.go +++ b/api/types/image/disk_usage.go @@ -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. // diff --git a/api/types/system/disk_usage.go b/api/types/system/disk_usage.go index c0a2a1a5c1..2c9b1fee7d 100644 --- a/api/types/system/disk_usage.go +++ b/api/types/system/disk_usage.go @@ -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 { diff --git a/vendor/github.com/moby/moby/api/types/system/volumes_disk_usage.go b/api/types/volume/disk_usage.go similarity index 71% rename from vendor/github.com/moby/moby/api/types/system/volumes_disk_usage.go rename to api/types/volume/disk_usage.go index 56e36aa83f..4d1221c2dc 100644 --- a/vendor/github.com/moby/moby/api/types/system/volumes_disk_usage.go +++ b/api/types/volume/disk_usage.go @@ -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. // diff --git a/client/system_disk_usage_test.go b/client/system_disk_usage_test.go index ac1ae09b48..f838e353b9 100644 --- a/client/system_disk_usage_test.go +++ b/client/system_disk_usage_test.go @@ -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, diff --git a/daemon/server/router/system/system_routes.go b/daemon/server/router/system/system_routes.go index a91f022777..380aa5d633 100644 --- a/daemon/server/router/system/system_routes.go +++ b/daemon/server/router/system/system_routes.go @@ -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)), } diff --git a/hack/generate-swagger-api.sh b/hack/generate-swagger-api.sh index aa59408cef..7fedb8ff9a 100755 --- a/hack/generate-swagger-api.sh +++ b/hack/generate-swagger-api.sh @@ -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 diff --git a/vendor/github.com/moby/moby/api/types/system/build_cache_disk_usage.go b/vendor/github.com/moby/moby/api/types/build/disk_usage.go similarity index 72% rename from vendor/github.com/moby/moby/api/types/system/build_cache_disk_usage.go rename to vendor/github.com/moby/moby/api/types/build/disk_usage.go index 2bf617b869..872d389f75 100644 --- a/vendor/github.com/moby/moby/api/types/system/build_cache_disk_usage.go +++ b/vendor/github.com/moby/moby/api/types/build/disk_usage.go @@ -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. // diff --git a/api/types/system/containers_disk_usage.go b/vendor/github.com/moby/moby/api/types/container/disk_usage.go similarity index 69% rename from api/types/system/containers_disk_usage.go rename to vendor/github.com/moby/moby/api/types/container/disk_usage.go index b7eda27e48..d708e22d84 100644 --- a/api/types/system/containers_disk_usage.go +++ b/vendor/github.com/moby/moby/api/types/container/disk_usage.go @@ -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. // diff --git a/api/types/system/images_disk_usage.go b/vendor/github.com/moby/moby/api/types/image/disk_usage.go similarity index 71% rename from api/types/system/images_disk_usage.go rename to vendor/github.com/moby/moby/api/types/image/disk_usage.go index 7ebe1986c9..0b694e3d66 100644 --- a/api/types/system/images_disk_usage.go +++ b/vendor/github.com/moby/moby/api/types/image/disk_usage.go @@ -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. // diff --git a/vendor/github.com/moby/moby/api/types/system/disk_usage.go b/vendor/github.com/moby/moby/api/types/system/disk_usage.go index c0a2a1a5c1..2c9b1fee7d 100644 --- a/vendor/github.com/moby/moby/api/types/system/disk_usage.go +++ b/vendor/github.com/moby/moby/api/types/system/disk_usage.go @@ -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 { diff --git a/api/types/system/volumes_disk_usage.go b/vendor/github.com/moby/moby/api/types/volume/disk_usage.go similarity index 71% rename from api/types/system/volumes_disk_usage.go rename to vendor/github.com/moby/moby/api/types/volume/disk_usage.go index 56e36aa83f..4d1221c2dc 100644 --- a/api/types/system/volumes_disk_usage.go +++ b/vendor/github.com/moby/moby/api/types/volume/disk_usage.go @@ -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. //