{"action":"created","comment":{"url":"https://api.github.com/repos/meteor/docker-registry-client/pulls/comments/67977980","id":67977980,"diff_hunk":"@@ -0,0 +1,76 @@\n+package registry\n+\n+import (\n+\t\"encoding/json\"\n+\t\"errors\"\n+\t\"golang.org/x/net/context\"\n+\t\"golang.org/x/net/context/ctxhttp\"\n+\t\"net/http\"\n+)\n+\n+// ErrBadSchema is returned when server returns an unsupported or invalid schema format.\n+var ErrBadSchema = errors.New(\"Server did not return a supported schema format\")\n+\n+// ErrDigestNotFound is returned when server does not include digest header in response.\n+var ErrDigestNotFound = errors.New(\"Docker-Content-Digest header not found\")\n+\n+type manifestResponse struct {\n+\tSchemaVersion int    `json:\"schemaVersion\"`\n+\tMediaType     string `json:\"mediaType\"` // v2 only\n+}\n+\n+const (\n+\tschemaV1MimeType = \"application/vnd.docker.distribution.manifest.v1+json\"\n+\tschemaV2MimeType = \"application/vnd.docker.distribution.manifest.v2+json\"\n+)\n+\n+func (registry *Registry) GetManifestDigest(ctx context.Context, repository string, reference string) (string, error) {\n+\turl := registry.url(\"/v2/%s/manifests/%s\", repository, reference)\n+\tregistry.Logf(\"registry.manifests url=%s repository=%s reference=%s\", url, repository, reference)\n+\n+\treq, err := http.NewRequest(\"GET\", url, nil)\n+\tif err != nil {\n+\t\treturn \"\", err\n+\t}\n+\n+\t// both schema formats are valid\n+\treq.Header[\"Accept\"] = []string{schemaV2MimeType, schemaV1MimeType}\n+\n+\tresp, err := ctxhttp.Do(ctx, registry.Client, req)\n+\tif resp != nil {\n+\t\tdefer resp.Body.Close()\n+\t}\n+\tif err != nil {\n+\t\treturn \"\", chooseError(ctx, err)\n+\t}\n+\n+\tvar manifest manifestResponse\n+\tdecoder := json.NewDecoder(resp.Body)\n+\tif err := decoder.Decode(&manifest); err != nil {\n+\t\treturn \"\", err\n+\t}\n+\n+\t// sanity check to at least make sure we are getting an image manifest","path":"registry/manifest.go","position":53,"original_position":53,"commit_id":"05029604dacb2dc7def11d83fef0ca43d333929d","original_commit_id":"05029604dacb2dc7def11d83fef0ca43d333929d","user":{"login":"ccp0101","id":303501,"avatar_url":"https://avatars.githubusercontent.com/u/303501?v=3","gravatar_id":"","url":"https://api.github.com/users/ccp0101","html_url":"https://github.com/ccp0101","followers_url":"https://api.github.com/users/ccp0101/followers","following_url":"https://api.github.com/users/ccp0101/following{/other_user}","gists_url":"https://api.github.com/users/ccp0101/gists{/gist_id}","starred_url":"https://api.github.com/users/ccp0101/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ccp0101/subscriptions","organizations_url":"https://api.github.com/users/ccp0101/orgs","repos_url":"https://api.github.com/users/ccp0101/repos","events_url":"https://api.github.com/users/ccp0101/events{/privacy}","received_events_url":"https://api.github.com/users/ccp0101/received_events","type":"User","site_admin":false},"body":"My understanding is that we get SchemaVersion 1 if the manifest uploaded in version 1. Registry does convert version 2 to version 1 if we don't supply the `Accept` header, however there's no reverse conversion. \r\n\r\nHere's the registry code that serves GetManifest. Looks like there's only downgrade conversion (line 128 and onward). \r\nhttps://github.com/docker/distribution/blob/8907f7d/registry/handlers/images.go\r\n\r\nIn the same file, `PutManifest` unmarshalls a manifest (mostly just JSON decode), and doesn't seem to perform any conversion before writing. \r\n\r\nIn my experience, `_/ubuntu` returns V1, whereas my own repo `ccp0101/appbase-node-0.10.45` returns V2.","created_at":"2016-06-22T00:41:19Z","updated_at":"2016-06-22T00:41:19Z","html_url":"https://github.com/meteor/docker-registry-client/pull/1#discussion_r67977980","pull_request_url":"https://api.github.com/repos/meteor/docker-registry-client/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/meteor/docker-registry-client/pulls/comments/67977980"},"html":{"href":"https://github.com/meteor/docker-registry-client/pull/1#discussion_r67977980"},"pull_request":{"href":"https://api.github.com/repos/meteor/docker-registry-client/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/meteor/docker-registry-client/pulls/1","id":74536498,"html_url":"https://github.com/meteor/docker-registry-client/pull/1","diff_url":"https://github.com/meteor/docker-registry-client/pull/1.diff","patch_url":"https://github.com/meteor/docker-registry-client/pull/1.patch","issue_url":"https://api.github.com/repos/meteor/docker-registry-client/issues/1","number":1,"state":"open","locked":false,"title":"Query manifest digest","user":{"login":"ccp0101","id":303501,"avatar_url":"https://avatars.githubusercontent.com/u/303501?v=3","gravatar_id":"","url":"https://api.github.com/users/ccp0101","html_url":"https://github.com/ccp0101","followers_url":"https://api.github.com/users/ccp0101/followers","following_url":"https://api.github.com/users/ccp0101/following{/other_user}","gists_url":"https://api.github.com/users/ccp0101/gists{/gist_id}","starred_url":"https://api.github.com/users/ccp0101/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ccp0101/subscriptions","organizations_url":"https://api.github.com/users/ccp0101/orgs","repos_url":"https://api.github.com/users/ccp0101/repos","events_url":"https://api.github.com/users/ccp0101/events{/privacy}","received_events_url":"https://api.github.com/users/ccp0101/received_events","type":"User","site_admin":false},"body":"- added target API for querying manifest and returning the content digest only\r\n- added a tool to print the digest of any remote image, e.g. `go run getdigest.go library/nginx:latest` should print out same hash from `docker pull library/nginx:latest | tail -n 2 | head -n 1`","created_at":"2016-06-21T00:52:18Z","updated_at":"2016-06-22T00:41:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dfea92bdf12cb1ac4cc330a1d68090beccab65cf","assignee":{"login":"glasser","id":16724,"avatar_url":"https://avatars.githubusercontent.com/u/16724?v=3","gravatar_id":"","url":"https://api.github.com/users/glasser","html_url":"https://github.com/glasser","followers_url":"https://api.github.com/users/glasser/followers","following_url":"https://api.github.com/users/glasser/following{/other_user}","gists_url":"https://api.github.com/users/glasser/gists{/gist_id}","starred_url":"https://api.github.com/users/glasser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glasser/subscriptions","organizations_url":"https://api.github.com/users/glasser/orgs","repos_url":"https://api.github.com/users/glasser/repos","events_url":"https://api.github.com/users/glasser/events{/privacy}","received_events_url":"https://api.github.com/users/glasser/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/meteor/docker-registry-client/pulls/1/commits","review_comments_url":"https://api.github.com/repos/meteor/docker-registry-client/pulls/1/comments","review_comment_url":"https://api.github.com/repos/meteor/docker-registry-client/pulls/comments{/number}","comments_url":"https://api.github.com/repos/meteor/docker-registry-client/issues/1/comments","statuses_url":"https://api.github.com/repos/meteor/docker-registry-client/statuses/05029604dacb2dc7def11d83fef0ca43d333929d","head":{"label":"meteor:changping/digest","ref":"changping/digest","sha":"05029604dacb2dc7def11d83fef0ca43d333929d","user":{"login":"meteor","id":789528,"avatar_url":"https://avatars.githubusercontent.com/u/789528?v=3","gravatar_id":"","url":"https://api.github.com/users/meteor","html_url":"https://github.com/meteor","followers_url":"https://api.github.com/users/meteor/followers","following_url":"https://api.github.com/users/meteor/following{/other_user}","gists_url":"https://api.github.com/users/meteor/gists{/gist_id}","starred_url":"https://api.github.com/users/meteor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/meteor/subscriptions","organizations_url":"https://api.github.com/users/meteor/orgs","repos_url":"https://api.github.com/users/meteor/repos","events_url":"https://api.github.com/users/meteor/events{/privacy}","received_events_url":"https://api.github.com/users/meteor/received_events","type":"Organization","site_admin":false},"repo":{"id":55436351,"name":"docker-registry-client","full_name":"meteor/docker-registry-client","owner":{"login":"meteor","id":789528,"avatar_url":"https://avatars.githubusercontent.com/u/789528?v=3","gravatar_id":"","url":"https://api.github.com/users/meteor","html_url":"https://github.com/meteor","followers_url":"https://api.github.com/users/meteor/followers","following_url":"https://api.github.com/users/meteor/following{/other_user}","gists_url":"https://api.github.com/users/meteor/gists{/gist_id}","starred_url":"https://api.github.com/users/meteor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/meteor/subscriptions","organizations_url":"https://api.github.com/users/meteor/orgs","repos_url":"https://api.github.com/users/meteor/repos","events_url":"https://api.github.com/users/meteor/events{/privacy}","received_events_url":"https://api.github.com/users/meteor/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/meteor/docker-registry-client","description":"A Go API client for the v2 Docker Registry API","fork":true,"url":"https://api.github.com/repos/meteor/docker-registry-client","forks_url":"https://api.github.com/repos/meteor/docker-registry-client/forks","keys_url":"https://api.github.com/repos/meteor/docker-registry-client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/meteor/docker-registry-client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/meteor/docker-registry-client/teams","hooks_url":"https://api.github.com/repos/meteor/docker-registry-client/hooks","issue_events_url":"https://api.github.com/repos/meteor/docker-registry-client/issues/events{/number}","events_url":"https://api.github.com/repos/meteor/docker-registry-client/events","assignees_url":"https://api.github.com/repos/meteor/docker-registry-client/assignees{/user}","branches_url":"https://api.github.com/repos/meteor/docker-registry-client/branches{/branch}","tags_url":"https://api.github.com/repos/meteor/docker-registry-client/tags","blobs_url":"https://api.github.com/repos/meteor/docker-registry-client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/meteor/docker-registry-client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/meteor/docker-registry-client/git/refs{/sha}","trees_url":"https://api.github.com/repos/meteor/docker-registry-client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/meteor/docker-registry-client/statuses/{sha}","languages_url":"https://api.github.com/repos/meteor/docker-registry-client/languages","stargazers_url":"https://api.github.com/repos/meteor/docker-registry-client/stargazers","contributors_url":"https://api.github.com/repos/meteor/docker-registry-client/contributors","subscribers_url":"https://api.github.com/repos/meteor/docker-registry-client/subscribers","subscription_url":"https://api.github.com/repos/meteor/docker-registry-client/subscription","commits_url":"https://api.github.com/repos/meteor/docker-registry-client/commits{/sha}","git_commits_url":"https://api.github.com/repos/meteor/docker-registry-client/git/commits{/sha}","comments_url":"https://api.github.com/repos/meteor/docker-registry-client/comments{/number}","issue_comment_url":"https://api.github.com/repos/meteor/docker-registry-client/issues/comments{/number}","contents_url":"https://api.github.com/repos/meteor/docker-registry-client/contents/{+path}","compare_url":"https://api.github.com/repos/meteor/docker-registry-client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/meteor/docker-registry-client/merges","archive_url":"https://api.github.com/repos/meteor/docker-registry-client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/meteor/docker-registry-client/downloads","issues_url":"https://api.github.com/repos/meteor/docker-registry-client/issues{/number}","pulls_url":"https://api.github.com/repos/meteor/docker-registry-client/pulls{/number}","milestones_url":"https://api.github.com/repos/meteor/docker-registry-client/milestones{/number}","notifications_url":"https://api.github.com/repos/meteor/docker-registry-client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/meteor/docker-registry-client/labels{/name}","releases_url":"https://api.github.com/repos/meteor/docker-registry-client/releases{/id}","deployments_url":"https://api.github.com/repos/meteor/docker-registry-client/deployments","created_at":"2016-04-04T18:49:13Z","updated_at":"2016-04-04T18:49:14Z","pushed_at":"2016-06-21T18:33:56Z","git_url":"git://github.com/meteor/docker-registry-client.git","ssh_url":"git@github.com:meteor/docker-registry-client.git","clone_url":"https://github.com/meteor/docker-registry-client.git","svn_url":"https://github.com/meteor/docker-registry-client","homepage":null,"size":142,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"meteor:master","ref":"master","sha":"c92c2b37bee5e2332df0aa2608ebf020cf86c0da","user":{"login":"meteor","id":789528,"avatar_url":"https://avatars.githubusercontent.com/u/789528?v=3","gravatar_id":"","url":"https://api.github.com/users/meteor","html_url":"https://github.com/meteor","followers_url":"https://api.github.com/users/meteor/followers","following_url":"https://api.github.com/users/meteor/following{/other_user}","gists_url":"https://api.github.com/users/meteor/gists{/gist_id}","starred_url":"https://api.github.com/users/meteor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/meteor/subscriptions","organizations_url":"https://api.github.com/users/meteor/orgs","repos_url":"https://api.github.com/users/meteor/repos","events_url":"https://api.github.com/users/meteor/events{/privacy}","received_events_url":"https://api.github.com/users/meteor/received_events","type":"Organization","site_admin":false},"repo":{"id":55436351,"name":"docker-registry-client","full_name":"meteor/docker-registry-client","owner":{"login":"meteor","id":789528,"avatar_url":"https://avatars.githubusercontent.com/u/789528?v=3","gravatar_id":"","url":"https://api.github.com/users/meteor","html_url":"https://github.com/meteor","followers_url":"https://api.github.com/users/meteor/followers","following_url":"https://api.github.com/users/meteor/following{/other_user}","gists_url":"https://api.github.com/users/meteor/gists{/gist_id}","starred_url":"https://api.github.com/users/meteor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/meteor/subscriptions","organizations_url":"https://api.github.com/users/meteor/orgs","repos_url":"https://api.github.com/users/meteor/repos","events_url":"https://api.github.com/users/meteor/events{/privacy}","received_events_url":"https://api.github.com/users/meteor/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/meteor/docker-registry-client","description":"A Go API client for the v2 Docker Registry API","fork":true,"url":"https://api.github.com/repos/meteor/docker-registry-client","forks_url":"https://api.github.com/repos/meteor/docker-registry-client/forks","keys_url":"https://api.github.com/repos/meteor/docker-registry-client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/meteor/docker-registry-client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/meteor/docker-registry-client/teams","hooks_url":"https://api.github.com/repos/meteor/docker-registry-client/hooks","issue_events_url":"https://api.github.com/repos/meteor/docker-registry-client/issues/events{/number}","events_url":"https://api.github.com/repos/meteor/docker-registry-client/events","assignees_url":"https://api.github.com/repos/meteor/docker-registry-client/assignees{/user}","branches_url":"https://api.github.com/repos/meteor/docker-registry-client/branches{/branch}","tags_url":"https://api.github.com/repos/meteor/docker-registry-client/tags","blobs_url":"https://api.github.com/repos/meteor/docker-registry-client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/meteor/docker-registry-client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/meteor/docker-registry-client/git/refs{/sha}","trees_url":"https://api.github.com/repos/meteor/docker-registry-client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/meteor/docker-registry-client/statuses/{sha}","languages_url":"https://api.github.com/repos/meteor/docker-registry-client/languages","stargazers_url":"https://api.github.com/repos/meteor/docker-registry-client/stargazers","contributors_url":"https://api.github.com/repos/meteor/docker-registry-client/contributors","subscribers_url":"https://api.github.com/repos/meteor/docker-registry-client/subscribers","subscription_url":"https://api.github.com/repos/meteor/docker-registry-client/subscription","commits_url":"https://api.github.com/repos/meteor/docker-registry-client/commits{/sha}","git_commits_url":"https://api.github.com/repos/meteor/docker-registry-client/git/commits{/sha}","comments_url":"https://api.github.com/repos/meteor/docker-registry-client/comments{/number}","issue_comment_url":"https://api.github.com/repos/meteor/docker-registry-client/issues/comments{/number}","contents_url":"https://api.github.com/repos/meteor/docker-registry-client/contents/{+path}","compare_url":"https://api.github.com/repos/meteor/docker-registry-client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/meteor/docker-registry-client/merges","archive_url":"https://api.github.com/repos/meteor/docker-registry-client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/meteor/docker-registry-client/downloads","issues_url":"https://api.github.com/repos/meteor/docker-registry-client/issues{/number}","pulls_url":"https://api.github.com/repos/meteor/docker-registry-client/pulls{/number}","milestones_url":"https://api.github.com/repos/meteor/docker-registry-client/milestones{/number}","notifications_url":"https://api.github.com/repos/meteor/docker-registry-client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/meteor/docker-registry-client/labels{/name}","releases_url":"https://api.github.com/repos/meteor/docker-registry-client/releases{/id}","deployments_url":"https://api.github.com/repos/meteor/docker-registry-client/deployments","created_at":"2016-04-04T18:49:13Z","updated_at":"2016-04-04T18:49:14Z","pushed_at":"2016-06-21T18:33:56Z","git_url":"git://github.com/meteor/docker-registry-client.git","ssh_url":"git@github.com:meteor/docker-registry-client.git","clone_url":"https://github.com/meteor/docker-registry-client.git","svn_url":"https://github.com/meteor/docker-registry-client","homepage":null,"size":142,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/meteor/docker-registry-client/pulls/1"},"html":{"href":"https://github.com/meteor/docker-registry-client/pull/1"},"issue":{"href":"https://api.github.com/repos/meteor/docker-registry-client/issues/1"},"comments":{"href":"https://api.github.com/repos/meteor/docker-registry-client/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/meteor/docker-registry-client/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/meteor/docker-registry-client/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/meteor/docker-registry-client/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/meteor/docker-registry-client/statuses/05029604dacb2dc7def11d83fef0ca43d333929d"}}}}
{"actor":{"display_login":"ccp0101"}}