New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added tags list to /images/:id/json api. #13185
Conversation
76cef41
to
943c63b
Compare
this will also need docs updates etc. and tests. |
} | ||
} | ||
} | ||
s.Unlock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be on line 36 as defer s.Unlock()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually not necessary, there is no returns between.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think structure should be unlocked asap.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we need a lock at all, can we at least make it a read-lock so we don't block all interactions on the image DB?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then we have to include sync.RWMutex
to TagStore
structure instead of sync.Mutex
. I could do it. Can this change break something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be ok - but let's try it and see if the tests are ok.
@jfrazelle should I do these updates here? I couldn't find any tests for this. Could you show me where is it? (Sorry, I'm new to docker contributing) |
@NOX73 It should be in the integration test ( After looking a bit it seems there, I think the best place should be in func (s *DockerSuite) TestInspectApiImageResponse(c *check.C) {
// […]
endpoint := "/images/" + imageId + "/json"
// […]
} |
943c63b
to
f3c764e
Compare
@vdemeester done, I added test and fixed docs. |
c.Assert(status, check.Equals, http.StatusOK) | ||
c.Assert(err, check.IsNil) | ||
|
||
var inspectJSON map[string]interface{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use types.ImageInspect
instead of map[string]interface{}
f3c764e
to
5e5cab6
Compare
@runcom @vdemeester done |
5e5cab6
to
14d35b8
Compare
@NOX73 I think the test needs to be a little more complete, like checking if there the content of the JSON (and in our case, just the fact that there is a |
@vdemeester The fact that JSON correctly unmarshal to ImageInspect type doesn't mean that it's all good? We can check Tags field, but for me it seems just like code duplication. Should I do it? |
@NOX73 hum well you're right, it's a more general test than just checking the tags.. nevermind my comment, the fact it has correctly unmarshal to ImageInspect is ok 😉 😅. |
c.Fatalf("failed to pull image: %s, %v", out, err) | ||
} | ||
|
||
runCmd = exec.Command(dockerBinary, "images", "-q", "busybox") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Up to you if you want to change it, but you don't need to get the ID for busybox, you can just do GET /images/busybox/json
down below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@duglin is it pulled somewhere before? I don't see.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All I meant is that they could use 'busybox' (by name) instead of busybox's ID. Should result in the same thing, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, yes. I get it. Thanks, I'll do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@duglin done
status, body, err := sockRequest("GET", endpoint, nil) | ||
|
||
c.Assert(status, check.Equals, http.StatusOK) | ||
c.Assert(err, check.IsNil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check error before status pls
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@runcom done
3f37678
to
c27eac0
Compare
@NOX73 looks like this needs to be rebased as well. Also (but we're not in docs-review yet), the changes to the API documentation need to be moved to docker_remote_api_v1.20.md |
c27eac0
to
8a41211
Compare
"github.com/go-check/check" | ||
) | ||
|
||
func contains(tags []string, tag string) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A function like this exists here:
https://github.com/docker/docker/blob/master/pkg/stringutils/stringutils.go#L45
It's slightly different because it's is discarding case but I don't think that matters here. If so, let's use that.
yes, of course, asap, give me one or two days |
251c6fa
to
401e372
Compare
@vdemeester @cpuguy83 could you take a look here ) |
"Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc", | ||
"Parent": "27cf784147099545", | ||
"Size": 6824592 | ||
"ContainerConfig" : { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something happened here.
Was this wrong in the old version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cpuguy83 ohh yeah, it misses some field (Config
object for example).
Although I don't have the same output as @NOX73 :
{
"Id": "91e54dfb11794fad694460162bf0cb0a4fa710cfa3f60979c177d920813e267c",
"Parent": "d74508fb6632491cea586a1fd7d748dfc5274cd6fdfedee309ecdcbc2bf5cb82",
"Comment": "",
"Created": "2015-08-20T20:21:15.767240511Z",
"Container": "74bb7db8d212f77ab6d467b710451e54d2c60533f641de8c91e7ef343b88a146",
"ContainerConfig": {
"Hostname": "e611e15f9c9d",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": null,
"PublishService": "",
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": null,
"Cmd": [
"\/bin\/sh",
"-c",
"#(nop) CMD [\"\/bin\/bash\"]"
],
"Image": "d74508fb6632491cea586a1fd7d748dfc5274cd6fdfedee309ecdcbc2bf5cb82",
"Volumes": null,
"VolumeDriver": "",
"WorkingDir": "",
"Entrypoint": null,
"NetworkDisabled": false,
"MacAddress": "",
"OnBuild": null,
"Labels": {}
},
"DockerVersion": "1.7.1",
"Author": "",
"Config": {
"Hostname": "e611e15f9c9d",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": null,
"PublishService": "",
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": null,
"Cmd": [
"\/bin\/bash"
],
"Image": "d74508fb6632491cea586a1fd7d748dfc5274cd6fdfedee309ecdcbc2bf5cb82",
"Volumes": null,
"VolumeDriver": "",
"WorkingDir": "",
"Entrypoint": null,
"NetworkDisabled": false,
"MacAddress": "",
"OnBuild": null,
"Labels": {}
},
"Architecture": "amd64",
"Os": "linux",
"Tags" : [
"ubuntu:14.04",
"ubuntu:latest"
],
"Size": 0,
"VirtualSize": 188333286,
"GraphDriver": {
"Name": "btrfs",
"Data": null
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to create some script to start a container producing the right output for updating these examples; for example, the "labels" are now missing in the output, which I think we want to keep in there.
(I know I commented on another PR with an example docker run
to include the labels. I can look it up if you want)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to create some script to start a container producing the right output for updating these examples
Definitely 👍
for example, the "labels" are now missing in the output, which I think we want to keep in there.
Not sure I got this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The old example output had some example labels in the output;
#13185 (diff), that got lost in the new example output;
https://github.com/docker/docker/pull/13185/files#diff-3acbcaa129d9a6972e140d1b4c32cc27R1433
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ohh right ! I see 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's why I think we could use a simple script that builds images and containers, using the same settings each time, and curls the API, capturing the output for copy/paste in the docs (or something similar) 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is likely because the image was created with a different docker version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, should I update this docs here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@NOX73 sorry for my late response; yes, if you can update the docs and make sure the labels are in there, that would be great!
LGTM |
@NOX73 I'm afraid this needs a rebase again - sorry! If you could fix the image output in the docs at the same time, that'd be grand. Thanks for your patience! |
401e372
to
a19b7f7
Compare
LGTM. Moving to docs review |
docs LGTM - @thaJeztah @moxiegirl |
"WorkingDir" : "", | ||
"VolumeDriver" : "", | ||
"OnBuild" : null, | ||
"Labels" : {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the labels got lost in the example output; could you make sure the example output contains some labels?
See my earlier comment for some instructions to create images with the labels that were present previously; #13185 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@NOX73 can you do this and rebase? We'll merge as soon as everything is green again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@calavera done, waiting for checks ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
a19b7f7
to
d80ce7e
Compare
It closes moby#10139. Signed-off-by: Rozhnov Alexandr <nox73@ya.ru>
d80ce7e
to
e9e68fa
Compare
docs LGTM waiting for Janky/Windows |
Added tags list to /images/:id/json api.
It closes #10139.