{"action":"created","comment":{"url":"https://api.github.com/repos/snapcore/snapcraft/pulls/comments/79743844","id":79743844,"diff_hunk":"@@ -281,3 +282,82 @@ def download(snap_name, channel, download_path, arch):\n         raise RuntimeError(\n             'Failed to download {} at {} (mismatched SHA)'.format(\n                 snap_name, download_path))\n+\n+\n+def _get_snap_data(name, store):\n+    search_results = store.cpi.search_package(name, 'stable', None)\n+    if search_results is None:\n+        raise RuntimeError(\n+            'Snap {name} cannot be found'.format(\n+                name=name))\n+    details_url = search_results['_links']['self']['href']\n+    details = store.cpi.get(details_url).json()\n+    if details.get('result') == 'error':\n+        raise RuntimeError(\n+            'Error obtaining details for snap {}: {}'.format(\n+                name, ', '.join(details['errors'])))\n+    return details\n+\n+\n+def gated(snap_name):\n+    \"\"\"Print list of snaps gated by snap_name.\"\"\"\n+    store = storeapi.StoreClient()\n+    # Get data for the gating snap\n+    snap_data = _get_snap_data(snap_name, store)\n+    snap_id = snap_data['snap_id']\n+    validations = store.get_validations(snap_id)\n+\n+    table_data = []\n+    for v in validations:\n+        table_data.append([v['approved-snap-name'], v['approved-snap-revision']])\n+    tabulated = tabulate(table_data, headers=['Name', 'Approved'],\n+                         tablefmt=\"plain\")\n+    print(tabulated)\n+\n+\n+def validate(snap_name, validations, revoke=False, key=None):\n+    \"\"\"Generate, sign and upload validation assertions.\"\"\"\n+    store = storeapi.StoreClient()\n+\n+    # Get data for the gating snap\n+    snap_data = _get_snap_data(snap_name, store)\n+    release = str(snap_data['release'][0])\n+    snap_id = snap_data['snap_id']\n+    developer_id = snap_data['developer_id']\n+    # Then, for each requested validation, generate assertion\n+    # XXX FIXME: ensure validations are of the form name=number\n+    for validation in validations:\n+        gated_name, rev = validation.split('=', 1)\n+        approved_data = _get_snap_data(gated_name, store)\n+        assertion = {\n+            'type': 'validation',\n+            'authority-id': developer_id,\n+            'series': release,\n+            'snap-id': snap_id,\n+            'approved-snap-id': approved_data['snap_id'],\n+            'approved-snap-revision': rev,\n+            'timestamp': datetime.datetime.utcnow().isoformat() + 'Z',\n+            'valid': \"true\"\n+        }\n+        if revoke:\n+            assertion['valid'] = \"false\"\n+\n+        cmdline = ['snap', 'sign']\n+        if key is not None:","path":"snapcraft/_store.py","position":73,"original_position":73,"commit_id":"7285508b455e1f1d5338a6b76b053560f22b1961","original_commit_id":"7285508b455e1f1d5338a6b76b053560f22b1961","user":{"login":"sergiusens","id":1146853,"avatar_url":"https://avatars.githubusercontent.com/u/1146853?v=3","gravatar_id":"","url":"https://api.github.com/users/sergiusens","html_url":"https://github.com/sergiusens","followers_url":"https://api.github.com/users/sergiusens/followers","following_url":"https://api.github.com/users/sergiusens/following{/other_user}","gists_url":"https://api.github.com/users/sergiusens/gists{/gist_id}","starred_url":"https://api.github.com/users/sergiusens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sergiusens/subscriptions","organizations_url":"https://api.github.com/users/sergiusens/orgs","repos_url":"https://api.github.com/users/sergiusens/repos","events_url":"https://api.github.com/users/sergiusens/events{/privacy}","received_events_url":"https://api.github.com/users/sergiusens/received_events","type":"User","site_admin":false},"body":"`if key:` reads better here, is there a possibility for it to be a zero value?","created_at":"2016-09-21T00:57:31Z","updated_at":"2016-09-21T00:58:32Z","html_url":"https://github.com/snapcore/snapcraft/pull/813#discussion_r79743844","pull_request_url":"https://api.github.com/repos/snapcore/snapcraft/pulls/813","_links":{"self":{"href":"https://api.github.com/repos/snapcore/snapcraft/pulls/comments/79743844"},"html":{"href":"https://github.com/snapcore/snapcraft/pull/813#discussion_r79743844"},"pull_request":{"href":"https://api.github.com/repos/snapcore/snapcraft/pulls/813"}}},"pull_request":{"url":"https://api.github.com/repos/snapcore/snapcraft/pulls/813","id":85871506,"html_url":"https://github.com/snapcore/snapcraft/pull/813","diff_url":"https://github.com/snapcore/snapcraft/pull/813.diff","patch_url":"https://github.com/snapcore/snapcraft/pull/813.patch","issue_url":"https://api.github.com/repos/snapcore/snapcraft/issues/813","number":813,"state":"open","locked":false,"title":"[WIP] \"snapcraft validate\" and \"snapcraft gated\" commands","user":{"login":"ralsina","id":1579,"avatar_url":"https://avatars.githubusercontent.com/u/1579?v=3","gravatar_id":"","url":"https://api.github.com/users/ralsina","html_url":"https://github.com/ralsina","followers_url":"https://api.github.com/users/ralsina/followers","following_url":"https://api.github.com/users/ralsina/following{/other_user}","gists_url":"https://api.github.com/users/ralsina/gists{/gist_id}","starred_url":"https://api.github.com/users/ralsina/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ralsina/subscriptions","organizations_url":"https://api.github.com/users/ralsina/orgs","repos_url":"https://api.github.com/users/ralsina/repos","events_url":"https://api.github.com/users/ralsina/events{/privacy}","received_events_url":"https://api.github.com/users/ralsina/received_events","type":"User","site_admin":false},"body":"Implements snapcraft validate and gated commands, according to discussions and specs.\r\n\r\nWIP because tests are not pushed because they don't work yet, will be there later today.","created_at":"2016-09-19T21:18:44Z","updated_at":"2016-09-21T00:58:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"184712e3066d695488bf5a45441d0cafd6a10766","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/snapcore/snapcraft/pulls/813/commits","review_comments_url":"https://api.github.com/repos/snapcore/snapcraft/pulls/813/comments","review_comment_url":"https://api.github.com/repos/snapcore/snapcraft/pulls/comments{/number}","comments_url":"https://api.github.com/repos/snapcore/snapcraft/issues/813/comments","statuses_url":"https://api.github.com/repos/snapcore/snapcraft/statuses/7285508b455e1f1d5338a6b76b053560f22b1961","head":{"label":"ralsina:master","ref":"master","sha":"7285508b455e1f1d5338a6b76b053560f22b1961","user":{"login":"ralsina","id":1579,"avatar_url":"https://avatars.githubusercontent.com/u/1579?v=3","gravatar_id":"","url":"https://api.github.com/users/ralsina","html_url":"https://github.com/ralsina","followers_url":"https://api.github.com/users/ralsina/followers","following_url":"https://api.github.com/users/ralsina/following{/other_user}","gists_url":"https://api.github.com/users/ralsina/gists{/gist_id}","starred_url":"https://api.github.com/users/ralsina/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ralsina/subscriptions","organizations_url":"https://api.github.com/users/ralsina/orgs","repos_url":"https://api.github.com/users/ralsina/repos","events_url":"https://api.github.com/users/ralsina/events{/privacy}","received_events_url":"https://api.github.com/users/ralsina/received_events","type":"User","site_admin":false},"repo":{"id":66283083,"name":"snapcraft","full_name":"ralsina/snapcraft","owner":{"login":"ralsina","id":1579,"avatar_url":"https://avatars.githubusercontent.com/u/1579?v=3","gravatar_id":"","url":"https://api.github.com/users/ralsina","html_url":"https://github.com/ralsina","followers_url":"https://api.github.com/users/ralsina/followers","following_url":"https://api.github.com/users/ralsina/following{/other_user}","gists_url":"https://api.github.com/users/ralsina/gists{/gist_id}","starred_url":"https://api.github.com/users/ralsina/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ralsina/subscriptions","organizations_url":"https://api.github.com/users/ralsina/orgs","repos_url":"https://api.github.com/users/ralsina/repos","events_url":"https://api.github.com/users/ralsina/events{/privacy}","received_events_url":"https://api.github.com/users/ralsina/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ralsina/snapcraft","description":"Snapcraft is a delightful packaging tool","fork":true,"url":"https://api.github.com/repos/ralsina/snapcraft","forks_url":"https://api.github.com/repos/ralsina/snapcraft/forks","keys_url":"https://api.github.com/repos/ralsina/snapcraft/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ralsina/snapcraft/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ralsina/snapcraft/teams","hooks_url":"https://api.github.com/repos/ralsina/snapcraft/hooks","issue_events_url":"https://api.github.com/repos/ralsina/snapcraft/issues/events{/number}","events_url":"https://api.github.com/repos/ralsina/snapcraft/events","assignees_url":"https://api.github.com/repos/ralsina/snapcraft/assignees{/user}","branches_url":"https://api.github.com/repos/ralsina/snapcraft/branches{/branch}","tags_url":"https://api.github.com/repos/ralsina/snapcraft/tags","blobs_url":"https://api.github.com/repos/ralsina/snapcraft/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ralsina/snapcraft/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ralsina/snapcraft/git/refs{/sha}","trees_url":"https://api.github.com/repos/ralsina/snapcraft/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ralsina/snapcraft/statuses/{sha}","languages_url":"https://api.github.com/repos/ralsina/snapcraft/languages","stargazers_url":"https://api.github.com/repos/ralsina/snapcraft/stargazers","contributors_url":"https://api.github.com/repos/ralsina/snapcraft/contributors","subscribers_url":"https://api.github.com/repos/ralsina/snapcraft/subscribers","subscription_url":"https://api.github.com/repos/ralsina/snapcraft/subscription","commits_url":"https://api.github.com/repos/ralsina/snapcraft/commits{/sha}","git_commits_url":"https://api.github.com/repos/ralsina/snapcraft/git/commits{/sha}","comments_url":"https://api.github.com/repos/ralsina/snapcraft/comments{/number}","issue_comment_url":"https://api.github.com/repos/ralsina/snapcraft/issues/comments{/number}","contents_url":"https://api.github.com/repos/ralsina/snapcraft/contents/{+path}","compare_url":"https://api.github.com/repos/ralsina/snapcraft/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ralsina/snapcraft/merges","archive_url":"https://api.github.com/repos/ralsina/snapcraft/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ralsina/snapcraft/downloads","issues_url":"https://api.github.com/repos/ralsina/snapcraft/issues{/number}","pulls_url":"https://api.github.com/repos/ralsina/snapcraft/pulls{/number}","milestones_url":"https://api.github.com/repos/ralsina/snapcraft/milestones{/number}","notifications_url":"https://api.github.com/repos/ralsina/snapcraft/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ralsina/snapcraft/labels{/name}","releases_url":"https://api.github.com/repos/ralsina/snapcraft/releases{/id}","deployments_url":"https://api.github.com/repos/ralsina/snapcraft/deployments","created_at":"2016-08-22T15:10:48Z","updated_at":"2016-08-22T15:10:49Z","pushed_at":"2016-09-20T22:31:45Z","git_url":"git://github.com/ralsina/snapcraft.git","ssh_url":"git@github.com:ralsina/snapcraft.git","clone_url":"https://github.com/ralsina/snapcraft.git","svn_url":"https://github.com/ralsina/snapcraft","homepage":null,"size":4960,"stargazers_count":0,"watchers_count":0,"language":"Python","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":"snapcore:master","ref":"master","sha":"60b7ef04465e3da922d23cba060a2f2831dc5548","user":{"login":"snapcore","id":19532717,"avatar_url":"https://avatars.githubusercontent.com/u/19532717?v=3","gravatar_id":"","url":"https://api.github.com/users/snapcore","html_url":"https://github.com/snapcore","followers_url":"https://api.github.com/users/snapcore/followers","following_url":"https://api.github.com/users/snapcore/following{/other_user}","gists_url":"https://api.github.com/users/snapcore/gists{/gist_id}","starred_url":"https://api.github.com/users/snapcore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snapcore/subscriptions","organizations_url":"https://api.github.com/users/snapcore/orgs","repos_url":"https://api.github.com/users/snapcore/repos","events_url":"https://api.github.com/users/snapcore/events{/privacy}","received_events_url":"https://api.github.com/users/snapcore/received_events","type":"Organization","site_admin":false},"repo":{"id":45199136,"name":"snapcraft","full_name":"snapcore/snapcraft","owner":{"login":"snapcore","id":19532717,"avatar_url":"https://avatars.githubusercontent.com/u/19532717?v=3","gravatar_id":"","url":"https://api.github.com/users/snapcore","html_url":"https://github.com/snapcore","followers_url":"https://api.github.com/users/snapcore/followers","following_url":"https://api.github.com/users/snapcore/following{/other_user}","gists_url":"https://api.github.com/users/snapcore/gists{/gist_id}","starred_url":"https://api.github.com/users/snapcore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snapcore/subscriptions","organizations_url":"https://api.github.com/users/snapcore/orgs","repos_url":"https://api.github.com/users/snapcore/repos","events_url":"https://api.github.com/users/snapcore/events{/privacy}","received_events_url":"https://api.github.com/users/snapcore/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/snapcore/snapcraft","description":"Snapcraft is a delightful packaging tool","fork":false,"url":"https://api.github.com/repos/snapcore/snapcraft","forks_url":"https://api.github.com/repos/snapcore/snapcraft/forks","keys_url":"https://api.github.com/repos/snapcore/snapcraft/keys{/key_id}","collaborators_url":"https://api.github.com/repos/snapcore/snapcraft/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/snapcore/snapcraft/teams","hooks_url":"https://api.github.com/repos/snapcore/snapcraft/hooks","issue_events_url":"https://api.github.com/repos/snapcore/snapcraft/issues/events{/number}","events_url":"https://api.github.com/repos/snapcore/snapcraft/events","assignees_url":"https://api.github.com/repos/snapcore/snapcraft/assignees{/user}","branches_url":"https://api.github.com/repos/snapcore/snapcraft/branches{/branch}","tags_url":"https://api.github.com/repos/snapcore/snapcraft/tags","blobs_url":"https://api.github.com/repos/snapcore/snapcraft/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/snapcore/snapcraft/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/snapcore/snapcraft/git/refs{/sha}","trees_url":"https://api.github.com/repos/snapcore/snapcraft/git/trees{/sha}","statuses_url":"https://api.github.com/repos/snapcore/snapcraft/statuses/{sha}","languages_url":"https://api.github.com/repos/snapcore/snapcraft/languages","stargazers_url":"https://api.github.com/repos/snapcore/snapcraft/stargazers","contributors_url":"https://api.github.com/repos/snapcore/snapcraft/contributors","subscribers_url":"https://api.github.com/repos/snapcore/snapcraft/subscribers","subscription_url":"https://api.github.com/repos/snapcore/snapcraft/subscription","commits_url":"https://api.github.com/repos/snapcore/snapcraft/commits{/sha}","git_commits_url":"https://api.github.com/repos/snapcore/snapcraft/git/commits{/sha}","comments_url":"https://api.github.com/repos/snapcore/snapcraft/comments{/number}","issue_comment_url":"https://api.github.com/repos/snapcore/snapcraft/issues/comments{/number}","contents_url":"https://api.github.com/repos/snapcore/snapcraft/contents/{+path}","compare_url":"https://api.github.com/repos/snapcore/snapcraft/compare/{base}...{head}","merges_url":"https://api.github.com/repos/snapcore/snapcraft/merges","archive_url":"https://api.github.com/repos/snapcore/snapcraft/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/snapcore/snapcraft/downloads","issues_url":"https://api.github.com/repos/snapcore/snapcraft/issues{/number}","pulls_url":"https://api.github.com/repos/snapcore/snapcraft/pulls{/number}","milestones_url":"https://api.github.com/repos/snapcore/snapcraft/milestones{/number}","notifications_url":"https://api.github.com/repos/snapcore/snapcraft/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/snapcore/snapcraft/labels{/name}","releases_url":"https://api.github.com/repos/snapcore/snapcraft/releases{/id}","deployments_url":"https://api.github.com/repos/snapcore/snapcraft/deployments","created_at":"2015-10-29T17:23:15Z","updated_at":"2016-09-20T20:47:21Z","pushed_at":"2016-09-21T00:46:43Z","git_url":"git://github.com/snapcore/snapcraft.git","ssh_url":"git@github.com:snapcore/snapcraft.git","clone_url":"https://github.com/snapcore/snapcraft.git","svn_url":"https://github.com/snapcore/snapcraft","homepage":null,"size":7492,"stargazers_count":217,"watchers_count":217,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":125,"mirror_url":null,"open_issues_count":16,"forks":125,"open_issues":16,"watchers":217,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/snapcore/snapcraft/pulls/813"},"html":{"href":"https://github.com/snapcore/snapcraft/pull/813"},"issue":{"href":"https://api.github.com/repos/snapcore/snapcraft/issues/813"},"comments":{"href":"https://api.github.com/repos/snapcore/snapcraft/issues/813/comments"},"review_comments":{"href":"https://api.github.com/repos/snapcore/snapcraft/pulls/813/comments"},"review_comment":{"href":"https://api.github.com/repos/snapcore/snapcraft/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/snapcore/snapcraft/pulls/813/commits"},"statuses":{"href":"https://api.github.com/repos/snapcore/snapcraft/statuses/7285508b455e1f1d5338a6b76b053560f22b1961"}}}}
{"actor":{"display_login":"sergiusens"}}