{"action":"created","comment":{"url":"https://api.github.com/repos/docker/notary/pulls/comments/47604177","id":47604177,"diff_hunk":"@@ -176,3 +189,74 @@ func (r Role) IsDelegation() bool {\n \ttargetsBase := fmt.Sprintf(\"%s/\", ValidRoles[CanonicalTargetsRole])\n \treturn strings.HasPrefix(r.Name, targetsBase)\n }\n+\n+// AddKeys merges the ids into the current list of role key ids\n+func (r *Role) AddKeys(ids []string) {\n+\tr.KeyIDs = mergeStrSlices(r.KeyIDs, ids)\n+}\n+\n+// AddPaths merges the paths into the current list of role paths\n+func (r *Role) AddPaths(paths []string) error {\n+\tif len(paths) == 0 {\n+\t\treturn nil\n+\t}\n+\tif len(r.PathHashPrefixes) > 0 {\n+\t\treturn ErrInvalidRole{Role: r.Name, Reason: \"attempted to add paths to role that already has hash prefixes\"}\n+\t}\n+\tr.Paths = mergeStrSlices(r.Paths, paths)\n+\treturn nil\n+}\n+\n+// AddPathHashPrefixes merges the prefixes into the list of role path hash prefixes\n+func (r *Role) AddPathHashPrefixes(prefixes []string) error {\n+\tif len(prefixes) == 0 {\n+\t\treturn nil\n+\t}\n+\tif len(r.Paths) > 0 {\n+\t\treturn ErrInvalidRole{Role: r.Name, Reason: \"attempted to add hash prefixes to role that already has paths\"}\n+\t}\n+\tr.PathHashPrefixes = mergeStrSlices(r.PathHashPrefixes, prefixes)\n+\treturn nil\n+}\n+\n+// RemoveKeys removes the ids from the current list of key ids\n+func (r *Role) RemoveKeys(ids []string) {\n+\tr.KeyIDs = subtractStrSlices(r.KeyIDs, ids)\n+}\n+\n+// RemovePaths removes the paths from the current list of role paths\n+func (r *Role) RemovePaths(paths []string) {","path":"tuf/data/roles.go","position":71,"original_position":71,"commit_id":"79b05d4c0a5a400f6b23edf5c35cb24df1c2fd12","original_commit_id":"79b05d4c0a5a400f6b23edf5c35cb24df1c2fd12","user":{"login":"cyli","id":223200,"avatar_url":"https://avatars.githubusercontent.com/u/223200?v=3","gravatar_id":"","url":"https://api.github.com/users/cyli","html_url":"https://github.com/cyli","followers_url":"https://api.github.com/users/cyli/followers","following_url":"https://api.github.com/users/cyli/following{/other_user}","gists_url":"https://api.github.com/users/cyli/gists{/gist_id}","starred_url":"https://api.github.com/users/cyli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cyli/subscriptions","organizations_url":"https://api.github.com/users/cyli/orgs","repos_url":"https://api.github.com/users/cyli/repos","events_url":"https://api.github.com/users/cyli/events{/privacy}","received_events_url":"https://api.github.com/users/cyli/received_events","type":"User","site_admin":false},"body":"Should this and `RemovePathHashPrefixes` check to see if the opposite is 0?  [According to the spec](https://github.com/theupdateframework/tuf/blob/develop/docs/tuf-spec.txt#L729) one of these must be specified (although I guess `NewRole` allows the creation of a role with both as empty arrays).","created_at":"2015-12-15T07:20:46Z","updated_at":"2015-12-15T07:20:46Z","html_url":"https://github.com/docker/notary/pull/354#discussion_r47604177","pull_request_url":"https://api.github.com/repos/docker/notary/pulls/354","_links":{"self":{"href":"https://api.github.com/repos/docker/notary/pulls/comments/47604177"},"html":{"href":"https://github.com/docker/notary/pull/354#discussion_r47604177"},"pull_request":{"href":"https://api.github.com/repos/docker/notary/pulls/354"}}},"pull_request":{"url":"https://api.github.com/repos/docker/notary/pulls/354","id":53338780,"html_url":"https://github.com/docker/notary/pull/354","diff_url":"https://github.com/docker/notary/pull/354.diff","patch_url":"https://github.com/docker/notary/pull/354.patch","issue_url":"https://api.github.com/repos/docker/notary/issues/354","number":354,"state":"open","locked":false,"title":"Delegation primitives up to changelist level","user":{"login":"endophage","id":1302091,"avatar_url":"https://avatars.githubusercontent.com/u/1302091?v=3","gravatar_id":"","url":"https://api.github.com/users/endophage","html_url":"https://github.com/endophage","followers_url":"https://api.github.com/users/endophage/followers","following_url":"https://api.github.com/users/endophage/following{/other_user}","gists_url":"https://api.github.com/users/endophage/gists{/gist_id}","starred_url":"https://api.github.com/users/endophage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/endophage/subscriptions","organizations_url":"https://api.github.com/users/endophage/orgs","repos_url":"https://api.github.com/users/endophage/repos","events_url":"https://api.github.com/users/endophage/events{/privacy}","received_events_url":"https://api.github.com/users/endophage/received_events","type":"User","site_admin":false},"body":"I debated on whether `UpdateDelegations` should create the delegations file in the case it doesn't exist, but that's not necessarily possible in the general TUF case due to what keys the parent owner wants present on the delegation. Creation of this file will happen at a higher level (i.e. in NotaryRepository). When adding that functionality, we will likely want to update `repo.InitTargets` to take a role name.\r\n\r\nSigned-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)","created_at":"2015-12-11T00:34:22Z","updated_at":"2015-12-15T07:20:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"549a22389a3054e59ecbea0c97cb204d3a1e3b61","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/docker/notary/pulls/354/commits","review_comments_url":"https://api.github.com/repos/docker/notary/pulls/354/comments","review_comment_url":"https://api.github.com/repos/docker/notary/pulls/comments{/number}","comments_url":"https://api.github.com/repos/docker/notary/issues/354/comments","statuses_url":"https://api.github.com/repos/docker/notary/statuses/79b05d4c0a5a400f6b23edf5c35cb24df1c2fd12","head":{"label":"endophage:delegations","ref":"delegations","sha":"79b05d4c0a5a400f6b23edf5c35cb24df1c2fd12","user":{"login":"endophage","id":1302091,"avatar_url":"https://avatars.githubusercontent.com/u/1302091?v=3","gravatar_id":"","url":"https://api.github.com/users/endophage","html_url":"https://github.com/endophage","followers_url":"https://api.github.com/users/endophage/followers","following_url":"https://api.github.com/users/endophage/following{/other_user}","gists_url":"https://api.github.com/users/endophage/gists{/gist_id}","starred_url":"https://api.github.com/users/endophage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/endophage/subscriptions","organizations_url":"https://api.github.com/users/endophage/orgs","repos_url":"https://api.github.com/users/endophage/repos","events_url":"https://api.github.com/users/endophage/events{/privacy}","received_events_url":"https://api.github.com/users/endophage/received_events","type":"User","site_admin":false},"repo":{"id":37937558,"name":"notary","full_name":"endophage/notary","owner":{"login":"endophage","id":1302091,"avatar_url":"https://avatars.githubusercontent.com/u/1302091?v=3","gravatar_id":"","url":"https://api.github.com/users/endophage","html_url":"https://github.com/endophage","followers_url":"https://api.github.com/users/endophage/followers","following_url":"https://api.github.com/users/endophage/following{/other_user}","gists_url":"https://api.github.com/users/endophage/gists{/gist_id}","starred_url":"https://api.github.com/users/endophage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/endophage/subscriptions","organizations_url":"https://api.github.com/users/endophage/orgs","repos_url":"https://api.github.com/users/endophage/repos","events_url":"https://api.github.com/users/endophage/events{/privacy}","received_events_url":"https://api.github.com/users/endophage/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/endophage/notary","description":"","fork":true,"url":"https://api.github.com/repos/endophage/notary","forks_url":"https://api.github.com/repos/endophage/notary/forks","keys_url":"https://api.github.com/repos/endophage/notary/keys{/key_id}","collaborators_url":"https://api.github.com/repos/endophage/notary/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/endophage/notary/teams","hooks_url":"https://api.github.com/repos/endophage/notary/hooks","issue_events_url":"https://api.github.com/repos/endophage/notary/issues/events{/number}","events_url":"https://api.github.com/repos/endophage/notary/events","assignees_url":"https://api.github.com/repos/endophage/notary/assignees{/user}","branches_url":"https://api.github.com/repos/endophage/notary/branches{/branch}","tags_url":"https://api.github.com/repos/endophage/notary/tags","blobs_url":"https://api.github.com/repos/endophage/notary/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/endophage/notary/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/endophage/notary/git/refs{/sha}","trees_url":"https://api.github.com/repos/endophage/notary/git/trees{/sha}","statuses_url":"https://api.github.com/repos/endophage/notary/statuses/{sha}","languages_url":"https://api.github.com/repos/endophage/notary/languages","stargazers_url":"https://api.github.com/repos/endophage/notary/stargazers","contributors_url":"https://api.github.com/repos/endophage/notary/contributors","subscribers_url":"https://api.github.com/repos/endophage/notary/subscribers","subscription_url":"https://api.github.com/repos/endophage/notary/subscription","commits_url":"https://api.github.com/repos/endophage/notary/commits{/sha}","git_commits_url":"https://api.github.com/repos/endophage/notary/git/commits{/sha}","comments_url":"https://api.github.com/repos/endophage/notary/comments{/number}","issue_comment_url":"https://api.github.com/repos/endophage/notary/issues/comments{/number}","contents_url":"https://api.github.com/repos/endophage/notary/contents/{+path}","compare_url":"https://api.github.com/repos/endophage/notary/compare/{base}...{head}","merges_url":"https://api.github.com/repos/endophage/notary/merges","archive_url":"https://api.github.com/repos/endophage/notary/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/endophage/notary/downloads","issues_url":"https://api.github.com/repos/endophage/notary/issues{/number}","pulls_url":"https://api.github.com/repos/endophage/notary/pulls{/number}","milestones_url":"https://api.github.com/repos/endophage/notary/milestones{/number}","notifications_url":"https://api.github.com/repos/endophage/notary/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/endophage/notary/labels{/name}","releases_url":"https://api.github.com/repos/endophage/notary/releases{/id}","created_at":"2015-06-23T18:35:21Z","updated_at":"2015-06-23T18:35:27Z","pushed_at":"2015-12-15T01:24:01Z","git_url":"git://github.com/endophage/notary.git","ssh_url":"git@github.com:endophage/notary.git","clone_url":"https://github.com/endophage/notary.git","svn_url":"https://github.com/endophage/notary","homepage":"","size":21826,"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":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"docker:master","ref":"master","sha":"aa81b91ab40ef53b1b2e66ef14f86e4ee25d5781","user":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"repo":{"id":37743436,"name":"notary","full_name":"docker/notary","owner":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/docker/notary","description":"","fork":false,"url":"https://api.github.com/repos/docker/notary","forks_url":"https://api.github.com/repos/docker/notary/forks","keys_url":"https://api.github.com/repos/docker/notary/keys{/key_id}","collaborators_url":"https://api.github.com/repos/docker/notary/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/docker/notary/teams","hooks_url":"https://api.github.com/repos/docker/notary/hooks","issue_events_url":"https://api.github.com/repos/docker/notary/issues/events{/number}","events_url":"https://api.github.com/repos/docker/notary/events","assignees_url":"https://api.github.com/repos/docker/notary/assignees{/user}","branches_url":"https://api.github.com/repos/docker/notary/branches{/branch}","tags_url":"https://api.github.com/repos/docker/notary/tags","blobs_url":"https://api.github.com/repos/docker/notary/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/docker/notary/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/docker/notary/git/refs{/sha}","trees_url":"https://api.github.com/repos/docker/notary/git/trees{/sha}","statuses_url":"https://api.github.com/repos/docker/notary/statuses/{sha}","languages_url":"https://api.github.com/repos/docker/notary/languages","stargazers_url":"https://api.github.com/repos/docker/notary/stargazers","contributors_url":"https://api.github.com/repos/docker/notary/contributors","subscribers_url":"https://api.github.com/repos/docker/notary/subscribers","subscription_url":"https://api.github.com/repos/docker/notary/subscription","commits_url":"https://api.github.com/repos/docker/notary/commits{/sha}","git_commits_url":"https://api.github.com/repos/docker/notary/git/commits{/sha}","comments_url":"https://api.github.com/repos/docker/notary/comments{/number}","issue_comment_url":"https://api.github.com/repos/docker/notary/issues/comments{/number}","contents_url":"https://api.github.com/repos/docker/notary/contents/{+path}","compare_url":"https://api.github.com/repos/docker/notary/compare/{base}...{head}","merges_url":"https://api.github.com/repos/docker/notary/merges","archive_url":"https://api.github.com/repos/docker/notary/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/docker/notary/downloads","issues_url":"https://api.github.com/repos/docker/notary/issues{/number}","pulls_url":"https://api.github.com/repos/docker/notary/pulls{/number}","milestones_url":"https://api.github.com/repos/docker/notary/milestones{/number}","notifications_url":"https://api.github.com/repos/docker/notary/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/docker/notary/labels{/name}","releases_url":"https://api.github.com/repos/docker/notary/releases{/id}","created_at":"2015-06-19T20:07:53Z","updated_at":"2015-12-14T20:42:08Z","pushed_at":"2015-12-15T01:44:34Z","git_url":"git://github.com/docker/notary.git","ssh_url":"git@github.com:docker/notary.git","clone_url":"https://github.com/docker/notary.git","svn_url":"https://github.com/docker/notary","homepage":null,"size":22013,"stargazers_count":449,"watchers_count":449,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":62,"mirror_url":null,"open_issues_count":47,"forks":62,"open_issues":47,"watchers":449,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/docker/notary/pulls/354"},"html":{"href":"https://github.com/docker/notary/pull/354"},"issue":{"href":"https://api.github.com/repos/docker/notary/issues/354"},"comments":{"href":"https://api.github.com/repos/docker/notary/issues/354/comments"},"review_comments":{"href":"https://api.github.com/repos/docker/notary/pulls/354/comments"},"review_comment":{"href":"https://api.github.com/repos/docker/notary/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/docker/notary/pulls/354/commits"},"statuses":{"href":"https://api.github.com/repos/docker/notary/statuses/79b05d4c0a5a400f6b23edf5c35cb24df1c2fd12"}}}}