{"action":"created","comment":{"url":"https://api.github.com/repos/ubuntu-core/snappy/pulls/comments/46020841","id":46020841,"diff_hunk":"@@ -0,0 +1,254 @@\n+// -*- Mode: Go; indent-tabs-mode: t -*-\n+\n+/*\n+ * Copyright (C) 2014-2015 Canonical Ltd\n+ *\n+ * This program is free software: you can redistribute it and/or modify\n+ * it under the terms of the GNU General Public License version 3 as\n+ * published by the Free Software Foundation.\n+ *\n+ * This program is distributed in the hope that it will be useful,\n+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+ * GNU General Public License for more details.\n+ *\n+ * You should have received a copy of the GNU General Public License\n+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.\n+ *\n+ */\n+\n+package classic\n+\n+import (\n+\t\"bufio\"\n+\t\"fmt\"\n+\t\"io\"\n+\t\"io/ioutil\"\n+\t\"net/http\"\n+\t\"os\"\n+\t\"os/exec\"\n+\t\"path/filepath\"\n+\t\"strings\"\n+\n+\t\"github.com/ubuntu-core/snappy/arch\"\n+\t\"github.com/ubuntu-core/snappy/dirs\"\n+\n+\t\"github.com/ubuntu-core/snappy/helpers\"\n+\t\"github.com/ubuntu-core/snappy/progress\"\n+\t\"github.com/ubuntu-core/snappy/release\"\n+)\n+\n+var (\n+\tlxdBaseURL   = \"https://images.linuxcontainers.org\"\n+\tlxdIndexPath = \"/meta/1.0/index-system\"\n+)\n+\n+func findDownloadPathFromLxdIndex(r io.Reader) (string, error) {\n+\tarch := arch.UbuntuArchitecture()\n+\tlsb, err := release.ReadLsb()\n+\tif err != nil {\n+\t\treturn \"\", err\n+\t}\n+\trelease := lsb.Codename\n+\n+\tneedle := fmt.Sprintf(\"ubuntu;%s;%s;default\", release, arch)\n+\tscanner := bufio.NewScanner(r)\n+\tfor scanner.Scan() {\n+\t\tif strings.HasPrefix(scanner.Text(), needle) {\n+\t\t\tl := strings.Split(scanner.Text(), \";\")\n+\t\t\tif len(l) < 6 {\n+\t\t\t\treturn \"\", fmt.Errorf(\"can not find download path in %s\", scanner.Text())\n+\t\t\t}\n+\t\t\treturn l[5], nil\n+\t\t}\n+\t}\n+\n+\tif err := scanner.Err(); err != nil {\n+\t\treturn \"\", err\n+\t}\n+\n+\treturn \"\", fmt.Errorf(\"needle %s not found\", needle)\n+}\n+\n+func findDownloadURL() (string, error) {\n+\tresp, err := http.Get(lxdBaseURL + lxdIndexPath)\n+\tif err != nil {\n+\t\treturn \"\", fmt.Errorf(\"failed to downlaod lxdIndexUrl: %s\", err)\n+\t}\n+\tdefer resp.Body.Close()\n+\n+\tdlPath, err := findDownloadPathFromLxdIndex(resp.Body)\n+\tif err != nil {\n+\t\treturn \"\", err\n+\t}\n+\turl := fmt.Sprintf(\"%s%s%s\", lxdBaseURL, dlPath, \"rootfs.tar.xz\")","path":"classic/create.go","position":84,"original_position":84,"commit_id":"24fdea01cf94636f20b9fe1389d66bab4e558028","original_commit_id":"24fdea01cf94636f20b9fe1389d66bab4e558028","user":{"login":"mvo5","id":914418,"avatar_url":"https://avatars.githubusercontent.com/u/914418?v=3","gravatar_id":"","url":"https://api.github.com/users/mvo5","html_url":"https://github.com/mvo5","followers_url":"https://api.github.com/users/mvo5/followers","following_url":"https://api.github.com/users/mvo5/following{/other_user}","gists_url":"https://api.github.com/users/mvo5/gists{/gist_id}","starred_url":"https://api.github.com/users/mvo5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mvo5/subscriptions","organizations_url":"https://api.github.com/users/mvo5/orgs","repos_url":"https://api.github.com/users/mvo5/repos","events_url":"https://api.github.com/users/mvo5/events{/privacy}","received_events_url":"https://api.github.com/users/mvo5/received_events","type":"User","site_admin":false},"body":"Indeed, thank you. Fixed.","created_at":"2015-11-27T06:59:18Z","updated_at":"2015-11-27T06:59:18Z","html_url":"https://github.com/ubuntu-core/snappy/pull/178#discussion_r46020841","pull_request_url":"https://api.github.com/repos/ubuntu-core/snappy/pulls/178","_links":{"self":{"href":"https://api.github.com/repos/ubuntu-core/snappy/pulls/comments/46020841"},"html":{"href":"https://github.com/ubuntu-core/snappy/pull/178#discussion_r46020841"},"pull_request":{"href":"https://api.github.com/repos/ubuntu-core/snappy/pulls/178"}}},"pull_request":{"url":"https://api.github.com/repos/ubuntu-core/snappy/pulls/178","id":51924761,"html_url":"https://github.com/ubuntu-core/snappy/pull/178","diff_url":"https://github.com/ubuntu-core/snappy/pull/178.diff","patch_url":"https://github.com/ubuntu-core/snappy/pull/178.patch","issue_url":"https://api.github.com/repos/ubuntu-core/snappy/issues/178","number":178,"state":"open","locked":false,"title":"Feature/classic dimension","user":{"login":"mvo5","id":914418,"avatar_url":"https://avatars.githubusercontent.com/u/914418?v=3","gravatar_id":"","url":"https://api.github.com/users/mvo5","html_url":"https://github.com/mvo5","followers_url":"https://api.github.com/users/mvo5/followers","following_url":"https://api.github.com/users/mvo5/following{/other_user}","gists_url":"https://api.github.com/users/mvo5/gists{/gist_id}","starred_url":"https://api.github.com/users/mvo5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mvo5/subscriptions","organizations_url":"https://api.github.com/users/mvo5/orgs","repos_url":"https://api.github.com/users/mvo5/repos","events_url":"https://api.github.com/users/mvo5/events{/privacy}","received_events_url":"https://api.github.com/users/mvo5/received_events","type":"User","site_admin":false},"body":"This is the first part of the classic dimension work.\r\n\r\nThe branch adds a new classic package that has:\r\n- classic.Create()\r\n- classic.RunShell()\r\n- classic.Destroy()\r\n\r\nUntil the rest of the work is done the classic mode is available via the following CLI:\r\n - sudo snappy enable-classic\r\n - sudo snappy shell classic\r\n - sudo snappy destroy-classic\r\n\r\nIn a followup branch I plan to make classic appear like a regular snap, i.e. it will be listed\r\nvia snappy list and \"sudo snappy install classic\" will install it, \"sudo snappy purge classic\" will remove it.\r\n\r\nI'm not sure how to best test RunShell() as its really not doing much and it would probably just be \"mockBindMount\" \"mockCallSystemd\" and checking if those got called. Happy to do that if you think there is value in it.","created_at":"2015-11-26T15:29:27Z","updated_at":"2015-11-27T06:59:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e74034daa83111bffd06959daade7db8f44d5439","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ubuntu-core/snappy/pulls/178/commits","review_comments_url":"https://api.github.com/repos/ubuntu-core/snappy/pulls/178/comments","review_comment_url":"https://api.github.com/repos/ubuntu-core/snappy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ubuntu-core/snappy/issues/178/comments","statuses_url":"https://api.github.com/repos/ubuntu-core/snappy/statuses/24fdea01cf94636f20b9fe1389d66bab4e558028","head":{"label":"mvo5:feature/classic-dimension","ref":"feature/classic-dimension","sha":"24fdea01cf94636f20b9fe1389d66bab4e558028","user":{"login":"mvo5","id":914418,"avatar_url":"https://avatars.githubusercontent.com/u/914418?v=3","gravatar_id":"","url":"https://api.github.com/users/mvo5","html_url":"https://github.com/mvo5","followers_url":"https://api.github.com/users/mvo5/followers","following_url":"https://api.github.com/users/mvo5/following{/other_user}","gists_url":"https://api.github.com/users/mvo5/gists{/gist_id}","starred_url":"https://api.github.com/users/mvo5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mvo5/subscriptions","organizations_url":"https://api.github.com/users/mvo5/orgs","repos_url":"https://api.github.com/users/mvo5/repos","events_url":"https://api.github.com/users/mvo5/events{/privacy}","received_events_url":"https://api.github.com/users/mvo5/received_events","type":"User","site_admin":false},"repo":{"id":45067233,"name":"snappy","full_name":"mvo5/snappy","owner":{"login":"mvo5","id":914418,"avatar_url":"https://avatars.githubusercontent.com/u/914418?v=3","gravatar_id":"","url":"https://api.github.com/users/mvo5","html_url":"https://github.com/mvo5","followers_url":"https://api.github.com/users/mvo5/followers","following_url":"https://api.github.com/users/mvo5/following{/other_user}","gists_url":"https://api.github.com/users/mvo5/gists{/gist_id}","starred_url":"https://api.github.com/users/mvo5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mvo5/subscriptions","organizations_url":"https://api.github.com/users/mvo5/orgs","repos_url":"https://api.github.com/users/mvo5/repos","events_url":"https://api.github.com/users/mvo5/events{/privacy}","received_events_url":"https://api.github.com/users/mvo5/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mvo5/snappy","description":"Snappy is the software at the heart of Ubuntu Core.","fork":true,"url":"https://api.github.com/repos/mvo5/snappy","forks_url":"https://api.github.com/repos/mvo5/snappy/forks","keys_url":"https://api.github.com/repos/mvo5/snappy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mvo5/snappy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mvo5/snappy/teams","hooks_url":"https://api.github.com/repos/mvo5/snappy/hooks","issue_events_url":"https://api.github.com/repos/mvo5/snappy/issues/events{/number}","events_url":"https://api.github.com/repos/mvo5/snappy/events","assignees_url":"https://api.github.com/repos/mvo5/snappy/assignees{/user}","branches_url":"https://api.github.com/repos/mvo5/snappy/branches{/branch}","tags_url":"https://api.github.com/repos/mvo5/snappy/tags","blobs_url":"https://api.github.com/repos/mvo5/snappy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mvo5/snappy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mvo5/snappy/git/refs{/sha}","trees_url":"https://api.github.com/repos/mvo5/snappy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mvo5/snappy/statuses/{sha}","languages_url":"https://api.github.com/repos/mvo5/snappy/languages","stargazers_url":"https://api.github.com/repos/mvo5/snappy/stargazers","contributors_url":"https://api.github.com/repos/mvo5/snappy/contributors","subscribers_url":"https://api.github.com/repos/mvo5/snappy/subscribers","subscription_url":"https://api.github.com/repos/mvo5/snappy/subscription","commits_url":"https://api.github.com/repos/mvo5/snappy/commits{/sha}","git_commits_url":"https://api.github.com/repos/mvo5/snappy/git/commits{/sha}","comments_url":"https://api.github.com/repos/mvo5/snappy/comments{/number}","issue_comment_url":"https://api.github.com/repos/mvo5/snappy/issues/comments{/number}","contents_url":"https://api.github.com/repos/mvo5/snappy/contents/{+path}","compare_url":"https://api.github.com/repos/mvo5/snappy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mvo5/snappy/merges","archive_url":"https://api.github.com/repos/mvo5/snappy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mvo5/snappy/downloads","issues_url":"https://api.github.com/repos/mvo5/snappy/issues{/number}","pulls_url":"https://api.github.com/repos/mvo5/snappy/pulls{/number}","milestones_url":"https://api.github.com/repos/mvo5/snappy/milestones{/number}","notifications_url":"https://api.github.com/repos/mvo5/snappy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mvo5/snappy/labels{/name}","releases_url":"https://api.github.com/repos/mvo5/snappy/releases{/id}","created_at":"2015-10-27T20:12:18Z","updated_at":"2015-10-27T20:12:21Z","pushed_at":"2015-11-26T18:57:43Z","git_url":"git://github.com/mvo5/snappy.git","ssh_url":"git@github.com:mvo5/snappy.git","clone_url":"https://github.com/mvo5/snappy.git","svn_url":"https://github.com/mvo5/snappy","homepage":null,"size":24122,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"ubuntu-core:master","ref":"master","sha":"dbd6e1e8a85357c2793e08cc431d906c883908a3","user":{"login":"ubuntu-core","id":15022473,"avatar_url":"https://avatars.githubusercontent.com/u/15022473?v=3","gravatar_id":"","url":"https://api.github.com/users/ubuntu-core","html_url":"https://github.com/ubuntu-core","followers_url":"https://api.github.com/users/ubuntu-core/followers","following_url":"https://api.github.com/users/ubuntu-core/following{/other_user}","gists_url":"https://api.github.com/users/ubuntu-core/gists{/gist_id}","starred_url":"https://api.github.com/users/ubuntu-core/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ubuntu-core/subscriptions","organizations_url":"https://api.github.com/users/ubuntu-core/orgs","repos_url":"https://api.github.com/users/ubuntu-core/repos","events_url":"https://api.github.com/users/ubuntu-core/events{/privacy}","received_events_url":"https://api.github.com/users/ubuntu-core/received_events","type":"Organization","site_admin":false},"repo":{"id":44672744,"name":"snappy","full_name":"ubuntu-core/snappy","owner":{"login":"ubuntu-core","id":15022473,"avatar_url":"https://avatars.githubusercontent.com/u/15022473?v=3","gravatar_id":"","url":"https://api.github.com/users/ubuntu-core","html_url":"https://github.com/ubuntu-core","followers_url":"https://api.github.com/users/ubuntu-core/followers","following_url":"https://api.github.com/users/ubuntu-core/following{/other_user}","gists_url":"https://api.github.com/users/ubuntu-core/gists{/gist_id}","starred_url":"https://api.github.com/users/ubuntu-core/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ubuntu-core/subscriptions","organizations_url":"https://api.github.com/users/ubuntu-core/orgs","repos_url":"https://api.github.com/users/ubuntu-core/repos","events_url":"https://api.github.com/users/ubuntu-core/events{/privacy}","received_events_url":"https://api.github.com/users/ubuntu-core/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ubuntu-core/snappy","description":"Snappy is the software at the heart of Ubuntu Core.","fork":false,"url":"https://api.github.com/repos/ubuntu-core/snappy","forks_url":"https://api.github.com/repos/ubuntu-core/snappy/forks","keys_url":"https://api.github.com/repos/ubuntu-core/snappy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ubuntu-core/snappy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ubuntu-core/snappy/teams","hooks_url":"https://api.github.com/repos/ubuntu-core/snappy/hooks","issue_events_url":"https://api.github.com/repos/ubuntu-core/snappy/issues/events{/number}","events_url":"https://api.github.com/repos/ubuntu-core/snappy/events","assignees_url":"https://api.github.com/repos/ubuntu-core/snappy/assignees{/user}","branches_url":"https://api.github.com/repos/ubuntu-core/snappy/branches{/branch}","tags_url":"https://api.github.com/repos/ubuntu-core/snappy/tags","blobs_url":"https://api.github.com/repos/ubuntu-core/snappy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ubuntu-core/snappy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ubuntu-core/snappy/git/refs{/sha}","trees_url":"https://api.github.com/repos/ubuntu-core/snappy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ubuntu-core/snappy/statuses/{sha}","languages_url":"https://api.github.com/repos/ubuntu-core/snappy/languages","stargazers_url":"https://api.github.com/repos/ubuntu-core/snappy/stargazers","contributors_url":"https://api.github.com/repos/ubuntu-core/snappy/contributors","subscribers_url":"https://api.github.com/repos/ubuntu-core/snappy/subscribers","subscription_url":"https://api.github.com/repos/ubuntu-core/snappy/subscription","commits_url":"https://api.github.com/repos/ubuntu-core/snappy/commits{/sha}","git_commits_url":"https://api.github.com/repos/ubuntu-core/snappy/git/commits{/sha}","comments_url":"https://api.github.com/repos/ubuntu-core/snappy/comments{/number}","issue_comment_url":"https://api.github.com/repos/ubuntu-core/snappy/issues/comments{/number}","contents_url":"https://api.github.com/repos/ubuntu-core/snappy/contents/{+path}","compare_url":"https://api.github.com/repos/ubuntu-core/snappy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ubuntu-core/snappy/merges","archive_url":"https://api.github.com/repos/ubuntu-core/snappy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ubuntu-core/snappy/downloads","issues_url":"https://api.github.com/repos/ubuntu-core/snappy/issues{/number}","pulls_url":"https://api.github.com/repos/ubuntu-core/snappy/pulls{/number}","milestones_url":"https://api.github.com/repos/ubuntu-core/snappy/milestones{/number}","notifications_url":"https://api.github.com/repos/ubuntu-core/snappy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ubuntu-core/snappy/labels{/name}","releases_url":"https://api.github.com/repos/ubuntu-core/snappy/releases{/id}","created_at":"2015-10-21T11:51:46Z","updated_at":"2015-11-25T15:23:13Z","pushed_at":"2015-11-26T20:54:48Z","git_url":"git://github.com/ubuntu-core/snappy.git","ssh_url":"git@github.com:ubuntu-core/snappy.git","clone_url":"https://github.com/ubuntu-core/snappy.git","svn_url":"https://github.com/ubuntu-core/snappy","homepage":null,"size":24109,"stargazers_count":37,"watchers_count":37,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":16,"mirror_url":null,"open_issues_count":16,"forks":16,"open_issues":16,"watchers":37,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ubuntu-core/snappy/pulls/178"},"html":{"href":"https://github.com/ubuntu-core/snappy/pull/178"},"issue":{"href":"https://api.github.com/repos/ubuntu-core/snappy/issues/178"},"comments":{"href":"https://api.github.com/repos/ubuntu-core/snappy/issues/178/comments"},"review_comments":{"href":"https://api.github.com/repos/ubuntu-core/snappy/pulls/178/comments"},"review_comment":{"href":"https://api.github.com/repos/ubuntu-core/snappy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ubuntu-core/snappy/pulls/178/commits"},"statuses":{"href":"https://api.github.com/repos/ubuntu-core/snappy/statuses/24fdea01cf94636f20b9fe1389d66bab4e558028"}}}}