{"action":"created","comment":{"url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/pulls/comments/34711624","id":34711624,"diff_hunk":"@@ -0,0 +1,94 @@\n+package scopes\n+\n+import (\n+\t\"strings\"\n+)\n+\n+type (\n+\tGiven    []string\n+\tRequired [][]string\n+)\n+\n+// Calls function `matches(j)` for each `j` in `list` until `true` is returned,\n+// or the list is exhausted. Returns `true` if result `true` was returned from\n+// `matches(j)` for some `j`, otherwise false.\n+func some(list []interface{}, matches func(interface{}) bool) bool {\n+\tfor _, j := range list {\n+\t\tif matches(j) {\n+\t\t\treturn true\n+\t\t}\n+\t}\n+\treturn false\n+}\n+\n+// Calls function `matches(j)` for each `j` in `list` until `false` is returned,\n+// or the list is exhausted. Returns `false` if result `false` was returned from\n+// `matches(j)` for some `j`, otherwise true.\n+func every(list []interface{}, matches func(interface{}) bool) bool {\n+\tfor _, j := range list {\n+\t\tif !matches(j) {\n+\t\t\treturn false\n+\t\t}\n+\t}\n+\treturn true\n+}\n+\n+// Returns true if `given` satisfies `required`.\n+//\n+// `given` is a pointer to an array of strings such as:\n+//\n+//  &[]string{\n+//  \t\"abc:*\",\n+//  \t\"123:4:56\",\n+//  \t\"xyz\",\n+//  \t\"AB:*\",\n+//  }\n+//\n+// `required` is a pointer to an array of arrays of strings such as:\n+//\n+//  &[][]string{\n+//  \t{\"abc:def\", \"AB:CD:EF\"},\n+//  \t{\"123:4:5\"},\n+//  \t{\"abc:def\", \"123:4\"},\n+//  \t{\"Xxyz\"},\n+//  }\n+//\n+// 1) The `*` when specified at the end of a scope in `given` operates as a\n+// wildcard, matching anything.\n+//\n+// 2) Each string of inner []string of `required` must be satisfied for the\n+// []string to be satisfied.  `required` is satisfied if only one of the outer\n+// []string of the [][]string is satisfied. In other words, outer array =>\n+// logical OR, inner array => logical AND.\n+//\n+// In the example above, Satisfies would return true, since the scopes\n+// \"abc:def\" and \"AB:CD:EF\" are satisfied by \"abc:*\" and \"AB:*\".\n+func (given *Given) Satisfies(required *Required) bool {","path":"scopes/scopes.go","position":66,"original_position":66,"commit_id":"c78c4c373aba7a0dc4b0b019514aa377a7e1e641","original_commit_id":"c78c4c373aba7a0dc4b0b019514aa377a7e1e641","user":{"login":"jonasfj","id":149732,"avatar_url":"https://avatars.githubusercontent.com/u/149732?v=3","gravatar_id":"","url":"https://api.github.com/users/jonasfj","html_url":"https://github.com/jonasfj","followers_url":"https://api.github.com/users/jonasfj/followers","following_url":"https://api.github.com/users/jonasfj/following{/other_user}","gists_url":"https://api.github.com/users/jonasfj/gists{/gist_id}","starred_url":"https://api.github.com/users/jonasfj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonasfj/subscriptions","organizations_url":"https://api.github.com/users/jonasfj/orgs","repos_url":"https://api.github.com/users/jonasfj/repos","events_url":"https://api.github.com/users/jonasfj/events{/privacy}","received_events_url":"https://api.github.com/users/jonasfj/received_events","type":"User","site_admin":false},"body":"This implementation is very complex...\r\n\r\nI would do it as follows:\r\nhttps://play.golang.org/p/-OWB--4fIb\r\n\r\nIt probably needs a little cleanup, but iterating over the bytes in go is easy... so that's fairly sane to do... Notice that UTF-8 can be checked byte by byte, and '*' is a single byte.","created_at":"2015-07-15T18:24:31Z","updated_at":"2015-07-15T18:24:31Z","html_url":"https://github.com/taskcluster/taskcluster-client-go/pull/2#discussion_r34711624","pull_request_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/taskcluster/taskcluster-client-go/pulls/comments/34711624"},"html":{"href":"https://github.com/taskcluster/taskcluster-client-go/pull/2#discussion_r34711624"},"pull_request":{"href":"https://api.github.com/repos/taskcluster/taskcluster-client-go/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/pulls/2","id":40042132,"html_url":"https://github.com/taskcluster/taskcluster-client-go/pull/2","diff_url":"https://github.com/taskcluster/taskcluster-client-go/pull/2.diff","patch_url":"https://github.com/taskcluster/taskcluster-client-go/pull/2.patch","issue_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/issues/2","number":2,"state":"open","locked":false,"title":"[Bug 1184044] Check whether a set of given scopes satisfies required scopes","user":{"login":"petemoore","id":190790,"avatar_url":"https://avatars.githubusercontent.com/u/190790?v=3","gravatar_id":"","url":"https://api.github.com/users/petemoore","html_url":"https://github.com/petemoore","followers_url":"https://api.github.com/users/petemoore/followers","following_url":"https://api.github.com/users/petemoore/following{/other_user}","gists_url":"https://api.github.com/users/petemoore/gists{/gist_id}","starred_url":"https://api.github.com/users/petemoore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/petemoore/subscriptions","organizations_url":"https://api.github.com/users/petemoore/orgs","repos_url":"https://api.github.com/users/petemoore/repos","events_url":"https://api.github.com/users/petemoore/events{/privacy}","received_events_url":"https://api.github.com/users/petemoore/received_events","type":"User","site_admin":false},"body":"Highly inspired by the node implementation! =)\r\n\r\nNo generics in Go makes it a little ugly with explicit castings and copying of arrays. No native sets either, but slices suffice.\r\n\r\n(P.S. I did not see any tests for node implementation)","created_at":"2015-07-15T16:29:30Z","updated_at":"2015-07-15T18:24:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"272cf88c7cd81c47e264301892505519f8996a8a","assignee":{"login":"jonasfj","id":149732,"avatar_url":"https://avatars.githubusercontent.com/u/149732?v=3","gravatar_id":"","url":"https://api.github.com/users/jonasfj","html_url":"https://github.com/jonasfj","followers_url":"https://api.github.com/users/jonasfj/followers","following_url":"https://api.github.com/users/jonasfj/following{/other_user}","gists_url":"https://api.github.com/users/jonasfj/gists{/gist_id}","starred_url":"https://api.github.com/users/jonasfj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonasfj/subscriptions","organizations_url":"https://api.github.com/users/jonasfj/orgs","repos_url":"https://api.github.com/users/jonasfj/repos","events_url":"https://api.github.com/users/jonasfj/events{/privacy}","received_events_url":"https://api.github.com/users/jonasfj/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/pulls/2/commits","review_comments_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/pulls/2/comments","review_comment_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/pulls/comments{/number}","comments_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/issues/2/comments","statuses_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/statuses/c78c4c373aba7a0dc4b0b019514aa377a7e1e641","head":{"label":"taskcluster:bug1184044","ref":"bug1184044","sha":"c78c4c373aba7a0dc4b0b019514aa377a7e1e641","user":{"login":"taskcluster","id":6257436,"avatar_url":"https://avatars.githubusercontent.com/u/6257436?v=3","gravatar_id":"","url":"https://api.github.com/users/taskcluster","html_url":"https://github.com/taskcluster","followers_url":"https://api.github.com/users/taskcluster/followers","following_url":"https://api.github.com/users/taskcluster/following{/other_user}","gists_url":"https://api.github.com/users/taskcluster/gists{/gist_id}","starred_url":"https://api.github.com/users/taskcluster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/taskcluster/subscriptions","organizations_url":"https://api.github.com/users/taskcluster/orgs","repos_url":"https://api.github.com/users/taskcluster/repos","events_url":"https://api.github.com/users/taskcluster/events{/privacy}","received_events_url":"https://api.github.com/users/taskcluster/received_events","type":"Organization","site_admin":false},"repo":{"id":29486192,"name":"taskcluster-client-go","full_name":"taskcluster/taskcluster-client-go","owner":{"login":"taskcluster","id":6257436,"avatar_url":"https://avatars.githubusercontent.com/u/6257436?v=3","gravatar_id":"","url":"https://api.github.com/users/taskcluster","html_url":"https://github.com/taskcluster","followers_url":"https://api.github.com/users/taskcluster/followers","following_url":"https://api.github.com/users/taskcluster/following{/other_user}","gists_url":"https://api.github.com/users/taskcluster/gists{/gist_id}","starred_url":"https://api.github.com/users/taskcluster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/taskcluster/subscriptions","organizations_url":"https://api.github.com/users/taskcluster/orgs","repos_url":"https://api.github.com/users/taskcluster/repos","events_url":"https://api.github.com/users/taskcluster/events{/privacy}","received_events_url":"https://api.github.com/users/taskcluster/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/taskcluster/taskcluster-client-go","description":"A go (golang) port of taskcluster-client","fork":false,"url":"https://api.github.com/repos/taskcluster/taskcluster-client-go","forks_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/forks","keys_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/keys{/key_id}","collaborators_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/teams","hooks_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/hooks","issue_events_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/issues/events{/number}","events_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/events","assignees_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/assignees{/user}","branches_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/branches{/branch}","tags_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/tags","blobs_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/git/refs{/sha}","trees_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/git/trees{/sha}","statuses_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/statuses/{sha}","languages_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/languages","stargazers_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/stargazers","contributors_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/contributors","subscribers_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/subscribers","subscription_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/subscription","commits_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/commits{/sha}","git_commits_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/git/commits{/sha}","comments_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/comments{/number}","issue_comment_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/issues/comments{/number}","contents_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/contents/{+path}","compare_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/compare/{base}...{head}","merges_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/merges","archive_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/downloads","issues_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/issues{/number}","pulls_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/pulls{/number}","milestones_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/milestones{/number}","notifications_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/labels{/name}","releases_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/releases{/id}","created_at":"2015-01-19T18:54:28Z","updated_at":"2015-07-06T02:16:51Z","pushed_at":"2015-07-15T16:34:29Z","git_url":"git://github.com/taskcluster/taskcluster-client-go.git","ssh_url":"git@github.com:taskcluster/taskcluster-client-go.git","clone_url":"https://github.com/taskcluster/taskcluster-client-go.git","svn_url":"https://github.com/taskcluster/taskcluster-client-go","homepage":null,"size":1455,"stargazers_count":2,"watchers_count":2,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":3,"mirror_url":null,"open_issues_count":1,"forks":3,"open_issues":1,"watchers":2,"default_branch":"master"}},"base":{"label":"taskcluster:master","ref":"master","sha":"1776575fe92e2837fc76b294b94037e63a9fe670","user":{"login":"taskcluster","id":6257436,"avatar_url":"https://avatars.githubusercontent.com/u/6257436?v=3","gravatar_id":"","url":"https://api.github.com/users/taskcluster","html_url":"https://github.com/taskcluster","followers_url":"https://api.github.com/users/taskcluster/followers","following_url":"https://api.github.com/users/taskcluster/following{/other_user}","gists_url":"https://api.github.com/users/taskcluster/gists{/gist_id}","starred_url":"https://api.github.com/users/taskcluster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/taskcluster/subscriptions","organizations_url":"https://api.github.com/users/taskcluster/orgs","repos_url":"https://api.github.com/users/taskcluster/repos","events_url":"https://api.github.com/users/taskcluster/events{/privacy}","received_events_url":"https://api.github.com/users/taskcluster/received_events","type":"Organization","site_admin":false},"repo":{"id":29486192,"name":"taskcluster-client-go","full_name":"taskcluster/taskcluster-client-go","owner":{"login":"taskcluster","id":6257436,"avatar_url":"https://avatars.githubusercontent.com/u/6257436?v=3","gravatar_id":"","url":"https://api.github.com/users/taskcluster","html_url":"https://github.com/taskcluster","followers_url":"https://api.github.com/users/taskcluster/followers","following_url":"https://api.github.com/users/taskcluster/following{/other_user}","gists_url":"https://api.github.com/users/taskcluster/gists{/gist_id}","starred_url":"https://api.github.com/users/taskcluster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/taskcluster/subscriptions","organizations_url":"https://api.github.com/users/taskcluster/orgs","repos_url":"https://api.github.com/users/taskcluster/repos","events_url":"https://api.github.com/users/taskcluster/events{/privacy}","received_events_url":"https://api.github.com/users/taskcluster/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/taskcluster/taskcluster-client-go","description":"A go (golang) port of taskcluster-client","fork":false,"url":"https://api.github.com/repos/taskcluster/taskcluster-client-go","forks_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/forks","keys_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/keys{/key_id}","collaborators_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/teams","hooks_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/hooks","issue_events_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/issues/events{/number}","events_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/events","assignees_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/assignees{/user}","branches_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/branches{/branch}","tags_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/tags","blobs_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/git/refs{/sha}","trees_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/git/trees{/sha}","statuses_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/statuses/{sha}","languages_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/languages","stargazers_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/stargazers","contributors_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/contributors","subscribers_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/subscribers","subscription_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/subscription","commits_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/commits{/sha}","git_commits_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/git/commits{/sha}","comments_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/comments{/number}","issue_comment_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/issues/comments{/number}","contents_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/contents/{+path}","compare_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/compare/{base}...{head}","merges_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/merges","archive_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/downloads","issues_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/issues{/number}","pulls_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/pulls{/number}","milestones_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/milestones{/number}","notifications_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/labels{/name}","releases_url":"https://api.github.com/repos/taskcluster/taskcluster-client-go/releases{/id}","created_at":"2015-01-19T18:54:28Z","updated_at":"2015-07-06T02:16:51Z","pushed_at":"2015-07-15T16:34:29Z","git_url":"git://github.com/taskcluster/taskcluster-client-go.git","ssh_url":"git@github.com:taskcluster/taskcluster-client-go.git","clone_url":"https://github.com/taskcluster/taskcluster-client-go.git","svn_url":"https://github.com/taskcluster/taskcluster-client-go","homepage":null,"size":1455,"stargazers_count":2,"watchers_count":2,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":3,"mirror_url":null,"open_issues_count":1,"forks":3,"open_issues":1,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/taskcluster/taskcluster-client-go/pulls/2"},"html":{"href":"https://github.com/taskcluster/taskcluster-client-go/pull/2"},"issue":{"href":"https://api.github.com/repos/taskcluster/taskcluster-client-go/issues/2"},"comments":{"href":"https://api.github.com/repos/taskcluster/taskcluster-client-go/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/taskcluster/taskcluster-client-go/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/taskcluster/taskcluster-client-go/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/taskcluster/taskcluster-client-go/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/taskcluster/taskcluster-client-go/statuses/c78c4c373aba7a0dc4b0b019514aa377a7e1e641"}}}}