mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Added tags list to /images/:id/json api.
It closes #10139. Signed-off-by: Rozhnov Alexandr <nox73@ya.ru>
This commit is contained in:
parent
072790bb3b
commit
e9e68fa2d2
5 changed files with 124 additions and 29 deletions
|
@ -96,6 +96,7 @@ type GraphDriverData struct {
|
||||||
// GET "/images/{name:.*}/json"
|
// GET "/images/{name:.*}/json"
|
||||||
type ImageInspect struct {
|
type ImageInspect struct {
|
||||||
ID string `json:"Id"`
|
ID string `json:"Id"`
|
||||||
|
Tags []string
|
||||||
Parent string
|
Parent string
|
||||||
Comment string
|
Comment string
|
||||||
Created string
|
Created string
|
||||||
|
|
|
@ -81,6 +81,7 @@ This section lists each version from latest to oldest. Each listing includes a
|
||||||
* `GET /volumes/(name)` get low-level information about a volume.
|
* `GET /volumes/(name)` get low-level information about a volume.
|
||||||
* `DELETE /volumes/(name)`remove a volume with the specified name.
|
* `DELETE /volumes/(name)`remove a volume with the specified name.
|
||||||
* `VolumeDriver` has been moved from config to hostConfig to make the configuration portable.
|
* `VolumeDriver` has been moved from config to hostConfig to make the configuration portable.
|
||||||
|
* `GET /images/(name)/json` now returns information about tags of the image.
|
||||||
|
|
||||||
|
|
||||||
### v1.20 API changes
|
### v1.20 API changes
|
||||||
|
|
|
@ -1433,7 +1433,7 @@ Return low-level information on the image `name`
|
||||||
|
|
||||||
**Example request**:
|
**Example request**:
|
||||||
|
|
||||||
GET /images/ubuntu/json HTTP/1.1
|
GET /images/example/json HTTP/1.1
|
||||||
|
|
||||||
**Example response**:
|
**Example response**:
|
||||||
|
|
||||||
|
@ -1441,34 +1441,90 @@ Return low-level information on the image `name`
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
|
|
||||||
{
|
{
|
||||||
"Created": "2013-03-23T22:24:18.818426-07:00",
|
"Id" : "85f05633ddc1c50679be2b16a0479ab6f7637f8884e0cfe0f4d20e1ebb3d6e7c",
|
||||||
"Container": "3d67245a8d72ecf13f33dffac9f79dcdf70f75acb84d308770391510e0c23ad0",
|
"Container" : "cb91e48a60d01f1e27028b4fc6819f4f290b3cf12496c8176ec714d0d390984a",
|
||||||
"ContainerConfig":
|
"Comment" : "",
|
||||||
{
|
"Os" : "linux",
|
||||||
"Hostname": "",
|
"Architecture" : "amd64",
|
||||||
"User": "",
|
"Parent" : "91e54dfb11794fad694460162bf0cb0a4fa710cfa3f60979c177d920813e267c",
|
||||||
"AttachStdin": false,
|
"ContainerConfig" : {
|
||||||
"AttachStdout": false,
|
"Tty" : false,
|
||||||
"AttachStderr": false,
|
"Hostname" : "e611e15f9c9d",
|
||||||
"Tty": true,
|
"Volumes" : null,
|
||||||
"OpenStdin": true,
|
"Domainname" : "",
|
||||||
"StdinOnce": false,
|
"AttachStdout" : false,
|
||||||
"Env": null,
|
"PublishService" : "",
|
||||||
"Cmd": ["/bin/bash"],
|
"AttachStdin" : false,
|
||||||
"Dns": null,
|
"OpenStdin" : false,
|
||||||
"Image": "ubuntu",
|
"StdinOnce" : false,
|
||||||
"Labels": {
|
"NetworkDisabled" : false,
|
||||||
"com.example.vendor": "Acme",
|
"OnBuild" : [],
|
||||||
"com.example.license": "GPL",
|
"Image" : "91e54dfb11794fad694460162bf0cb0a4fa710cfa3f60979c177d920813e267c",
|
||||||
"com.example.version": "1.0"
|
"User" : "",
|
||||||
},
|
"WorkingDir" : "",
|
||||||
"Volumes": null,
|
"Entrypoint" : null,
|
||||||
"VolumesFrom": "",
|
"MacAddress" : "",
|
||||||
"WorkingDir": ""
|
"AttachStderr" : false,
|
||||||
},
|
"Labels" : {
|
||||||
"Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
|
"com.example.license" : "GPL",
|
||||||
"Parent": "27cf784147099545",
|
"com.example.version" : "1.0",
|
||||||
"Size": 6824592
|
"com.example.vendor" : "Acme"
|
||||||
|
},
|
||||||
|
"Env" : [
|
||||||
|
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||||
|
],
|
||||||
|
"ExposedPorts" : null,
|
||||||
|
"Cmd" : [
|
||||||
|
"/bin/sh",
|
||||||
|
"-c",
|
||||||
|
"#(nop) LABEL com.example.vendor=Acme com.example.license=GPL com.example.version=1.0"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"DockerVersion" : "1.9.0-dev",
|
||||||
|
"VirtualSize" : 188359297,
|
||||||
|
"Size" : 0,
|
||||||
|
"Author" : "",
|
||||||
|
"Created" : "2015-09-10T08:30:53.26995814Z",
|
||||||
|
"GraphDriver" : {
|
||||||
|
"Name" : "aufs",
|
||||||
|
"Data" : null
|
||||||
|
},
|
||||||
|
"Tags" : [
|
||||||
|
"example:1.0",
|
||||||
|
"example:latest",
|
||||||
|
"example:stable"
|
||||||
|
],
|
||||||
|
"Config" : {
|
||||||
|
"Image" : "91e54dfb11794fad694460162bf0cb0a4fa710cfa3f60979c177d920813e267c",
|
||||||
|
"NetworkDisabled" : false,
|
||||||
|
"OnBuild" : [],
|
||||||
|
"StdinOnce" : false,
|
||||||
|
"PublishService" : "",
|
||||||
|
"AttachStdin" : false,
|
||||||
|
"OpenStdin" : false,
|
||||||
|
"Domainname" : "",
|
||||||
|
"AttachStdout" : false,
|
||||||
|
"Tty" : false,
|
||||||
|
"Hostname" : "e611e15f9c9d",
|
||||||
|
"Volumes" : null,
|
||||||
|
"Cmd" : [
|
||||||
|
"/bin/bash"
|
||||||
|
],
|
||||||
|
"ExposedPorts" : null,
|
||||||
|
"Env" : [
|
||||||
|
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||||
|
],
|
||||||
|
"Labels" : {
|
||||||
|
"com.example.vendor" : "Acme",
|
||||||
|
"com.example.version" : "1.0",
|
||||||
|
"com.example.license" : "GPL"
|
||||||
|
},
|
||||||
|
"Entrypoint" : null,
|
||||||
|
"MacAddress" : "",
|
||||||
|
"AttachStderr" : false,
|
||||||
|
"WorkingDir" : "",
|
||||||
|
"User" : ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Status Codes:
|
Status Codes:
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
|
"github.com/docker/docker/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
// lookupRaw looks up an image by name in a TagStore and returns the raw JSON
|
// lookupRaw looks up an image by name in a TagStore and returns the raw JSON
|
||||||
|
@ -34,8 +35,22 @@ func (s *TagStore) Lookup(name string) (*types.ImageInspect, error) {
|
||||||
return nil, fmt.Errorf("No such image: %s", name)
|
return nil, fmt.Errorf("No such image: %s", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var tags = make([]string, 0)
|
||||||
|
|
||||||
|
s.Lock()
|
||||||
|
for repoName, repository := range s.Repositories {
|
||||||
|
for ref, id := range repository {
|
||||||
|
if id == image.ID {
|
||||||
|
imgRef := utils.ImageReference(repoName, ref)
|
||||||
|
tags = append(tags, imgRef)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
s.Unlock()
|
||||||
|
|
||||||
imageInspect := &types.ImageInspect{
|
imageInspect := &types.ImageInspect{
|
||||||
ID: image.ID,
|
ID: image.ID,
|
||||||
|
Tags: tags,
|
||||||
Parent: image.Parent,
|
Parent: image.Parent,
|
||||||
Comment: image.Comment,
|
Comment: image.Comment,
|
||||||
Created: image.Created.Format(time.RFC3339Nano),
|
Created: image.Created.Format(time.RFC3339Nano),
|
||||||
|
|
|
@ -6,6 +6,8 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/docker/docker/api/types"
|
||||||
|
"github.com/docker/docker/pkg/stringutils"
|
||||||
"github.com/go-check/check"
|
"github.com/go-check/check"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -111,3 +113,23 @@ func (s *DockerSuite) TestInspectApiContainerVolumeDriver(c *check.C) {
|
||||||
c.Fatal("Api version 1.21 expected to include VolumeDriver in 'HostConfig'")
|
c.Fatal("Api version 1.21 expected to include VolumeDriver in 'HostConfig'")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *DockerSuite) TestInspectApiImageResponse(c *check.C) {
|
||||||
|
dockerCmd(c, "tag", "busybox:latest", "busybox:mytag")
|
||||||
|
|
||||||
|
endpoint := "/images/busybox/json"
|
||||||
|
status, body, err := sockRequest("GET", endpoint, nil)
|
||||||
|
|
||||||
|
c.Assert(err, check.IsNil)
|
||||||
|
c.Assert(status, check.Equals, http.StatusOK)
|
||||||
|
|
||||||
|
var imageJSON types.ImageInspect
|
||||||
|
if err = json.Unmarshal(body, &imageJSON); err != nil {
|
||||||
|
c.Fatalf("unable to unmarshal body for latest version: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
c.Assert(len(imageJSON.Tags), check.Equals, 2)
|
||||||
|
|
||||||
|
c.Assert(stringutils.InSlice(imageJSON.Tags, "busybox:latest"), check.Equals, true)
|
||||||
|
c.Assert(stringutils.InSlice(imageJSON.Tags, "busybox:mytag"), check.Equals, true)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue