Now that the types for the backend were moved to api/types/backend,
we can move the actual response-type and related options to
api/types/system.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,40 @@ |
| 0 |
+package system |
|
| 1 |
+ |
|
| 2 |
+import ( |
|
| 3 |
+ "github.com/moby/moby/api/types/build" |
|
| 4 |
+ "github.com/moby/moby/api/types/container" |
|
| 5 |
+ "github.com/moby/moby/api/types/image" |
|
| 6 |
+ "github.com/moby/moby/api/types/volume" |
|
| 7 |
+) |
|
| 8 |
+ |
|
| 9 |
+// DiskUsageObject represents an object type used for disk usage query filtering. |
|
| 10 |
+type DiskUsageObject string |
|
| 11 |
+ |
|
| 12 |
+const ( |
|
| 13 |
+ // ContainerObject represents a container DiskUsageObject. |
|
| 14 |
+ ContainerObject DiskUsageObject = "container" |
|
| 15 |
+ // ImageObject represents an image DiskUsageObject. |
|
| 16 |
+ ImageObject DiskUsageObject = "image" |
|
| 17 |
+ // VolumeObject represents a volume DiskUsageObject. |
|
| 18 |
+ VolumeObject DiskUsageObject = "volume" |
|
| 19 |
+ // BuildCacheObject represents a build-cache DiskUsageObject. |
|
| 20 |
+ BuildCacheObject DiskUsageObject = "build-cache" |
|
| 21 |
+) |
|
| 22 |
+ |
|
| 23 |
+// DiskUsageOptions holds parameters for system disk usage query. |
|
| 24 |
+type DiskUsageOptions struct {
|
|
| 25 |
+ // Types specifies what object types to include in the response. If empty, |
|
| 26 |
+ // all object types are returned. |
|
| 27 |
+ Types []DiskUsageObject |
|
| 28 |
+} |
|
| 29 |
+ |
|
| 30 |
+// DiskUsage contains response of Engine API: |
|
| 31 |
+// GET "/system/df" |
|
| 32 |
+type DiskUsage struct {
|
|
| 33 |
+ LayersSize int64 |
|
| 34 |
+ Images []*image.Summary |
|
| 35 |
+ Containers []*container.Summary |
|
| 36 |
+ Volumes []*volume.Volume |
|
| 37 |
+ BuildCache []*build.CacheRecord |
|
| 38 |
+ BuilderSize int64 `json:",omitempty"` // Deprecated: deprecated in API 1.38, and no longer used since API 1.40. |
|
| 39 |
+} |
| ... | ... |
@@ -2,10 +2,7 @@ package types |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 | 4 |
"github.com/moby/moby/api/types/build" |
| 5 |
- "github.com/moby/moby/api/types/container" |
|
| 6 |
- "github.com/moby/moby/api/types/image" |
|
| 7 | 5 |
"github.com/moby/moby/api/types/swarm" |
| 8 |
- "github.com/moby/moby/api/types/volume" |
|
| 9 | 6 |
) |
| 10 | 7 |
|
| 11 | 8 |
const ( |
| ... | ... |
@@ -61,38 +58,6 @@ type Version struct {
|
| 61 | 61 |
BuildTime string `json:",omitempty"` |
| 62 | 62 |
} |
| 63 | 63 |
|
| 64 |
-// DiskUsageObject represents an object type used for disk usage query filtering. |
|
| 65 |
-type DiskUsageObject string |
|
| 66 |
- |
|
| 67 |
-const ( |
|
| 68 |
- // ContainerObject represents a container DiskUsageObject. |
|
| 69 |
- ContainerObject DiskUsageObject = "container" |
|
| 70 |
- // ImageObject represents an image DiskUsageObject. |
|
| 71 |
- ImageObject DiskUsageObject = "image" |
|
| 72 |
- // VolumeObject represents a volume DiskUsageObject. |
|
| 73 |
- VolumeObject DiskUsageObject = "volume" |
|
| 74 |
- // BuildCacheObject represents a build-cache DiskUsageObject. |
|
| 75 |
- BuildCacheObject DiskUsageObject = "build-cache" |
|
| 76 |
-) |
|
| 77 |
- |
|
| 78 |
-// DiskUsageOptions holds parameters for system disk usage query. |
|
| 79 |
-type DiskUsageOptions struct {
|
|
| 80 |
- // Types specifies what object types to include in the response. If empty, |
|
| 81 |
- // all object types are returned. |
|
| 82 |
- Types []DiskUsageObject |
|
| 83 |
-} |
|
| 84 |
- |
|
| 85 |
-// DiskUsage contains response of Engine API: |
|
| 86 |
-// GET "/system/df" |
|
| 87 |
-type DiskUsage struct {
|
|
| 88 |
- LayersSize int64 |
|
| 89 |
- Images []*image.Summary |
|
| 90 |
- Containers []*container.Summary |
|
| 91 |
- Volumes []*volume.Volume |
|
| 92 |
- BuildCache []*build.CacheRecord |
|
| 93 |
- BuilderSize int64 `json:",omitempty"` // Deprecated: deprecated in API 1.38, and no longer used since API 1.40. |
|
| 94 |
-} |
|
| 95 |
- |
|
| 96 | 64 |
// PushResult contains the tag, manifest digest, and manifest size from the |
| 97 | 65 |
// push. It's used to signal this information to the trust code in the client |
| 98 | 66 |
// so it can sign the manifest if necessary. |
| ... | ... |
@@ -188,7 +188,7 @@ type SystemAPIClient interface {
|
| 188 | 188 |
Events(ctx context.Context, options events.ListOptions) (<-chan events.Message, <-chan error) |
| 189 | 189 |
Info(ctx context.Context) (system.Info, error) |
| 190 | 190 |
RegistryLogin(ctx context.Context, auth registry.AuthConfig) (registry.AuthenticateOKBody, error) |
| 191 |
- DiskUsage(ctx context.Context, options types.DiskUsageOptions) (types.DiskUsage, error) |
|
| 191 |
+ DiskUsage(ctx context.Context, options system.DiskUsageOptions) (system.DiskUsage, error) |
|
| 192 | 192 |
Ping(ctx context.Context) (types.Ping, error) |
| 193 | 193 |
} |
| 194 | 194 |
|
| ... | ... |
@@ -6,11 +6,11 @@ import ( |
| 6 | 6 |
"fmt" |
| 7 | 7 |
"net/url" |
| 8 | 8 |
|
| 9 |
- "github.com/moby/moby/api/types" |
|
| 9 |
+ "github.com/moby/moby/api/types/system" |
|
| 10 | 10 |
) |
| 11 | 11 |
|
| 12 | 12 |
// DiskUsage requests the current data usage from the daemon |
| 13 |
-func (cli *Client) DiskUsage(ctx context.Context, options types.DiskUsageOptions) (types.DiskUsage, error) {
|
|
| 13 |
+func (cli *Client) DiskUsage(ctx context.Context, options system.DiskUsageOptions) (system.DiskUsage, error) {
|
|
| 14 | 14 |
var query url.Values |
| 15 | 15 |
if len(options.Types) > 0 {
|
| 16 | 16 |
query = url.Values{}
|
| ... | ... |
@@ -22,12 +22,12 @@ func (cli *Client) DiskUsage(ctx context.Context, options types.DiskUsageOptions |
| 22 | 22 |
resp, err := cli.get(ctx, "/system/df", query, nil) |
| 23 | 23 |
defer ensureReaderClosed(resp) |
| 24 | 24 |
if err != nil {
|
| 25 |
- return types.DiskUsage{}, err
|
|
| 25 |
+ return system.DiskUsage{}, err
|
|
| 26 | 26 |
} |
| 27 | 27 |
|
| 28 |
- var du types.DiskUsage |
|
| 28 |
+ var du system.DiskUsage |
|
| 29 | 29 |
if err := json.NewDecoder(resp.Body).Decode(&du); err != nil {
|
| 30 |
- return types.DiskUsage{}, fmt.Errorf("Error retrieving disk usage: %v", err)
|
|
| 30 |
+ return system.DiskUsage{}, fmt.Errorf("Error retrieving disk usage: %v", err)
|
|
| 31 | 31 |
} |
| 32 | 32 |
return du, nil |
| 33 | 33 |
} |
| ... | ... |
@@ -11,7 +11,7 @@ import ( |
| 11 | 11 |
"testing" |
| 12 | 12 |
|
| 13 | 13 |
cerrdefs "github.com/containerd/errdefs" |
| 14 |
- "github.com/moby/moby/api/types" |
|
| 14 |
+ "github.com/moby/moby/api/types/system" |
|
| 15 | 15 |
"gotest.tools/v3/assert" |
| 16 | 16 |
is "gotest.tools/v3/assert/cmp" |
| 17 | 17 |
) |
| ... | ... |
@@ -20,7 +20,7 @@ func TestDiskUsageError(t *testing.T) {
|
| 20 | 20 |
client := &Client{
|
| 21 | 21 |
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), |
| 22 | 22 |
} |
| 23 |
- _, err := client.DiskUsage(context.Background(), types.DiskUsageOptions{})
|
|
| 23 |
+ _, err := client.DiskUsage(context.Background(), system.DiskUsageOptions{})
|
|
| 24 | 24 |
assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal)) |
| 25 | 25 |
} |
| 26 | 26 |
|
| ... | ... |
@@ -32,7 +32,7 @@ func TestDiskUsage(t *testing.T) {
|
| 32 | 32 |
return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
|
| 33 | 33 |
} |
| 34 | 34 |
|
| 35 |
- du := types.DiskUsage{
|
|
| 35 |
+ du := system.DiskUsage{
|
|
| 36 | 36 |
LayersSize: int64(100), |
| 37 | 37 |
Images: nil, |
| 38 | 38 |
Containers: nil, |
| ... | ... |
@@ -50,6 +50,6 @@ func TestDiskUsage(t *testing.T) {
|
| 50 | 50 |
}, nil |
| 51 | 51 |
}), |
| 52 | 52 |
} |
| 53 |
- _, err := client.DiskUsage(context.Background(), types.DiskUsageOptions{})
|
|
| 53 |
+ _, err := client.DiskUsage(context.Background(), system.DiskUsageOptions{})
|
|
| 54 | 54 |
assert.NilError(t, err) |
| 55 | 55 |
} |
| ... | ... |
@@ -14,7 +14,6 @@ import ( |
| 14 | 14 |
"github.com/docker/docker/daemon/server/httputils" |
| 15 | 15 |
"github.com/docker/docker/daemon/server/router/build" |
| 16 | 16 |
"github.com/docker/docker/pkg/ioutils" |
| 17 |
- "github.com/moby/moby/api/types" |
|
| 18 | 17 |
"github.com/moby/moby/api/types/backend" |
| 19 | 18 |
buildtypes "github.com/moby/moby/api/types/build" |
| 20 | 19 |
"github.com/moby/moby/api/types/events" |
| ... | ... |
@@ -167,14 +166,14 @@ func (s *systemRouter) getDiskUsage(ctx context.Context, w http.ResponseWriter, |
| 167 | 167 |
getContainers, getImages, getVolumes, getBuildCache = true, true, true, s.builder != nil |
| 168 | 168 |
} else {
|
| 169 | 169 |
for _, typ := range typeStrs {
|
| 170 |
- switch types.DiskUsageObject(typ) {
|
|
| 171 |
- case types.ContainerObject: |
|
| 170 |
+ switch system.DiskUsageObject(typ) {
|
|
| 171 |
+ case system.ContainerObject: |
|
| 172 | 172 |
getContainers = true |
| 173 |
- case types.ImageObject: |
|
| 173 |
+ case system.ImageObject: |
|
| 174 | 174 |
getImages = true |
| 175 |
- case types.VolumeObject: |
|
| 175 |
+ case system.VolumeObject: |
|
| 176 | 176 |
getVolumes = true |
| 177 |
- case types.BuildCacheObject: |
|
| 177 |
+ case system.BuildCacheObject: |
|
| 178 | 178 |
getBuildCache = true |
| 179 | 179 |
default: |
| 180 | 180 |
return invalidRequestError{Err: fmt.Errorf("unknown object type: %s", typ)}
|
| ... | ... |
@@ -253,7 +252,7 @@ func (s *systemRouter) getDiskUsage(ctx context.Context, w http.ResponseWriter, |
| 253 | 253 |
} |
| 254 | 254 |
|
| 255 | 255 |
// Use the old struct for the API return value. |
| 256 |
- var v types.DiskUsage |
|
| 256 |
+ var v system.DiskUsage |
|
| 257 | 257 |
if du.Images != nil {
|
| 258 | 258 |
v.LayersSize = du.Images.TotalSize |
| 259 | 259 |
v.Images = du.Images.Items |
| ... | ... |
@@ -6,10 +6,10 @@ import ( |
| 6 | 6 |
"github.com/docker/docker/integration/internal/container" |
| 7 | 7 |
"github.com/docker/docker/testutil" |
| 8 | 8 |
"github.com/docker/docker/testutil/daemon" |
| 9 |
- "github.com/moby/moby/api/types" |
|
| 10 | 9 |
"github.com/moby/moby/api/types/build" |
| 11 | 10 |
containertypes "github.com/moby/moby/api/types/container" |
| 12 | 11 |
"github.com/moby/moby/api/types/image" |
| 12 |
+ "github.com/moby/moby/api/types/system" |
|
| 13 | 13 |
"github.com/moby/moby/api/types/volume" |
| 14 | 14 |
"gotest.tools/v3/assert" |
| 15 | 15 |
is "gotest.tools/v3/assert/cmp" |
| ... | ... |
@@ -27,15 +27,15 @@ func TestDiskUsage(t *testing.T) {
|
| 27 | 27 |
defer d.Stop(t) |
| 28 | 28 |
apiClient := d.NewClientT(t) |
| 29 | 29 |
|
| 30 |
- var stepDU types.DiskUsage |
|
| 30 |
+ var stepDU system.DiskUsage |
|
| 31 | 31 |
for _, step := range []struct {
|
| 32 | 32 |
doc string |
| 33 |
- next func(t *testing.T, prev types.DiskUsage) types.DiskUsage |
|
| 33 |
+ next func(t *testing.T, prev system.DiskUsage) system.DiskUsage |
|
| 34 | 34 |
}{
|
| 35 | 35 |
{
|
| 36 | 36 |
doc: "empty", |
| 37 |
- next: func(t *testing.T, _ types.DiskUsage) types.DiskUsage {
|
|
| 38 |
- du, err := apiClient.DiskUsage(ctx, types.DiskUsageOptions{})
|
|
| 37 |
+ next: func(t *testing.T, _ system.DiskUsage) system.DiskUsage {
|
|
| 38 |
+ du, err := apiClient.DiskUsage(ctx, system.DiskUsageOptions{})
|
|
| 39 | 39 |
assert.NilError(t, err) |
| 40 | 40 |
|
| 41 | 41 |
expectedLayersSize := int64(0) |
| ... | ... |
@@ -47,7 +47,7 @@ func TestDiskUsage(t *testing.T) {
|
| 47 | 47 |
} |
| 48 | 48 |
} |
| 49 | 49 |
|
| 50 |
- assert.DeepEqual(t, du, types.DiskUsage{
|
|
| 50 |
+ assert.DeepEqual(t, du, system.DiskUsage{
|
|
| 51 | 51 |
LayersSize: expectedLayersSize, |
| 52 | 52 |
Images: []*image.Summary{},
|
| 53 | 53 |
Containers: []*containertypes.Summary{},
|
| ... | ... |
@@ -59,10 +59,10 @@ func TestDiskUsage(t *testing.T) {
|
| 59 | 59 |
}, |
| 60 | 60 |
{
|
| 61 | 61 |
doc: "after LoadBusybox", |
| 62 |
- next: func(t *testing.T, _ types.DiskUsage) types.DiskUsage {
|
|
| 62 |
+ next: func(t *testing.T, _ system.DiskUsage) system.DiskUsage {
|
|
| 63 | 63 |
d.LoadBusybox(ctx, t) |
| 64 | 64 |
|
| 65 |
- du, err := apiClient.DiskUsage(ctx, types.DiskUsageOptions{})
|
|
| 65 |
+ du, err := apiClient.DiskUsage(ctx, system.DiskUsageOptions{})
|
|
| 66 | 66 |
assert.NilError(t, err) |
| 67 | 67 |
assert.Assert(t, du.LayersSize > 0) |
| 68 | 68 |
assert.Equal(t, len(du.Images), 1) |
| ... | ... |
@@ -77,10 +77,10 @@ func TestDiskUsage(t *testing.T) {
|
| 77 | 77 |
}, |
| 78 | 78 |
{
|
| 79 | 79 |
doc: "after container.Run", |
| 80 |
- next: func(t *testing.T, prev types.DiskUsage) types.DiskUsage {
|
|
| 80 |
+ next: func(t *testing.T, prev system.DiskUsage) system.DiskUsage {
|
|
| 81 | 81 |
cID := container.Run(ctx, t, apiClient) |
| 82 | 82 |
|
| 83 |
- du, err := apiClient.DiskUsage(ctx, types.DiskUsageOptions{})
|
|
| 83 |
+ du, err := apiClient.DiskUsage(ctx, system.DiskUsageOptions{})
|
|
| 84 | 84 |
assert.NilError(t, err) |
| 85 | 85 |
assert.Equal(t, len(du.Containers), 1) |
| 86 | 86 |
assert.Equal(t, len(du.Containers[0].Names), 1) |
| ... | ... |
@@ -110,76 +110,76 @@ func TestDiskUsage(t *testing.T) {
|
| 110 | 110 |
|
| 111 | 111 |
for _, tc := range []struct {
|
| 112 | 112 |
doc string |
| 113 |
- options types.DiskUsageOptions |
|
| 114 |
- expected types.DiskUsage |
|
| 113 |
+ options system.DiskUsageOptions |
|
| 114 |
+ expected system.DiskUsage |
|
| 115 | 115 |
}{
|
| 116 | 116 |
{
|
| 117 | 117 |
doc: "container types", |
| 118 |
- options: types.DiskUsageOptions{
|
|
| 119 |
- Types: []types.DiskUsageObject{
|
|
| 120 |
- types.ContainerObject, |
|
| 118 |
+ options: system.DiskUsageOptions{
|
|
| 119 |
+ Types: []system.DiskUsageObject{
|
|
| 120 |
+ system.ContainerObject, |
|
| 121 | 121 |
}, |
| 122 | 122 |
}, |
| 123 |
- expected: types.DiskUsage{
|
|
| 123 |
+ expected: system.DiskUsage{
|
|
| 124 | 124 |
Containers: stepDU.Containers, |
| 125 | 125 |
}, |
| 126 | 126 |
}, |
| 127 | 127 |
{
|
| 128 | 128 |
doc: "image types", |
| 129 |
- options: types.DiskUsageOptions{
|
|
| 130 |
- Types: []types.DiskUsageObject{
|
|
| 131 |
- types.ImageObject, |
|
| 129 |
+ options: system.DiskUsageOptions{
|
|
| 130 |
+ Types: []system.DiskUsageObject{
|
|
| 131 |
+ system.ImageObject, |
|
| 132 | 132 |
}, |
| 133 | 133 |
}, |
| 134 |
- expected: types.DiskUsage{
|
|
| 134 |
+ expected: system.DiskUsage{
|
|
| 135 | 135 |
LayersSize: stepDU.LayersSize, |
| 136 | 136 |
Images: stepDU.Images, |
| 137 | 137 |
}, |
| 138 | 138 |
}, |
| 139 | 139 |
{
|
| 140 | 140 |
doc: "volume types", |
| 141 |
- options: types.DiskUsageOptions{
|
|
| 142 |
- Types: []types.DiskUsageObject{
|
|
| 143 |
- types.VolumeObject, |
|
| 141 |
+ options: system.DiskUsageOptions{
|
|
| 142 |
+ Types: []system.DiskUsageObject{
|
|
| 143 |
+ system.VolumeObject, |
|
| 144 | 144 |
}, |
| 145 | 145 |
}, |
| 146 |
- expected: types.DiskUsage{
|
|
| 146 |
+ expected: system.DiskUsage{
|
|
| 147 | 147 |
Volumes: stepDU.Volumes, |
| 148 | 148 |
}, |
| 149 | 149 |
}, |
| 150 | 150 |
{
|
| 151 | 151 |
doc: "build-cache types", |
| 152 |
- options: types.DiskUsageOptions{
|
|
| 153 |
- Types: []types.DiskUsageObject{
|
|
| 154 |
- types.BuildCacheObject, |
|
| 152 |
+ options: system.DiskUsageOptions{
|
|
| 153 |
+ Types: []system.DiskUsageObject{
|
|
| 154 |
+ system.BuildCacheObject, |
|
| 155 | 155 |
}, |
| 156 | 156 |
}, |
| 157 |
- expected: types.DiskUsage{
|
|
| 157 |
+ expected: system.DiskUsage{
|
|
| 158 | 158 |
BuildCache: stepDU.BuildCache, |
| 159 | 159 |
}, |
| 160 | 160 |
}, |
| 161 | 161 |
{
|
| 162 | 162 |
doc: "container, volume types", |
| 163 |
- options: types.DiskUsageOptions{
|
|
| 164 |
- Types: []types.DiskUsageObject{
|
|
| 165 |
- types.ContainerObject, |
|
| 166 |
- types.VolumeObject, |
|
| 163 |
+ options: system.DiskUsageOptions{
|
|
| 164 |
+ Types: []system.DiskUsageObject{
|
|
| 165 |
+ system.ContainerObject, |
|
| 166 |
+ system.VolumeObject, |
|
| 167 | 167 |
}, |
| 168 | 168 |
}, |
| 169 |
- expected: types.DiskUsage{
|
|
| 169 |
+ expected: system.DiskUsage{
|
|
| 170 | 170 |
Containers: stepDU.Containers, |
| 171 | 171 |
Volumes: stepDU.Volumes, |
| 172 | 172 |
}, |
| 173 | 173 |
}, |
| 174 | 174 |
{
|
| 175 | 175 |
doc: "image, build-cache types", |
| 176 |
- options: types.DiskUsageOptions{
|
|
| 177 |
- Types: []types.DiskUsageObject{
|
|
| 178 |
- types.ImageObject, |
|
| 179 |
- types.BuildCacheObject, |
|
| 176 |
+ options: system.DiskUsageOptions{
|
|
| 177 |
+ Types: []system.DiskUsageObject{
|
|
| 178 |
+ system.ImageObject, |
|
| 179 |
+ system.BuildCacheObject, |
|
| 180 | 180 |
}, |
| 181 | 181 |
}, |
| 182 |
- expected: types.DiskUsage{
|
|
| 182 |
+ expected: system.DiskUsage{
|
|
| 183 | 183 |
LayersSize: stepDU.LayersSize, |
| 184 | 184 |
Images: stepDU.Images, |
| 185 | 185 |
BuildCache: stepDU.BuildCache, |
| ... | ... |
@@ -187,14 +187,14 @@ func TestDiskUsage(t *testing.T) {
|
| 187 | 187 |
}, |
| 188 | 188 |
{
|
| 189 | 189 |
doc: "container, volume, build-cache types", |
| 190 |
- options: types.DiskUsageOptions{
|
|
| 191 |
- Types: []types.DiskUsageObject{
|
|
| 192 |
- types.ContainerObject, |
|
| 193 |
- types.VolumeObject, |
|
| 194 |
- types.BuildCacheObject, |
|
| 190 |
+ options: system.DiskUsageOptions{
|
|
| 191 |
+ Types: []system.DiskUsageObject{
|
|
| 192 |
+ system.ContainerObject, |
|
| 193 |
+ system.VolumeObject, |
|
| 194 |
+ system.BuildCacheObject, |
|
| 195 | 195 |
}, |
| 196 | 196 |
}, |
| 197 |
- expected: types.DiskUsage{
|
|
| 197 |
+ expected: system.DiskUsage{
|
|
| 198 | 198 |
Containers: stepDU.Containers, |
| 199 | 199 |
Volumes: stepDU.Volumes, |
| 200 | 200 |
BuildCache: stepDU.BuildCache, |
| ... | ... |
@@ -202,14 +202,14 @@ func TestDiskUsage(t *testing.T) {
|
| 202 | 202 |
}, |
| 203 | 203 |
{
|
| 204 | 204 |
doc: "image, volume, build-cache types", |
| 205 |
- options: types.DiskUsageOptions{
|
|
| 206 |
- Types: []types.DiskUsageObject{
|
|
| 207 |
- types.ImageObject, |
|
| 208 |
- types.VolumeObject, |
|
| 209 |
- types.BuildCacheObject, |
|
| 205 |
+ options: system.DiskUsageOptions{
|
|
| 206 |
+ Types: []system.DiskUsageObject{
|
|
| 207 |
+ system.ImageObject, |
|
| 208 |
+ system.VolumeObject, |
|
| 209 |
+ system.BuildCacheObject, |
|
| 210 | 210 |
}, |
| 211 | 211 |
}, |
| 212 |
- expected: types.DiskUsage{
|
|
| 212 |
+ expected: system.DiskUsage{
|
|
| 213 | 213 |
LayersSize: stepDU.LayersSize, |
| 214 | 214 |
Images: stepDU.Images, |
| 215 | 215 |
Volumes: stepDU.Volumes, |
| ... | ... |
@@ -218,14 +218,14 @@ func TestDiskUsage(t *testing.T) {
|
| 218 | 218 |
}, |
| 219 | 219 |
{
|
| 220 | 220 |
doc: "container, image, volume types", |
| 221 |
- options: types.DiskUsageOptions{
|
|
| 222 |
- Types: []types.DiskUsageObject{
|
|
| 223 |
- types.ContainerObject, |
|
| 224 |
- types.ImageObject, |
|
| 225 |
- types.VolumeObject, |
|
| 221 |
+ options: system.DiskUsageOptions{
|
|
| 222 |
+ Types: []system.DiskUsageObject{
|
|
| 223 |
+ system.ContainerObject, |
|
| 224 |
+ system.ImageObject, |
|
| 225 |
+ system.VolumeObject, |
|
| 226 | 226 |
}, |
| 227 | 227 |
}, |
| 228 |
- expected: types.DiskUsage{
|
|
| 228 |
+ expected: system.DiskUsage{
|
|
| 229 | 229 |
LayersSize: stepDU.LayersSize, |
| 230 | 230 |
Containers: stepDU.Containers, |
| 231 | 231 |
Images: stepDU.Images, |
| ... | ... |
@@ -234,15 +234,15 @@ func TestDiskUsage(t *testing.T) {
|
| 234 | 234 |
}, |
| 235 | 235 |
{
|
| 236 | 236 |
doc: "container, image, volume, build-cache types", |
| 237 |
- options: types.DiskUsageOptions{
|
|
| 238 |
- Types: []types.DiskUsageObject{
|
|
| 239 |
- types.ContainerObject, |
|
| 240 |
- types.ImageObject, |
|
| 241 |
- types.VolumeObject, |
|
| 242 |
- types.BuildCacheObject, |
|
| 237 |
+ options: system.DiskUsageOptions{
|
|
| 238 |
+ Types: []system.DiskUsageObject{
|
|
| 239 |
+ system.ContainerObject, |
|
| 240 |
+ system.ImageObject, |
|
| 241 |
+ system.VolumeObject, |
|
| 242 |
+ system.BuildCacheObject, |
|
| 243 | 243 |
}, |
| 244 | 244 |
}, |
| 245 |
- expected: types.DiskUsage{
|
|
| 245 |
+ expected: system.DiskUsage{
|
|
| 246 | 246 |
LayersSize: stepDU.LayersSize, |
| 247 | 247 |
Containers: stepDU.Containers, |
| 248 | 248 |
Images: stepDU.Images, |
| 249 | 249 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,40 @@ |
| 0 |
+package system |
|
| 1 |
+ |
|
| 2 |
+import ( |
|
| 3 |
+ "github.com/moby/moby/api/types/build" |
|
| 4 |
+ "github.com/moby/moby/api/types/container" |
|
| 5 |
+ "github.com/moby/moby/api/types/image" |
|
| 6 |
+ "github.com/moby/moby/api/types/volume" |
|
| 7 |
+) |
|
| 8 |
+ |
|
| 9 |
+// DiskUsageObject represents an object type used for disk usage query filtering. |
|
| 10 |
+type DiskUsageObject string |
|
| 11 |
+ |
|
| 12 |
+const ( |
|
| 13 |
+ // ContainerObject represents a container DiskUsageObject. |
|
| 14 |
+ ContainerObject DiskUsageObject = "container" |
|
| 15 |
+ // ImageObject represents an image DiskUsageObject. |
|
| 16 |
+ ImageObject DiskUsageObject = "image" |
|
| 17 |
+ // VolumeObject represents a volume DiskUsageObject. |
|
| 18 |
+ VolumeObject DiskUsageObject = "volume" |
|
| 19 |
+ // BuildCacheObject represents a build-cache DiskUsageObject. |
|
| 20 |
+ BuildCacheObject DiskUsageObject = "build-cache" |
|
| 21 |
+) |
|
| 22 |
+ |
|
| 23 |
+// DiskUsageOptions holds parameters for system disk usage query. |
|
| 24 |
+type DiskUsageOptions struct {
|
|
| 25 |
+ // Types specifies what object types to include in the response. If empty, |
|
| 26 |
+ // all object types are returned. |
|
| 27 |
+ Types []DiskUsageObject |
|
| 28 |
+} |
|
| 29 |
+ |
|
| 30 |
+// DiskUsage contains response of Engine API: |
|
| 31 |
+// GET "/system/df" |
|
| 32 |
+type DiskUsage struct {
|
|
| 33 |
+ LayersSize int64 |
|
| 34 |
+ Images []*image.Summary |
|
| 35 |
+ Containers []*container.Summary |
|
| 36 |
+ Volumes []*volume.Volume |
|
| 37 |
+ BuildCache []*build.CacheRecord |
|
| 38 |
+ BuilderSize int64 `json:",omitempty"` // Deprecated: deprecated in API 1.38, and no longer used since API 1.40. |
|
| 39 |
+} |
| ... | ... |
@@ -2,10 +2,7 @@ package types |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 | 4 |
"github.com/moby/moby/api/types/build" |
| 5 |
- "github.com/moby/moby/api/types/container" |
|
| 6 |
- "github.com/moby/moby/api/types/image" |
|
| 7 | 5 |
"github.com/moby/moby/api/types/swarm" |
| 8 |
- "github.com/moby/moby/api/types/volume" |
|
| 9 | 6 |
) |
| 10 | 7 |
|
| 11 | 8 |
const ( |
| ... | ... |
@@ -61,38 +58,6 @@ type Version struct {
|
| 61 | 61 |
BuildTime string `json:",omitempty"` |
| 62 | 62 |
} |
| 63 | 63 |
|
| 64 |
-// DiskUsageObject represents an object type used for disk usage query filtering. |
|
| 65 |
-type DiskUsageObject string |
|
| 66 |
- |
|
| 67 |
-const ( |
|
| 68 |
- // ContainerObject represents a container DiskUsageObject. |
|
| 69 |
- ContainerObject DiskUsageObject = "container" |
|
| 70 |
- // ImageObject represents an image DiskUsageObject. |
|
| 71 |
- ImageObject DiskUsageObject = "image" |
|
| 72 |
- // VolumeObject represents a volume DiskUsageObject. |
|
| 73 |
- VolumeObject DiskUsageObject = "volume" |
|
| 74 |
- // BuildCacheObject represents a build-cache DiskUsageObject. |
|
| 75 |
- BuildCacheObject DiskUsageObject = "build-cache" |
|
| 76 |
-) |
|
| 77 |
- |
|
| 78 |
-// DiskUsageOptions holds parameters for system disk usage query. |
|
| 79 |
-type DiskUsageOptions struct {
|
|
| 80 |
- // Types specifies what object types to include in the response. If empty, |
|
| 81 |
- // all object types are returned. |
|
| 82 |
- Types []DiskUsageObject |
|
| 83 |
-} |
|
| 84 |
- |
|
| 85 |
-// DiskUsage contains response of Engine API: |
|
| 86 |
-// GET "/system/df" |
|
| 87 |
-type DiskUsage struct {
|
|
| 88 |
- LayersSize int64 |
|
| 89 |
- Images []*image.Summary |
|
| 90 |
- Containers []*container.Summary |
|
| 91 |
- Volumes []*volume.Volume |
|
| 92 |
- BuildCache []*build.CacheRecord |
|
| 93 |
- BuilderSize int64 `json:",omitempty"` // Deprecated: deprecated in API 1.38, and no longer used since API 1.40. |
|
| 94 |
-} |
|
| 95 |
- |
|
| 96 | 64 |
// PushResult contains the tag, manifest digest, and manifest size from the |
| 97 | 65 |
// push. It's used to signal this information to the trust code in the client |
| 98 | 66 |
// so it can sign the manifest if necessary. |
| ... | ... |
@@ -188,7 +188,7 @@ type SystemAPIClient interface {
|
| 188 | 188 |
Events(ctx context.Context, options events.ListOptions) (<-chan events.Message, <-chan error) |
| 189 | 189 |
Info(ctx context.Context) (system.Info, error) |
| 190 | 190 |
RegistryLogin(ctx context.Context, auth registry.AuthConfig) (registry.AuthenticateOKBody, error) |
| 191 |
- DiskUsage(ctx context.Context, options types.DiskUsageOptions) (types.DiskUsage, error) |
|
| 191 |
+ DiskUsage(ctx context.Context, options system.DiskUsageOptions) (system.DiskUsage, error) |
|
| 192 | 192 |
Ping(ctx context.Context) (types.Ping, error) |
| 193 | 193 |
} |
| 194 | 194 |
|
| ... | ... |
@@ -6,11 +6,11 @@ import ( |
| 6 | 6 |
"fmt" |
| 7 | 7 |
"net/url" |
| 8 | 8 |
|
| 9 |
- "github.com/moby/moby/api/types" |
|
| 9 |
+ "github.com/moby/moby/api/types/system" |
|
| 10 | 10 |
) |
| 11 | 11 |
|
| 12 | 12 |
// DiskUsage requests the current data usage from the daemon |
| 13 |
-func (cli *Client) DiskUsage(ctx context.Context, options types.DiskUsageOptions) (types.DiskUsage, error) {
|
|
| 13 |
+func (cli *Client) DiskUsage(ctx context.Context, options system.DiskUsageOptions) (system.DiskUsage, error) {
|
|
| 14 | 14 |
var query url.Values |
| 15 | 15 |
if len(options.Types) > 0 {
|
| 16 | 16 |
query = url.Values{}
|
| ... | ... |
@@ -22,12 +22,12 @@ func (cli *Client) DiskUsage(ctx context.Context, options types.DiskUsageOptions |
| 22 | 22 |
resp, err := cli.get(ctx, "/system/df", query, nil) |
| 23 | 23 |
defer ensureReaderClosed(resp) |
| 24 | 24 |
if err != nil {
|
| 25 |
- return types.DiskUsage{}, err
|
|
| 25 |
+ return system.DiskUsage{}, err
|
|
| 26 | 26 |
} |
| 27 | 27 |
|
| 28 |
- var du types.DiskUsage |
|
| 28 |
+ var du system.DiskUsage |
|
| 29 | 29 |
if err := json.NewDecoder(resp.Body).Decode(&du); err != nil {
|
| 30 |
- return types.DiskUsage{}, fmt.Errorf("Error retrieving disk usage: %v", err)
|
|
| 30 |
+ return system.DiskUsage{}, fmt.Errorf("Error retrieving disk usage: %v", err)
|
|
| 31 | 31 |
} |
| 32 | 32 |
return du, nil |
| 33 | 33 |
} |