{"action":"created","comment":{"url":"https://api.github.com/repos/opencontainers/image-spec/pulls/comments/78032106","id":78032106,"diff_hunk":"@@ -50,17 +50,31 @@ var validRefMediaTypes = []string{\n }\n \n func validate(w walker, refs []string, out *log.Logger) error {\n-\tfor _, r := range refs {\n-\t\tref, err := findDescriptor(w, r)\n-\t\tif err != nil {\n-\t\t\treturn err\n+\tds, err := findDescriptors(w)\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\t// TODO(runcom): this is O(N) but it could be O(1) if refs have been\n+\t// map[string]bool coming from the cli package.\n+\t// However, I don't think refs could be large enough to impact performance.\n+\tinRefs := func(ref string) bool {\n+\t\tfor _, r := range refs {\n+\t\t\tif r == ref {\n+\t\t\t\treturn true\n+\t\t\t}\n \t\t}\n-\n-\t\tif err = ref.validate(w, validRefMediaTypes); err != nil {\n+\t\treturn false\n+\t}\n+\thasRefs := len(refs) != 0\n+\tfor ref, d := range ds {\n+\t\tif hasRefs && !inRefs(ref) {","path":"image/image.go","position":27,"original_position":27,"commit_id":"5c9400d6138ab3a5e93d6fa4fec9e9257c2a49b6","original_commit_id":"5c9400d6138ab3a5e93d6fa4fec9e9257c2a49b6","user":{"login":"runcom","id":849915,"avatar_url":"https://avatars.githubusercontent.com/u/849915?v=3","gravatar_id":"","url":"https://api.github.com/users/runcom","html_url":"https://github.com/runcom","followers_url":"https://api.github.com/users/runcom/followers","following_url":"https://api.github.com/users/runcom/following{/other_user}","gists_url":"https://api.github.com/users/runcom/gists{/gist_id}","starred_url":"https://api.github.com/users/runcom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/runcom/subscriptions","organizations_url":"https://api.github.com/users/runcom/orgs","repos_url":"https://api.github.com/users/runcom/repos","events_url":"https://api.github.com/users/runcom/events{/privacy}","received_events_url":"https://api.github.com/users/runcom/received_events","type":"User","site_admin":false},"body":"it's equivalent right? you still do an O(N) iterating over refs :(\r\n\r\nI guess I'll change as you did if you really wish to","created_at":"2016-09-08T15:40:01Z","updated_at":"2016-09-08T15:40:01Z","html_url":"https://github.com/opencontainers/image-spec/pull/279#discussion_r78032106","pull_request_url":"https://api.github.com/repos/opencontainers/image-spec/pulls/279","_links":{"self":{"href":"https://api.github.com/repos/opencontainers/image-spec/pulls/comments/78032106"},"html":{"href":"https://github.com/opencontainers/image-spec/pull/279#discussion_r78032106"},"pull_request":{"href":"https://api.github.com/repos/opencontainers/image-spec/pulls/279"}}},"pull_request":{"url":"https://api.github.com/repos/opencontainers/image-spec/pulls/279","id":84481584,"html_url":"https://github.com/opencontainers/image-spec/pull/279","diff_url":"https://github.com/opencontainers/image-spec/pull/279.diff","patch_url":"https://github.com/opencontainers/image-spec/pull/279.patch","issue_url":"https://api.github.com/repos/opencontainers/image-spec/issues/279","number":279,"state":"open","locked":false,"title":"cmd/oci-image-tool: validate all refs by default","user":{"login":"runcom","id":849915,"avatar_url":"https://avatars.githubusercontent.com/u/849915?v=3","gravatar_id":"","url":"https://api.github.com/users/runcom","html_url":"https://github.com/runcom","followers_url":"https://api.github.com/users/runcom/followers","following_url":"https://api.github.com/users/runcom/following{/other_user}","gists_url":"https://api.github.com/users/runcom/gists{/gist_id}","starred_url":"https://api.github.com/users/runcom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/runcom/subscriptions","organizations_url":"https://api.github.com/users/runcom/orgs","repos_url":"https://api.github.com/users/runcom/repos","events_url":"https://api.github.com/users/runcom/events{/privacy}","received_events_url":"https://api.github.com/users/runcom/received_events","type":"User","site_admin":false},"body":"This is taking care of https://github.com/opencontainers/image-spec/issues/271#issuecomment-245325132 (left a TODO/FIXME for later in case).\r\n\r\nI'll adapt everything to be same as per https://github.com/opencontainers/image-spec/issues/266 later\r\n\r\n```shell\r\n$ oci-image-tool validate /home/amurdaca/src/github.com/projectatomic/skopeo/busybox-oci2\r\nreference \"12.04\": OK\r\nreference \"3.1\": OK\r\nreference \"a59906e33509d14c036c8678d687bd4eec81ed7c4b8ce907b888c607f6a1e0e6\": OK\r\nreference \"latest\": OK\r\nreference \"notlatest\": OK\r\nreference \"tag\": OK\r\n/home/amurdaca/src/github.com/projectatomic/skopeo/busybox-oci2: OK\r\n```\r\n\r\n/cc @wking @vbatts @philips @stevvooe \r\n\r\nSigned-off-by: Antonio Murdaca <runcom@redhat.com>","created_at":"2016-09-08T13:52:44Z","updated_at":"2016-09-08T15:40:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"403c024fd76c2fa86720d4849c476e686d728993","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/opencontainers/image-spec/pulls/279/commits","review_comments_url":"https://api.github.com/repos/opencontainers/image-spec/pulls/279/comments","review_comment_url":"https://api.github.com/repos/opencontainers/image-spec/pulls/comments{/number}","comments_url":"https://api.github.com/repos/opencontainers/image-spec/issues/279/comments","statuses_url":"https://api.github.com/repos/opencontainers/image-spec/statuses/5c9400d6138ab3a5e93d6fa4fec9e9257c2a49b6","head":{"label":"runcom:validate-all-refs","ref":"validate-all-refs","sha":"5c9400d6138ab3a5e93d6fa4fec9e9257c2a49b6","user":{"login":"runcom","id":849915,"avatar_url":"https://avatars.githubusercontent.com/u/849915?v=3","gravatar_id":"","url":"https://api.github.com/users/runcom","html_url":"https://github.com/runcom","followers_url":"https://api.github.com/users/runcom/followers","following_url":"https://api.github.com/users/runcom/following{/other_user}","gists_url":"https://api.github.com/users/runcom/gists{/gist_id}","starred_url":"https://api.github.com/users/runcom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/runcom/subscriptions","organizations_url":"https://api.github.com/users/runcom/orgs","repos_url":"https://api.github.com/users/runcom/repos","events_url":"https://api.github.com/users/runcom/events{/privacy}","received_events_url":"https://api.github.com/users/runcom/received_events","type":"User","site_admin":false},"repo":{"id":56545452,"name":"image-spec","full_name":"runcom/image-spec","owner":{"login":"runcom","id":849915,"avatar_url":"https://avatars.githubusercontent.com/u/849915?v=3","gravatar_id":"","url":"https://api.github.com/users/runcom","html_url":"https://github.com/runcom","followers_url":"https://api.github.com/users/runcom/followers","following_url":"https://api.github.com/users/runcom/following{/other_user}","gists_url":"https://api.github.com/users/runcom/gists{/gist_id}","starred_url":"https://api.github.com/users/runcom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/runcom/subscriptions","organizations_url":"https://api.github.com/users/runcom/orgs","repos_url":"https://api.github.com/users/runcom/repos","events_url":"https://api.github.com/users/runcom/events{/privacy}","received_events_url":"https://api.github.com/users/runcom/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/runcom/image-spec","description":"OCI Image Format","fork":true,"url":"https://api.github.com/repos/runcom/image-spec","forks_url":"https://api.github.com/repos/runcom/image-spec/forks","keys_url":"https://api.github.com/repos/runcom/image-spec/keys{/key_id}","collaborators_url":"https://api.github.com/repos/runcom/image-spec/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/runcom/image-spec/teams","hooks_url":"https://api.github.com/repos/runcom/image-spec/hooks","issue_events_url":"https://api.github.com/repos/runcom/image-spec/issues/events{/number}","events_url":"https://api.github.com/repos/runcom/image-spec/events","assignees_url":"https://api.github.com/repos/runcom/image-spec/assignees{/user}","branches_url":"https://api.github.com/repos/runcom/image-spec/branches{/branch}","tags_url":"https://api.github.com/repos/runcom/image-spec/tags","blobs_url":"https://api.github.com/repos/runcom/image-spec/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/runcom/image-spec/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/runcom/image-spec/git/refs{/sha}","trees_url":"https://api.github.com/repos/runcom/image-spec/git/trees{/sha}","statuses_url":"https://api.github.com/repos/runcom/image-spec/statuses/{sha}","languages_url":"https://api.github.com/repos/runcom/image-spec/languages","stargazers_url":"https://api.github.com/repos/runcom/image-spec/stargazers","contributors_url":"https://api.github.com/repos/runcom/image-spec/contributors","subscribers_url":"https://api.github.com/repos/runcom/image-spec/subscribers","subscription_url":"https://api.github.com/repos/runcom/image-spec/subscription","commits_url":"https://api.github.com/repos/runcom/image-spec/commits{/sha}","git_commits_url":"https://api.github.com/repos/runcom/image-spec/git/commits{/sha}","comments_url":"https://api.github.com/repos/runcom/image-spec/comments{/number}","issue_comment_url":"https://api.github.com/repos/runcom/image-spec/issues/comments{/number}","contents_url":"https://api.github.com/repos/runcom/image-spec/contents/{+path}","compare_url":"https://api.github.com/repos/runcom/image-spec/compare/{base}...{head}","merges_url":"https://api.github.com/repos/runcom/image-spec/merges","archive_url":"https://api.github.com/repos/runcom/image-spec/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/runcom/image-spec/downloads","issues_url":"https://api.github.com/repos/runcom/image-spec/issues{/number}","pulls_url":"https://api.github.com/repos/runcom/image-spec/pulls{/number}","milestones_url":"https://api.github.com/repos/runcom/image-spec/milestones{/number}","notifications_url":"https://api.github.com/repos/runcom/image-spec/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/runcom/image-spec/labels{/name}","releases_url":"https://api.github.com/repos/runcom/image-spec/releases{/id}","deployments_url":"https://api.github.com/repos/runcom/image-spec/deployments","created_at":"2016-04-18T22:05:13Z","updated_at":"2016-04-18T22:05:14Z","pushed_at":"2016-09-08T13:50:57Z","git_url":"git://github.com/runcom/image-spec.git","ssh_url":"git@github.com:runcom/image-spec.git","clone_url":"https://github.com/runcom/image-spec.git","svn_url":"https://github.com/runcom/image-spec","homepage":"https://www.opencontainers.org/","size":688,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"opencontainers:master","ref":"master","sha":"9a93cca4f6d1f6b3509c6b8f7bc858e15b1ce508","user":{"login":"opencontainers","id":12563465,"avatar_url":"https://avatars.githubusercontent.com/u/12563465?v=3","gravatar_id":"","url":"https://api.github.com/users/opencontainers","html_url":"https://github.com/opencontainers","followers_url":"https://api.github.com/users/opencontainers/followers","following_url":"https://api.github.com/users/opencontainers/following{/other_user}","gists_url":"https://api.github.com/users/opencontainers/gists{/gist_id}","starred_url":"https://api.github.com/users/opencontainers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opencontainers/subscriptions","organizations_url":"https://api.github.com/users/opencontainers/orgs","repos_url":"https://api.github.com/users/opencontainers/repos","events_url":"https://api.github.com/users/opencontainers/events{/privacy}","received_events_url":"https://api.github.com/users/opencontainers/received_events","type":"Organization","site_admin":false},"repo":{"id":54503347,"name":"image-spec","full_name":"opencontainers/image-spec","owner":{"login":"opencontainers","id":12563465,"avatar_url":"https://avatars.githubusercontent.com/u/12563465?v=3","gravatar_id":"","url":"https://api.github.com/users/opencontainers","html_url":"https://github.com/opencontainers","followers_url":"https://api.github.com/users/opencontainers/followers","following_url":"https://api.github.com/users/opencontainers/following{/other_user}","gists_url":"https://api.github.com/users/opencontainers/gists{/gist_id}","starred_url":"https://api.github.com/users/opencontainers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opencontainers/subscriptions","organizations_url":"https://api.github.com/users/opencontainers/orgs","repos_url":"https://api.github.com/users/opencontainers/repos","events_url":"https://api.github.com/users/opencontainers/events{/privacy}","received_events_url":"https://api.github.com/users/opencontainers/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/opencontainers/image-spec","description":"OCI Image Format","fork":false,"url":"https://api.github.com/repos/opencontainers/image-spec","forks_url":"https://api.github.com/repos/opencontainers/image-spec/forks","keys_url":"https://api.github.com/repos/opencontainers/image-spec/keys{/key_id}","collaborators_url":"https://api.github.com/repos/opencontainers/image-spec/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/opencontainers/image-spec/teams","hooks_url":"https://api.github.com/repos/opencontainers/image-spec/hooks","issue_events_url":"https://api.github.com/repos/opencontainers/image-spec/issues/events{/number}","events_url":"https://api.github.com/repos/opencontainers/image-spec/events","assignees_url":"https://api.github.com/repos/opencontainers/image-spec/assignees{/user}","branches_url":"https://api.github.com/repos/opencontainers/image-spec/branches{/branch}","tags_url":"https://api.github.com/repos/opencontainers/image-spec/tags","blobs_url":"https://api.github.com/repos/opencontainers/image-spec/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/opencontainers/image-spec/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/opencontainers/image-spec/git/refs{/sha}","trees_url":"https://api.github.com/repos/opencontainers/image-spec/git/trees{/sha}","statuses_url":"https://api.github.com/repos/opencontainers/image-spec/statuses/{sha}","languages_url":"https://api.github.com/repos/opencontainers/image-spec/languages","stargazers_url":"https://api.github.com/repos/opencontainers/image-spec/stargazers","contributors_url":"https://api.github.com/repos/opencontainers/image-spec/contributors","subscribers_url":"https://api.github.com/repos/opencontainers/image-spec/subscribers","subscription_url":"https://api.github.com/repos/opencontainers/image-spec/subscription","commits_url":"https://api.github.com/repos/opencontainers/image-spec/commits{/sha}","git_commits_url":"https://api.github.com/repos/opencontainers/image-spec/git/commits{/sha}","comments_url":"https://api.github.com/repos/opencontainers/image-spec/comments{/number}","issue_comment_url":"https://api.github.com/repos/opencontainers/image-spec/issues/comments{/number}","contents_url":"https://api.github.com/repos/opencontainers/image-spec/contents/{+path}","compare_url":"https://api.github.com/repos/opencontainers/image-spec/compare/{base}...{head}","merges_url":"https://api.github.com/repos/opencontainers/image-spec/merges","archive_url":"https://api.github.com/repos/opencontainers/image-spec/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/opencontainers/image-spec/downloads","issues_url":"https://api.github.com/repos/opencontainers/image-spec/issues{/number}","pulls_url":"https://api.github.com/repos/opencontainers/image-spec/pulls{/number}","milestones_url":"https://api.github.com/repos/opencontainers/image-spec/milestones{/number}","notifications_url":"https://api.github.com/repos/opencontainers/image-spec/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/opencontainers/image-spec/labels{/name}","releases_url":"https://api.github.com/repos/opencontainers/image-spec/releases{/id}","deployments_url":"https://api.github.com/repos/opencontainers/image-spec/deployments","created_at":"2016-03-22T19:34:41Z","updated_at":"2016-09-08T09:40:53Z","pushed_at":"2016-09-08T14:41:28Z","git_url":"git://github.com/opencontainers/image-spec.git","ssh_url":"git@github.com:opencontainers/image-spec.git","clone_url":"https://github.com/opencontainers/image-spec.git","svn_url":"https://github.com/opencontainers/image-spec","homepage":"https://www.opencontainers.org/","size":819,"stargazers_count":122,"watchers_count":122,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":34,"mirror_url":null,"open_issues_count":54,"forks":34,"open_issues":54,"watchers":122,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/opencontainers/image-spec/pulls/279"},"html":{"href":"https://github.com/opencontainers/image-spec/pull/279"},"issue":{"href":"https://api.github.com/repos/opencontainers/image-spec/issues/279"},"comments":{"href":"https://api.github.com/repos/opencontainers/image-spec/issues/279/comments"},"review_comments":{"href":"https://api.github.com/repos/opencontainers/image-spec/pulls/279/comments"},"review_comment":{"href":"https://api.github.com/repos/opencontainers/image-spec/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/opencontainers/image-spec/pulls/279/commits"},"statuses":{"href":"https://api.github.com/repos/opencontainers/image-spec/statuses/5c9400d6138ab3a5e93d6fa4fec9e9257c2a49b6"}}}}
{"actor":{"display_login":"runcom"}}