and rename it to a more appropriate name ImageSummary.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
| ... | ... |
@@ -25,7 +25,7 @@ type containerBackend interface {
|
| 25 | 25 |
type imageBackend interface {
|
| 26 | 26 |
ImageDelete(imageRef string, force, prune bool) ([]types.ImageDelete, error) |
| 27 | 27 |
ImageHistory(imageName string) ([]*types.ImageHistory, error) |
| 28 |
- Images(filterArgs string, filter string, all bool, withExtraAttrs bool) ([]*types.Image, error) |
|
| 28 |
+ Images(filterArgs string, filter string, all bool, withExtraAttrs bool) ([]*types.ImageSummary, error) |
|
| 29 | 29 |
LookupImage(name string) (*types.ImageInspect, error) |
| 30 | 30 |
TagImage(imageName, repository, tag string) error |
| 31 | 31 |
ImagesPrune(config *types.ImagesPruneConfig) (*types.ImagesPruneReport, error) |
| ... | ... |
@@ -762,6 +762,58 @@ definitions: |
| 762 | 762 |
type: "string" |
| 763 | 763 |
BaseLayer: |
| 764 | 764 |
type: "string" |
| 765 |
+ |
|
| 766 |
+ ImageSummary: |
|
| 767 |
+ type: "object" |
|
| 768 |
+ required: |
|
| 769 |
+ - Id |
|
| 770 |
+ - ParentId |
|
| 771 |
+ - RepoTags |
|
| 772 |
+ - RepoDigests |
|
| 773 |
+ - Created |
|
| 774 |
+ - Size |
|
| 775 |
+ - SharedSize |
|
| 776 |
+ - VirtualSize |
|
| 777 |
+ - Labels |
|
| 778 |
+ - Containers |
|
| 779 |
+ properties: |
|
| 780 |
+ Id: |
|
| 781 |
+ type: "string" |
|
| 782 |
+ x-nullable: false |
|
| 783 |
+ ParentId: |
|
| 784 |
+ type: "string" |
|
| 785 |
+ x-nullable: false |
|
| 786 |
+ RepoTags: |
|
| 787 |
+ type: "array" |
|
| 788 |
+ x-nullable: false |
|
| 789 |
+ items: |
|
| 790 |
+ type: "string" |
|
| 791 |
+ RepoDigests: |
|
| 792 |
+ type: "array" |
|
| 793 |
+ x-nullable: false |
|
| 794 |
+ items: |
|
| 795 |
+ type: "string" |
|
| 796 |
+ Created: |
|
| 797 |
+ type: "integer" |
|
| 798 |
+ x-nullable: false |
|
| 799 |
+ Size: |
|
| 800 |
+ type: "integer" |
|
| 801 |
+ x-nullable: false |
|
| 802 |
+ SharedSize: |
|
| 803 |
+ type: "integer" |
|
| 804 |
+ x-nullable: false |
|
| 805 |
+ VirtualSize: |
|
| 806 |
+ type: "integer" |
|
| 807 |
+ x-nullable: false |
|
| 808 |
+ Labels: |
|
| 809 |
+ type: "object" |
|
| 810 |
+ x-nullable: false |
|
| 811 |
+ additionalProperties: |
|
| 812 |
+ type: "string" |
|
| 813 |
+ Containers: |
|
| 814 |
+ x-nullable: false |
|
| 815 |
+ type: "integer" |
|
| 816 |
+ |
|
| 765 | 817 |
AuthConfig: |
| 766 | 818 |
type: "object" |
| 767 | 819 |
properties: |
| ... | ... |
@@ -3829,37 +3881,11 @@ paths: |
| 3829 | 3829 |
- "application/json" |
| 3830 | 3830 |
responses: |
| 3831 | 3831 |
200: |
| 3832 |
- description: "no error" |
|
| 3832 |
+ description: "Summary image data for the images matching the query" |
|
| 3833 | 3833 |
schema: |
| 3834 | 3834 |
type: "array" |
| 3835 | 3835 |
items: |
| 3836 |
- type: "object" |
|
| 3837 |
- properties: |
|
| 3838 |
- Id: |
|
| 3839 |
- type: "string" |
|
| 3840 |
- ParentId: |
|
| 3841 |
- type: "string" |
|
| 3842 |
- RepoTags: |
|
| 3843 |
- type: "array" |
|
| 3844 |
- items: |
|
| 3845 |
- type: "string" |
|
| 3846 |
- RepoDigests: |
|
| 3847 |
- type: "array" |
|
| 3848 |
- items: |
|
| 3849 |
- type: "string" |
|
| 3850 |
- Created: |
|
| 3851 |
- type: "integer" |
|
| 3852 |
- format: "int64" |
|
| 3853 |
- Size: |
|
| 3854 |
- type: "integer" |
|
| 3855 |
- format: "int64" |
|
| 3856 |
- VirtualSize: |
|
| 3857 |
- type: "integer" |
|
| 3858 |
- format: "int64" |
|
| 3859 |
- Labels: |
|
| 3860 |
- type: "object" |
|
| 3861 |
- additionalProperties: |
|
| 3862 |
- type: "string" |
|
| 3836 |
+ $ref: "#/definitions/ImageSummary" |
|
| 3863 | 3837 |
examples: |
| 3864 | 3838 |
application/json: |
| 3865 | 3839 |
- RepoTags: |
| 3866 | 3840 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,49 @@ |
| 0 |
+package types |
|
| 1 |
+ |
|
| 2 |
+// This file was generated by the swagger tool. |
|
| 3 |
+// Editing this file might prove futile when you re-run the swagger generate command |
|
| 4 |
+ |
|
| 5 |
+// ImageSummary image summary |
|
| 6 |
+// swagger:model ImageSummary |
|
| 7 |
+type ImageSummary struct {
|
|
| 8 |
+ |
|
| 9 |
+ // containers |
|
| 10 |
+ // Required: true |
|
| 11 |
+ Containers int64 `json:"Containers"` |
|
| 12 |
+ |
|
| 13 |
+ // created |
|
| 14 |
+ // Required: true |
|
| 15 |
+ Created int64 `json:"Created"` |
|
| 16 |
+ |
|
| 17 |
+ // Id |
|
| 18 |
+ // Required: true |
|
| 19 |
+ ID string `json:"Id"` |
|
| 20 |
+ |
|
| 21 |
+ // labels |
|
| 22 |
+ // Required: true |
|
| 23 |
+ Labels map[string]string `json:"Labels"` |
|
| 24 |
+ |
|
| 25 |
+ // parent Id |
|
| 26 |
+ // Required: true |
|
| 27 |
+ ParentID string `json:"ParentId"` |
|
| 28 |
+ |
|
| 29 |
+ // repo digests |
|
| 30 |
+ // Required: true |
|
| 31 |
+ RepoDigests []string `json:"RepoDigests"` |
|
| 32 |
+ |
|
| 33 |
+ // repo tags |
|
| 34 |
+ // Required: true |
|
| 35 |
+ RepoTags []string `json:"RepoTags"` |
|
| 36 |
+ |
|
| 37 |
+ // shared size |
|
| 38 |
+ // Required: true |
|
| 39 |
+ SharedSize int64 `json:"SharedSize"` |
|
| 40 |
+ |
|
| 41 |
+ // size |
|
| 42 |
+ // Required: true |
|
| 43 |
+ Size int64 `json:"Size"` |
|
| 44 |
+ |
|
| 45 |
+ // virtual size |
|
| 46 |
+ // Required: true |
|
| 47 |
+ VirtualSize int64 `json:"VirtualSize"` |
|
| 48 |
+} |
| ... | ... |
@@ -86,21 +86,6 @@ type ImageDelete struct {
|
| 86 | 86 |
Deleted string `json:",omitempty"` |
| 87 | 87 |
} |
| 88 | 88 |
|
| 89 |
-// Image contains response of Remote API: |
|
| 90 |
-// GET "/images/json" |
|
| 91 |
-type Image struct {
|
|
| 92 |
- ID string `json:"Id"` |
|
| 93 |
- ParentID string `json:"ParentId"` |
|
| 94 |
- RepoTags []string |
|
| 95 |
- RepoDigests []string |
|
| 96 |
- Created int64 |
|
| 97 |
- Size int64 |
|
| 98 |
- SharedSize int64 |
|
| 99 |
- VirtualSize int64 |
|
| 100 |
- Labels map[string]string |
|
| 101 |
- Containers int64 |
|
| 102 |
-} |
|
| 103 |
- |
|
| 104 | 89 |
// GraphDriverData returns Image's graph driver config info |
| 105 | 90 |
// when calling inspect command |
| 106 | 91 |
type GraphDriverData struct {
|
| ... | ... |
@@ -516,7 +501,7 @@ type Runtime struct {
|
| 516 | 516 |
// GET "/system/df" |
| 517 | 517 |
type DiskUsage struct {
|
| 518 | 518 |
LayersSize int64 |
| 519 |
- Images []*Image |
|
| 519 |
+ Images []*ImageSummary |
|
| 520 | 520 |
Containers []*Container |
| 521 | 521 |
Volumes []*Volume |
| 522 | 522 |
} |
| ... | ... |
@@ -31,7 +31,7 @@ type DiskUsageContext struct {
|
| 31 | 31 |
Context |
| 32 | 32 |
Verbose bool |
| 33 | 33 |
LayersSize int64 |
| 34 |
- Images []*types.Image |
|
| 34 |
+ Images []*types.ImageSummary |
|
| 35 | 35 |
Containers []*types.Container |
| 36 | 36 |
Volumes []*types.Volume |
| 37 | 37 |
} |
| ... | ... |
@@ -155,7 +155,7 @@ func (ctx *DiskUsageContext) Write() {
|
| 155 | 155 |
type diskUsageImagesContext struct {
|
| 156 | 156 |
HeaderContext |
| 157 | 157 |
totalSize int64 |
| 158 |
- images []*types.Image |
|
| 158 |
+ images []*types.ImageSummary |
|
| 159 | 159 |
} |
| 160 | 160 |
|
| 161 | 161 |
func (c *diskUsageImagesContext) Type() string {
|
| ... | ... |
@@ -26,7 +26,7 @@ type ImageContext struct {
|
| 26 | 26 |
Digest bool |
| 27 | 27 |
} |
| 28 | 28 |
|
| 29 |
-func isDangling(image types.Image) bool {
|
|
| 29 |
+func isDangling(image types.ImageSummary) bool {
|
|
| 30 | 30 |
return len(image.RepoTags) == 1 && image.RepoTags[0] == "<none>:<none>" && len(image.RepoDigests) == 1 && image.RepoDigests[0] == "<none>@<none>" |
| 31 | 31 |
} |
| 32 | 32 |
|
| ... | ... |
@@ -72,14 +72,14 @@ virtual_size: {{.Size}}
|
| 72 | 72 |
} |
| 73 | 73 |
|
| 74 | 74 |
// ImageWrite writes the formatter images using the ImageContext |
| 75 |
-func ImageWrite(ctx ImageContext, images []types.Image) error {
|
|
| 75 |
+func ImageWrite(ctx ImageContext, images []types.ImageSummary) error {
|
|
| 76 | 76 |
render := func(format func(subContext subContext) error) error {
|
| 77 | 77 |
return imageFormat(ctx, images, format) |
| 78 | 78 |
} |
| 79 | 79 |
return ctx.Write(&imageContext{}, render)
|
| 80 | 80 |
} |
| 81 | 81 |
|
| 82 |
-func imageFormat(ctx ImageContext, images []types.Image, format func(subContext subContext) error) error {
|
|
| 82 |
+func imageFormat(ctx ImageContext, images []types.ImageSummary, format func(subContext subContext) error) error {
|
|
| 83 | 83 |
for _, image := range images {
|
| 84 | 84 |
images := []*imageContext{}
|
| 85 | 85 |
if isDangling(image) {
|
| ... | ... |
@@ -184,7 +184,7 @@ func imageFormat(ctx ImageContext, images []types.Image, format func(subContext |
| 184 | 184 |
type imageContext struct {
|
| 185 | 185 |
HeaderContext |
| 186 | 186 |
trunc bool |
| 187 |
- i types.Image |
|
| 187 |
+ i types.ImageSummary |
|
| 188 | 188 |
repo string |
| 189 | 189 |
tag string |
| 190 | 190 |
digest string |
| ... | ... |
@@ -24,36 +24,36 @@ func TestImageContext(t *testing.T) {
|
| 24 | 24 |
call func() string |
| 25 | 25 |
}{
|
| 26 | 26 |
{imageContext{
|
| 27 |
- i: types.Image{ID: imageID},
|
|
| 27 |
+ i: types.ImageSummary{ID: imageID},
|
|
| 28 | 28 |
trunc: true, |
| 29 | 29 |
}, stringid.TruncateID(imageID), imageIDHeader, ctx.ID}, |
| 30 | 30 |
{imageContext{
|
| 31 |
- i: types.Image{ID: imageID},
|
|
| 31 |
+ i: types.ImageSummary{ID: imageID},
|
|
| 32 | 32 |
trunc: false, |
| 33 | 33 |
}, imageID, imageIDHeader, ctx.ID}, |
| 34 | 34 |
{imageContext{
|
| 35 |
- i: types.Image{Size: 10, VirtualSize: 10},
|
|
| 35 |
+ i: types.ImageSummary{Size: 10, VirtualSize: 10},
|
|
| 36 | 36 |
trunc: true, |
| 37 | 37 |
}, "10 B", sizeHeader, ctx.Size}, |
| 38 | 38 |
{imageContext{
|
| 39 |
- i: types.Image{Created: unix},
|
|
| 39 |
+ i: types.ImageSummary{Created: unix},
|
|
| 40 | 40 |
trunc: true, |
| 41 | 41 |
}, time.Unix(unix, 0).String(), createdAtHeader, ctx.CreatedAt}, |
| 42 | 42 |
// FIXME |
| 43 | 43 |
// {imageContext{
|
| 44 |
- // i: types.Image{Created: unix},
|
|
| 44 |
+ // i: types.ImageSummary{Created: unix},
|
|
| 45 | 45 |
// trunc: true, |
| 46 | 46 |
// }, units.HumanDuration(time.Unix(unix, 0)), createdSinceHeader, ctx.CreatedSince}, |
| 47 | 47 |
{imageContext{
|
| 48 |
- i: types.Image{},
|
|
| 48 |
+ i: types.ImageSummary{},
|
|
| 49 | 49 |
repo: "busybox", |
| 50 | 50 |
}, "busybox", repositoryHeader, ctx.Repository}, |
| 51 | 51 |
{imageContext{
|
| 52 |
- i: types.Image{},
|
|
| 52 |
+ i: types.ImageSummary{},
|
|
| 53 | 53 |
tag: "latest", |
| 54 | 54 |
}, "latest", tagHeader, ctx.Tag}, |
| 55 | 55 |
{imageContext{
|
| 56 |
- i: types.Image{},
|
|
| 56 |
+ i: types.ImageSummary{},
|
|
| 57 | 57 |
digest: "sha256:d149ab53f8718e987c3a3024bb8aa0e2caadf6c0328f1d9d850b2a2a67f2819a", |
| 58 | 58 |
}, "sha256:d149ab53f8718e987c3a3024bb8aa0e2caadf6c0328f1d9d850b2a2a67f2819a", digestHeader, ctx.Digest}, |
| 59 | 59 |
} |
| ... | ... |
@@ -262,7 +262,7 @@ image_id: imageID3 |
| 262 | 262 |
} |
| 263 | 263 |
|
| 264 | 264 |
for _, testcase := range cases {
|
| 265 |
- images := []types.Image{
|
|
| 265 |
+ images := []types.ImageSummary{
|
|
| 266 | 266 |
{ID: "imageID1", RepoTags: []string{"image:tag1"}, RepoDigests: []string{"image@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf"}, Created: unixTime},
|
| 267 | 267 |
{ID: "imageID2", RepoTags: []string{"image:tag2"}, Created: unixTime},
|
| 268 | 268 |
{ID: "imageID3", RepoTags: []string{"<none>:<none>"}, RepoDigests: []string{"<none>@<none>"}, Created: unixTime},
|
| ... | ... |
@@ -280,7 +280,7 @@ image_id: imageID3 |
| 280 | 280 |
|
| 281 | 281 |
func TestImageContextWriteWithNoImage(t *testing.T) {
|
| 282 | 282 |
out := bytes.NewBufferString("")
|
| 283 |
- images := []types.Image{}
|
|
| 283 |
+ images := []types.ImageSummary{}
|
|
| 284 | 284 |
|
| 285 | 285 |
contexts := []struct {
|
| 286 | 286 |
context ImageContext |
| ... | ... |
@@ -10,8 +10,8 @@ import ( |
| 10 | 10 |
) |
| 11 | 11 |
|
| 12 | 12 |
// ImageList returns a list of images in the docker host. |
| 13 |
-func (cli *Client) ImageList(ctx context.Context, options types.ImageListOptions) ([]types.Image, error) {
|
|
| 14 |
- var images []types.Image |
|
| 13 |
+func (cli *Client) ImageList(ctx context.Context, options types.ImageListOptions) ([]types.ImageSummary, error) {
|
|
| 14 |
+ var images []types.ImageSummary |
|
| 15 | 15 |
query := url.Values{}
|
| 16 | 16 |
|
| 17 | 17 |
if options.Filters.Len() > 0 {
|
| ... | ... |
@@ -93,7 +93,7 @@ func TestImageList(t *testing.T) {
|
| 93 | 93 |
return nil, fmt.Errorf("%s not set in URL query properly. Expected '%s', got %s", key, expected, actual)
|
| 94 | 94 |
} |
| 95 | 95 |
} |
| 96 |
- content, err := json.Marshal([]types.Image{
|
|
| 96 |
+ content, err := json.Marshal([]types.ImageSummary{
|
|
| 97 | 97 |
{
|
| 98 | 98 |
ID: "image_id2", |
| 99 | 99 |
}, |
| ... | ... |
@@ -71,7 +71,7 @@ type ImageAPIClient interface {
|
| 71 | 71 |
ImageHistory(ctx context.Context, image string) ([]types.ImageHistory, error) |
| 72 | 72 |
ImageImport(ctx context.Context, source types.ImageImportSource, ref string, options types.ImageImportOptions) (io.ReadCloser, error) |
| 73 | 73 |
ImageInspectWithRaw(ctx context.Context, image string) (types.ImageInspect, []byte, error) |
| 74 |
- ImageList(ctx context.Context, options types.ImageListOptions) ([]types.Image, error) |
|
| 74 |
+ ImageList(ctx context.Context, options types.ImageListOptions) ([]types.ImageSummary, error) |
|
| 75 | 75 |
ImageLoad(ctx context.Context, input io.Reader, quiet bool) (types.ImageLoadResponse, error) |
| 76 | 76 |
ImagePull(ctx context.Context, ref string, options types.ImagePullOptions) (io.ReadCloser, error) |
| 77 | 77 |
ImagePush(ctx context.Context, ref string, options types.ImagePushOptions) (io.ReadCloser, error) |
| ... | ... |
@@ -22,7 +22,7 @@ var acceptedImageFilterTags = map[string]bool{
|
| 22 | 22 |
|
| 23 | 23 |
// byCreated is a temporary type used to sort a list of images by creation |
| 24 | 24 |
// time. |
| 25 |
-type byCreated []*types.Image |
|
| 25 |
+type byCreated []*types.ImageSummary |
|
| 26 | 26 |
|
| 27 | 27 |
func (r byCreated) Len() int { return len(r) }
|
| 28 | 28 |
func (r byCreated) Swap(i, j int) { r[i], r[j] = r[j], r[i] }
|
| ... | ... |
@@ -38,7 +38,7 @@ func (daemon *Daemon) Map() map[image.ID]*image.Image {
|
| 38 | 38 |
// filter is a shell glob string applied to repository names. The argument |
| 39 | 39 |
// named all controls whether all images in the graph are filtered, or just |
| 40 | 40 |
// the heads. |
| 41 |
-func (daemon *Daemon) Images(filterArgs, filter string, all bool, withExtraAttrs bool) ([]*types.Image, error) {
|
|
| 41 |
+func (daemon *Daemon) Images(filterArgs, filter string, all bool, withExtraAttrs bool) ([]*types.ImageSummary, error) {
|
|
| 42 | 42 |
var ( |
| 43 | 43 |
allImages map[image.ID]*image.Image |
| 44 | 44 |
err error |
| ... | ... |
@@ -83,8 +83,8 @@ func (daemon *Daemon) Images(filterArgs, filter string, all bool, withExtraAttrs |
| 83 | 83 |
return nil, err |
| 84 | 84 |
} |
| 85 | 85 |
|
| 86 |
- images := []*types.Image{}
|
|
| 87 |
- var imagesMap map[*image.Image]*types.Image |
|
| 86 |
+ images := []*types.ImageSummary{}
|
|
| 87 |
+ var imagesMap map[*image.Image]*types.ImageSummary |
|
| 88 | 88 |
var layerRefs map[layer.ChainID]int |
| 89 | 89 |
var allLayers map[layer.ChainID]layer.Layer |
| 90 | 90 |
var allContainers []*container.Container |
| ... | ... |
@@ -181,7 +181,7 @@ func (daemon *Daemon) Images(filterArgs, filter string, all bool, withExtraAttrs |
| 181 | 181 |
if imagesMap == nil {
|
| 182 | 182 |
allContainers = daemon.List() |
| 183 | 183 |
allLayers = daemon.layerStore.Map() |
| 184 |
- imagesMap = make(map[*image.Image]*types.Image) |
|
| 184 |
+ imagesMap = make(map[*image.Image]*types.ImageSummary) |
|
| 185 | 185 |
layerRefs = make(map[layer.ChainID]int) |
| 186 | 186 |
} |
| 187 | 187 |
|
| ... | ... |
@@ -241,8 +241,8 @@ func (daemon *Daemon) Images(filterArgs, filter string, all bool, withExtraAttrs |
| 241 | 241 |
return images, nil |
| 242 | 242 |
} |
| 243 | 243 |
|
| 244 |
-func newImage(image *image.Image, virtualSize int64) *types.Image {
|
|
| 245 |
- newImage := new(types.Image) |
|
| 244 |
+func newImage(image *image.Image, virtualSize int64) *types.ImageSummary {
|
|
| 245 |
+ newImage := new(types.ImageSummary) |
|
| 246 | 246 |
newImage.ParentID = image.Parent.String() |
| 247 | 247 |
newImage.ID = image.ID().String() |
| 248 | 248 |
newImage.Created = image.Created.Unix() |
| ... | ... |
@@ -18,7 +18,7 @@ func (s *DockerSuite) TestAPIImagesFilter(c *check.C) {
|
| 18 | 18 |
for _, n := range []string{name, name2, name3} {
|
| 19 | 19 |
dockerCmd(c, "tag", "busybox", n) |
| 20 | 20 |
} |
| 21 |
- type image types.Image |
|
| 21 |
+ type image types.ImageSummary |
|
| 22 | 22 |
getImages := func(filter string) []image {
|
| 23 | 23 |
v := url.Values{}
|
| 24 | 24 |
v.Set("filter", filter)
|