Skip to content
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

Merged
merged 1 commit into from Sep 10, 2015

Conversation

NOX73
Copy link
Contributor

@NOX73 NOX73 commented May 13, 2015

It closes #10139.

@jessfraz
Copy link
Contributor

this will also need docs updates etc. and tests.

}
}
}
s.Unlock()
Copy link
Contributor

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()

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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.

@NOX73
Copy link
Contributor Author

NOX73 commented May 14, 2015

@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)
I find docs here docs/sources/reference/api/docker_remote_api_v1.9.md. Are there any other places which should be updated?

@vdemeester
Copy link
Member

@NOX73 It should be in the integration test (integration-cli), and because you've change the images/:id/json, I would guess: docker_api_inspect_test.go or docker_api_image_test.go(and maybe in the cli ones, like docker_cli_inspect_tes.go but I doubt it).

After looking a bit it seems there, I think the best place should be in docker_api_inspect_test.go but there is only the container one in there, should create a new one for the image that does almost the same thing.

func (s *DockerSuite) TestInspectApiImageResponse(c *check.C) {
    // […]
    endpoint := "/images/" + imageId + "/json"
    // […]
}

@NOX73 NOX73 force-pushed the 10139-tags-list-get-image-api branch from 943c63b to f3c764e Compare May 18, 2015 13:23
@NOX73
Copy link
Contributor Author

NOX73 commented May 18, 2015

@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{}
Copy link
Member

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{}

@vdemeester
Copy link
Member

@NOX73 Could you take care of the comment from @runcom ? 😉

@NOX73 NOX73 force-pushed the 10139-tags-list-get-image-api branch from f3c764e to 5e5cab6 Compare May 26, 2015 14:57
@NOX73
Copy link
Contributor Author

NOX73 commented May 26, 2015

@runcom @vdemeester done

@NOX73 NOX73 force-pushed the 10139-tags-list-get-image-api branch from 5e5cab6 to 14d35b8 Compare June 2, 2015 09:35
@vdemeester
Copy link
Member

@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 Tag field and that it is what we expect)

@runcom
Copy link
Member

runcom commented Jun 3, 2015

ping @duglin or @calavera about design before moving to code review and rebase, this SGTM

@NOX73
Copy link
Contributor Author

NOX73 commented Jun 3, 2015

@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?

@vdemeester
Copy link
Member

@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")
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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)
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@runcom done

@NOX73 NOX73 force-pushed the 10139-tags-list-get-image-api branch 2 times, most recently from 3f37678 to c27eac0 Compare June 15, 2015 15:15
@thaJeztah
Copy link
Member

@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

@NOX73 NOX73 force-pushed the 10139-tags-list-get-image-api branch from c27eac0 to 8a41211 Compare June 18, 2015 20:49
"github.com/go-check/check"
)

func contains(tags []string, tag string) bool {
Copy link
Member

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.

@vdemeester
Copy link
Member

ping @NOX73, could you take care of @cpuguy83 comments ? 😉

@NOX73
Copy link
Contributor Author

NOX73 commented Aug 16, 2015

yes, of course, asap, give me one or two days

@NOX73 NOX73 force-pushed the 10139-tags-list-get-image-api branch 2 times, most recently from 251c6fa to 401e372 Compare August 21, 2015 11:03
@NOX73
Copy link
Contributor Author

NOX73 commented Aug 21, 2015

@vdemeester @cpuguy83 could you take a look here )

"Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
"Parent": "27cf784147099545",
"Size": 6824592
"ContainerConfig" : {
Copy link
Member

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?

Copy link
Member

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
  }
}

Copy link
Member

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)

Copy link
Member

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.

Copy link
Member

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohh right ! I see 😅

Copy link
Member

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) 😄

Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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!

@cpuguy83
Copy link
Member

LGTM

@bfirsh
Copy link
Contributor

bfirsh commented Aug 28, 2015

@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!

@NOX73
Copy link
Contributor Author

NOX73 commented Aug 30, 2015

@bfirsh @cpuguy83 rebased & updated /image/ubuntu/json example json in docs.

@calavera
Copy link
Contributor

calavera commented Sep 5, 2015

LGTM. Moving to docs review

@SvenDowideit
Copy link
Contributor

docs LGTM - @thaJeztah @moxiegirl

"WorkingDir" : "",
"VolumeDriver" : "",
"OnBuild" : null,
"Labels" : {},
Copy link
Member

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)

Copy link
Contributor

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.

Copy link
Contributor Author

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 ...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@NOX73 NOX73 force-pushed the 10139-tags-list-get-image-api branch from a19b7f7 to d80ce7e Compare September 10, 2015 08:20
It closes moby#10139.

Signed-off-by: Rozhnov Alexandr <nox73@ya.ru>
@NOX73 NOX73 force-pushed the 10139-tags-list-get-image-api branch from d80ce7e to e9e68fa Compare September 10, 2015 08:55
@thaJeztah
Copy link
Member

docs LGTM

waiting for Janky/Windows

calavera added a commit that referenced this pull request Sep 10, 2015
Added tags list to /images/:id/json api.
@calavera calavera merged commit bb1996a into moby:master Sep 10, 2015
@thaJeztah thaJeztah added this to the 1.9.0 milestone Oct 28, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API: image inspection doesn't return tags