{"action":"created","comment":{"url":"https://api.github.com/repos/docker/notary/pulls/comments/48072235","id":48072235,"diff_hunk":"@@ -185,10 +211,19 @@ func (tr *Repo) UpdateDelegations(role *data.Role, keys []data.PublicKey) error\n \t\treturn data.ErrInvalidRole{Role: role.Name, Reason: \"not a valid delegated role\"}\n \t}\n \tparent := filepath.Dir(role.Name)\n-\tp, ok := tr.Targets[parent]\n-\tif !ok {\n+\n+\t// check the parent role\n+\tif parentRole := tr.keysDB.GetRole(parent); parentRole == nil {\n \t\treturn data.ErrInvalidRole{Role: role.Name, Reason: \"parent role not found\"}\n \t}\n+\n+\t// check the parent role's metadata\n+\tp, ok := tr.Targets[parent]\n+\tif !ok { // the parent targetfile may not exist yet - if not, then create it\n+\t\tp = data.NewTargets()","path":"tuf/tuf.go","position":65,"original_position":65,"commit_id":"d6805bf47577177aad7e22787c87b90dd5a92dcf","original_commit_id":"d6805bf47577177aad7e22787c87b90dd5a92dcf","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":"Do we want to check if we have signing keys before creating? Also:\r\n```\r\ntr.InitTargets(parent)\r\n```","created_at":"2015-12-18T21:31:18Z","updated_at":"2015-12-18T21:31:18Z","html_url":"https://github.com/docker/notary/pull/378#discussion_r48072235","pull_request_url":"https://api.github.com/repos/docker/notary/pulls/378","_links":{"self":{"href":"https://api.github.com/repos/docker/notary/pulls/comments/48072235"},"html":{"href":"https://github.com/docker/notary/pull/378#discussion_r48072235"},"pull_request":{"href":"https://api.github.com/repos/docker/notary/pulls/378"}}},"pull_request":{"url":"https://api.github.com/repos/docker/notary/pulls/378","id":54083584,"html_url":"https://github.com/docker/notary/pull/378","diff_url":"https://github.com/docker/notary/pull/378.diff","patch_url":"https://github.com/docker/notary/pull/378.patch","issue_url":"https://api.github.com/repos/docker/notary/issues/378","number":378,"state":"open","locked":false,"title":"Publishing delegation changes, and targets to delegations","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":"This makes the following logic changes:\r\n\r\n- publish now iterates over all targets marked dirty and publishes only those that are dirty (this means canonical targets will not always get pushed)\r\n- if changes are applied to a role that doesn't exist, publish will fallback on its parent role and so forth until it finds a role that exists.  the changes will be applied to that role.\r\n- delegations metadata is not always created when a delegation is created\r\n- role checks now check keyDB rather than the metadata, because the metadata may not exist\r\n- if the role exists, but metadata doesn't, it is now created before being modified (as opposed to just failing before)","created_at":"2015-12-18T09:57:01Z","updated_at":"2015-12-18T21:31:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c18b828227582d265406f8d004f4a34695e71d4a","assignee":null,"milestone":{"url":"https://api.github.com/repos/docker/notary/milestones/4","html_url":"https://github.com/docker/notary/milestones/delegations_v1","labels_url":"https://api.github.com/repos/docker/notary/milestones/4/labels","id":1451085,"number":4,"title":"delegations_v1","description":"1.  Server needs to provide a snapshot key and sign snapshots\r\n1.  Client needs to be able to request a snapshot key from the server and not sign snapshots\r\n1.  CLI needs a way to delegate snapshot signing to the server, as well as reclaim that responsibility","creator":{"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},"open_issues":2,"closed_issues":12,"state":"open","created_at":"2015-12-09T01:27:13Z","updated_at":"2015-12-18T20:35:17Z","due_on":"2015-12-18T08:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/docker/notary/pulls/378/commits","review_comments_url":"https://api.github.com/repos/docker/notary/pulls/378/comments","review_comment_url":"https://api.github.com/repos/docker/notary/pulls/comments{/number}","comments_url":"https://api.github.com/repos/docker/notary/issues/378/comments","statuses_url":"https://api.github.com/repos/docker/notary/statuses/d6805bf47577177aad7e22787c87b90dd5a92dcf","head":{"label":"cyli:publish-delegations","ref":"publish-delegations","sha":"d6805bf47577177aad7e22787c87b90dd5a92dcf","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},"repo":{"id":43714589,"name":"notary","full_name":"cyli/notary","owner":{"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},"private":false,"html_url":"https://github.com/cyli/notary","description":"","fork":true,"url":"https://api.github.com/repos/cyli/notary","forks_url":"https://api.github.com/repos/cyli/notary/forks","keys_url":"https://api.github.com/repos/cyli/notary/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cyli/notary/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cyli/notary/teams","hooks_url":"https://api.github.com/repos/cyli/notary/hooks","issue_events_url":"https://api.github.com/repos/cyli/notary/issues/events{/number}","events_url":"https://api.github.com/repos/cyli/notary/events","assignees_url":"https://api.github.com/repos/cyli/notary/assignees{/user}","branches_url":"https://api.github.com/repos/cyli/notary/branches{/branch}","tags_url":"https://api.github.com/repos/cyli/notary/tags","blobs_url":"https://api.github.com/repos/cyli/notary/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cyli/notary/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cyli/notary/git/refs{/sha}","trees_url":"https://api.github.com/repos/cyli/notary/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cyli/notary/statuses/{sha}","languages_url":"https://api.github.com/repos/cyli/notary/languages","stargazers_url":"https://api.github.com/repos/cyli/notary/stargazers","contributors_url":"https://api.github.com/repos/cyli/notary/contributors","subscribers_url":"https://api.github.com/repos/cyli/notary/subscribers","subscription_url":"https://api.github.com/repos/cyli/notary/subscription","commits_url":"https://api.github.com/repos/cyli/notary/commits{/sha}","git_commits_url":"https://api.github.com/repos/cyli/notary/git/commits{/sha}","comments_url":"https://api.github.com/repos/cyli/notary/comments{/number}","issue_comment_url":"https://api.github.com/repos/cyli/notary/issues/comments{/number}","contents_url":"https://api.github.com/repos/cyli/notary/contents/{+path}","compare_url":"https://api.github.com/repos/cyli/notary/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cyli/notary/merges","archive_url":"https://api.github.com/repos/cyli/notary/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cyli/notary/downloads","issues_url":"https://api.github.com/repos/cyli/notary/issues{/number}","pulls_url":"https://api.github.com/repos/cyli/notary/pulls{/number}","milestones_url":"https://api.github.com/repos/cyli/notary/milestones{/number}","notifications_url":"https://api.github.com/repos/cyli/notary/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cyli/notary/labels{/name}","releases_url":"https://api.github.com/repos/cyli/notary/releases{/id}","created_at":"2015-10-05T21:22:52Z","updated_at":"2015-10-05T21:22:54Z","pushed_at":"2015-12-18T20:38:27Z","git_url":"git://github.com/cyli/notary.git","ssh_url":"git@github.com:cyli/notary.git","clone_url":"https://github.com/cyli/notary.git","svn_url":"https://github.com/cyli/notary","homepage":null,"size":22072,"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":"547a17c96b13d6b022c53f75a9719a43cfb5d605","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":"Notary is a Docker project that allows anyone to have trust over arbitrary collections of data","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-18T14:29:05Z","pushed_at":"2015-12-18T20:38:28Z","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":"https://docker.com","size":22262,"stargazers_count":452,"watchers_count":452,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":64,"mirror_url":null,"open_issues_count":46,"forks":64,"open_issues":46,"watchers":452,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/docker/notary/pulls/378"},"html":{"href":"https://github.com/docker/notary/pull/378"},"issue":{"href":"https://api.github.com/repos/docker/notary/issues/378"},"comments":{"href":"https://api.github.com/repos/docker/notary/issues/378/comments"},"review_comments":{"href":"https://api.github.com/repos/docker/notary/pulls/378/comments"},"review_comment":{"href":"https://api.github.com/repos/docker/notary/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/docker/notary/pulls/378/commits"},"statuses":{"href":"https://api.github.com/repos/docker/notary/statuses/d6805bf47577177aad7e22787c87b90dd5a92dcf"}}}}