Skip to content

Commit 48cacbc

Browse files
committed
api/types: move image-types to api/types/image
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent aacd100 commit 48cacbc

26 files changed

Lines changed: 116 additions & 86 deletions

api/server/router/image/backend.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ type Backend interface {
2222
}
2323

2424
type imageBackend interface {
25-
ImageDelete(ctx context.Context, imageRef string, force, prune bool) ([]types.ImageDeleteResponseItem, error)
25+
ImageDelete(ctx context.Context, imageRef string, force, prune bool) ([]image.DeleteResponse, error)
2626
ImageHistory(ctx context.Context, imageName string) ([]*image.HistoryResponseItem, error)
27-
Images(ctx context.Context, opts types.ImageListOptions) ([]*types.ImageSummary, error)
27+
Images(ctx context.Context, opts types.ImageListOptions) ([]*image.Summary, error)
2828
GetImage(ctx context.Context, refOrID string, options image.GetImageOpts) (*dockerimage.Image, error)
2929
TagImage(ctx context.Context, id dockerimage.ID, newRef reference.Named) error
3030
ImagesPrune(ctx context.Context, pruneFilters filters.Args) (*types.ImagesPruneReport, error)

api/server/router/image/image_routes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ func (ir *imageRouter) toImageInspect(img *image.Image) (*types.ImageInspect, er
353353
Data: img.Details.Metadata,
354354
},
355355
RootFS: rootFSToAPIType(img.RootFS),
356-
Metadata: types.ImageMetadata{
356+
Metadata: opts.Metadata{
357357
LastTagTime: img.Details.LastUpdated,
358358
},
359359
}, nil

api/swagger.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1840,6 +1840,7 @@ definitions:
18401840
x-nullable: true
18411841
ImageSummary:
18421842
type: "object"
1843+
x-go-name: "Summary"
18431844
required:
18441845
- Id
18451846
- ParentId
@@ -4477,6 +4478,7 @@ definitions:
44774478

44784479
ImageDeleteResponseItem:
44794480
type: "object"
4481+
x-go-name: "DeleteResponse"
44804482
properties:
44814483
Untagged:
44824484
description: "The image ID of an image that was untagged"
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
package types
1+
package image
22

33
// This file was generated by the swagger tool.
44
// Editing this file might prove futile when you re-run the swagger generate command
55

6-
// ImageDeleteResponseItem image delete response item
7-
// swagger:model ImageDeleteResponseItem
8-
type ImageDeleteResponseItem struct {
6+
// DeleteResponse delete response
7+
// swagger:model DeleteResponse
8+
type DeleteResponse struct {
99

1010
// The image ID of an image that was deleted
1111
Deleted string `json:"Deleted,omitempty"`

api/types/image/image.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package image
2+
3+
import "time"
4+
5+
// Metadata contains engine-local data about the image.
6+
type Metadata struct {
7+
// LastTagTime is the date and time at which the image was last tagged.
8+
LastTagTime time.Time `json:",omitempty"`
9+
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
package types
1+
package image
22

33
// This file was generated by the swagger tool.
44
// Editing this file might prove futile when you re-run the swagger generate command
55

6-
// ImageSummary image summary
7-
// swagger:model ImageSummary
8-
type ImageSummary struct {
6+
// Summary summary
7+
// swagger:model Summary
8+
type Summary struct {
99

1010
// Number of containers using this image. Includes both stopped and running
1111
// containers.

api/types/types.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77

88
"github.com/docker/docker/api/types/container"
99
"github.com/docker/docker/api/types/filters"
10+
"github.com/docker/docker/api/types/image"
1011
"github.com/docker/docker/api/types/mount"
1112
"github.com/docker/docker/api/types/network"
1213
"github.com/docker/docker/api/types/swarm"
@@ -128,13 +129,7 @@ type ImageInspect struct {
128129
// Metadata of the image in the local cache.
129130
//
130131
// This information is local to the daemon, and not part of the image itself.
131-
Metadata ImageMetadata
132-
}
133-
134-
// ImageMetadata contains engine-local data about the image
135-
type ImageMetadata struct {
136-
// LastTagTime is the date and time at which the image was last tagged.
137-
LastTagTime time.Time `json:",omitempty"`
132+
Metadata image.Metadata
138133
}
139134

140135
// Container contains response of Engine API:
@@ -514,7 +509,7 @@ type DiskUsageOptions struct {
514509
// GET "/system/df"
515510
type DiskUsage struct {
516511
LayersSize int64
517-
Images []*ImageSummary
512+
Images []*image.Summary
518513
Containers []*Container
519514
Volumes []*volume.Volume
520515
BuildCache []*BuildCache
@@ -538,7 +533,7 @@ type VolumesPruneReport struct {
538533
// ImagesPruneReport contains the response for Engine API:
539534
// POST "/images/prune"
540535
type ImagesPruneReport struct {
541-
ImagesDeleted []ImageDeleteResponseItem
536+
ImagesDeleted []image.DeleteResponse
542537
SpaceReclaimed uint64
543538
}
544539

api/types/types_deprecated.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package types
22

33
import (
44
"github.com/docker/docker/api/types/checkpoint"
5+
"github.com/docker/docker/api/types/image"
56
"github.com/docker/docker/api/types/system"
67
)
78

@@ -63,6 +64,21 @@ type SecurityOpt = system.SecurityOpt
6364
// Deprecated: use [system.KeyValue].
6465
type KeyValue = system.KeyValue
6566

67+
// ImageDeleteResponseItem image delete response item.
68+
//
69+
// Deprecated: use [image.DeleteResponse].
70+
type ImageDeleteResponseItem = image.DeleteResponse
71+
72+
// ImageSummary image summary.
73+
//
74+
// Deprecated: use [image.Summary].
75+
type ImageSummary = image.Summary
76+
77+
// ImageMetadata contains engine-local data about the image.
78+
//
79+
// Deprecated: use [image.Metadata].
80+
type ImageMetadata = image.Metadata
81+
6682
// DecodeSecurityOptions decodes a security options string slice to a type safe
6783
// [system.SecurityOpt].
6884
//

client/image_list.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,20 @@ import (
77

88
"github.com/docker/docker/api/types"
99
"github.com/docker/docker/api/types/filters"
10+
"github.com/docker/docker/api/types/image"
1011
"github.com/docker/docker/api/types/versions"
1112
)
1213

1314
// ImageList returns a list of images in the docker host.
14-
func (cli *Client) ImageList(ctx context.Context, options types.ImageListOptions) ([]types.ImageSummary, error) {
15+
func (cli *Client) ImageList(ctx context.Context, options types.ImageListOptions) ([]image.Summary, error) {
1516
// Make sure we negotiated (if the client is configured to do so),
1617
// as code below contains API-version specific handling of options.
1718
//
1819
// Normally, version-negotiation (if enabled) would not happen until
1920
// the API request is made.
2021
cli.checkVersion(ctx)
2122

22-
var images []types.ImageSummary
23+
var images []image.Summary
2324
query := url.Values{}
2425

2526
optionFilters := options.Filters

client/image_list_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313

1414
"github.com/docker/docker/api/types"
1515
"github.com/docker/docker/api/types/filters"
16+
"github.com/docker/docker/api/types/image"
1617
"github.com/docker/docker/errdefs"
1718
"gotest.tools/v3/assert"
1819
is "gotest.tools/v3/assert/cmp"
@@ -80,7 +81,7 @@ func TestImageList(t *testing.T) {
8081
return nil, fmt.Errorf("%s not set in URL query properly. Expected '%s', got %s", key, expected, actual)
8182
}
8283
}
83-
content, err := json.Marshal([]types.ImageSummary{
84+
content, err := json.Marshal([]image.Summary{
8485
{
8586
ID: "image_id2",
8687
},
@@ -121,7 +122,7 @@ func TestImageListApiBefore125(t *testing.T) {
121122
if actualFilters != "" {
122123
return nil, fmt.Errorf("filters should have not been present, were with value: %s", actualFilters)
123124
}
124-
content, err := json.Marshal([]types.ImageSummary{
125+
content, err := json.Marshal([]image.Summary{
125126
{
126127
ID: "image_id2",
127128
},

0 commit comments

Comments
 (0)