heroku / docker-registry-client

A Go API client for the v2 Docker Registry API
BSD 3-Clause "New" or "Revised" License
297 stars 225 forks source link

Provide API to retrieve an image's digest #19

Closed omallo closed 7 years ago

omallo commented 7 years ago

I've just started using this library and while it works fine for most things, I haven't found a way to retrieve an image's digest. Would it be possible to add this functionality to the library?

Based on the API docs, the digest seems to be delivered in the Docker-Content-Digest header.

omallo commented 7 years ago

I've just seen that this can be accomplished as follows using the Client exposed by the library:

request, _ := http.NewRequest("HEAD", "https://registry-1.docker.io/v2/library/alpine/manifests/latest", nil)
request.Header.Add("Accept", "application/vnd.docker.distribution.manifest.v2+json")
response, _ := registry.Client.Do(request)
fmt.Println(response.Header["Docker-Content-Digest"][0])

However, I think it would still be nice if this functionality would be exposed by the library itself.

martinskis commented 7 years ago

Was looking at this a few weeks ago myself. Came back to check and saw your comment. The Docker Manifest in the library would need to be changed to schema2. But I like how you dealt with it, my solution was dirtier :)

lorenzobenvenuti commented 7 years ago

I've created a PR with this feature and manifest deletion: #21

dmathieu commented 7 years ago

Done in #21.