{"action":"created","comment":{"url":"https://api.github.com/repos/snapcore/snapd/pulls/comments/240963478","pull_request_review_id":184113516,"id":240963478,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0MDk2MzQ3OA==","diff_hunk":"@@ -0,0 +1,124 @@\n+// -*- Mode: Go; indent-tabs-mode: t -*-\n+\n+/*\n+ * Copyright (C) 2018 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 features\n+\n+import (\n+\t\"fmt\"\n+\t\"path/filepath\"\n+\n+\t\"github.com/snapcore/snapd/dirs\"\n+\t\"github.com/snapcore/snapd/osutil\"\n+)\n+\n+// SnapdFeature is a named feature that may be on or off.\n+type SnapdFeature int\n+\n+const (\n+\t// Layouts controls availability of snap layouts.\n+\tLayouts SnapdFeature = iota\n+\t// ParallelInstances controls availability installing a snap multiple times.\n+\tParallelInstances\n+\t// Hotplug controls availability of dynamically creating slots based on system hardware.\n+\tHotplug\n+\t// SnapdSnap controls possibility of installing the snapd snap.\n+\tSnapdSnap\n+\t// PerUserMountNamespace controls the persistence of per-user mount namespaces.\n+\tPerUserMountNamespace\n+\t// lastFeature is the final known feature, it is only used for testing.\n+\tlastFeature\n+)\n+\n+// KnownFeatures returns the list of all known features.\n+func KnownFeatures() []SnapdFeature {\n+\treturn []SnapdFeature{Layouts, ParallelInstances, Hotplug, SnapdSnap, PerUserMountNamespace}\n+}\n+\n+// featyreNames maps feature constant to stable string representation.\n+// The constants here must be synchronized with cmd/libsnap-confine-private/feature.c\n+var featureNames = map[SnapdFeature]string{\n+\tLayouts:               \"layouts\",\n+\tParallelInstances:     \"parallel-instances\",\n+\tHotplug:               \"hotplug\",\n+\tSnapdSnap:             \"snapd-snap\",\n+\tPerUserMountNamespace: \"per-user-mount-namespace\",\n+}\n+\n+// String returns the name of a snapd feature.\n+// The function panics for bogus feature values.\n+func (f SnapdFeature) String() string {\n+\tif name, ok := featureNames[f]; ok {\n+\t\treturn name\n+\t}\n+\tpanic(fmt.Sprintf(\"unknown feature flag code %d\", f))\n+}\n+\n+// IsEnabledWhenUnset returns true if a feature is enabled when not set.\n+//\n+// A feature may be enabled or disabled with explicit state in snapd. If\n+// explicit state is absent the effective value is the implicit default\n+// computed by this function.\n+func (f SnapdFeature) IsEnabledWhenUnset() bool {\n+\tswitch f {\n+\tcase Layouts:\n+\t\treturn true\n+\t}\n+\treturn false\n+}\n+\n+// IsExported returns true if a feature is copied from snapd state to a feature file.\n+//\n+// Certain features are available outside of snapd internal state and visible as control\n+// files in a dedicated directory. Such features can be queried for, via IsEnabled, outside\n+// of snapd.\n+func (f SnapdFeature) IsExported() bool {\n+\tswitch f {\n+\tcase PerUserMountNamespace:\n+\t\treturn true\n+\t}\n+\treturn false\n+}\n+\n+// ControlFile returns the path of the file controlling the exported feature.\n+//\n+// Snapd considers the feature enabled if the file is present.\n+// The contents of the file are not important.\n+//\n+// The function panics for features that are not exported.\n+func (f SnapdFeature) ControlFile() string {\n+\tif !f.IsExported() {\n+\t\tpanic(fmt.Sprintf(\"cannot compute the control file of feature %q because that feature is not exported\", f))\n+\t}\n+\treturn filepath.Join(dirs.FeaturesDir, f.String())\n+}\n+\n+// ConfigOption returns the snap name and configuration option associated with this feature.\n+func (f SnapdFeature) ConfigOption() (snapName, confName string) {\n+\treturn \"core\", \"experimental.\" + f.String()","path":"features/features.go","position":113,"original_position":113,"commit_id":"3f5cd538f5ba64d088ab3c8fa5f10e0fe89a4c42","original_commit_id":"3f5cd538f5ba64d088ab3c8fa5f10e0fe89a4c42","user":{"login":"zyga","id":784262,"node_id":"MDQ6VXNlcjc4NDI2Mg==","avatar_url":"https://avatars0.githubusercontent.com/u/784262?v=4","gravatar_id":"","url":"https://api.github.com/users/zyga","html_url":"https://github.com/zyga","followers_url":"https://api.github.com/users/zyga/followers","following_url":"https://api.github.com/users/zyga/following{/other_user}","gists_url":"https://api.github.com/users/zyga/gists{/gist_id}","starred_url":"https://api.github.com/users/zyga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zyga/subscriptions","organizations_url":"https://api.github.com/users/zyga/orgs","repos_url":"https://api.github.com/users/zyga/repos","events_url":"https://api.github.com/users/zyga/events{/privacy}","received_events_url":"https://api.github.com/users/zyga/received_events","type":"User","site_admin":false},"body":"I was thinking about this and for now I don't have any ideas. I chose to put the snap name here since the consumers of this API have to provide one. It felt odd to hard-code one decision there and one decision here.","created_at":"2018-12-12T10:44:20Z","updated_at":"2018-12-12T10:44:21Z","html_url":"https://github.com/snapcore/snapd/pull/6190#discussion_r240963478","pull_request_url":"https://api.github.com/repos/snapcore/snapd/pulls/6190","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/snapcore/snapd/pulls/comments/240963478"},"html":{"href":"https://github.com/snapcore/snapd/pull/6190#discussion_r240963478"},"pull_request":{"href":"https://api.github.com/repos/snapcore/snapd/pulls/6190"}},"in_reply_to_id":240919395},"pull_request":{"url":"https://api.github.com/repos/snapcore/snapd/pulls/6190","id":232942373,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMyOTQyMzcz","html_url":"https://github.com/snapcore/snapd/pull/6190","diff_url":"https://github.com/snapcore/snapd/pull/6190.diff","patch_url":"https://github.com/snapcore/snapd/pull/6190.patch","issue_url":"https://api.github.com/repos/snapcore/snapd/issues/6190","number":6190,"state":"open","locked":false,"title":"overlord/configstate,features: expose features to snapd tools","user":{"login":"zyga","id":784262,"node_id":"MDQ6VXNlcjc4NDI2Mg==","avatar_url":"https://avatars0.githubusercontent.com/u/784262?v=4","gravatar_id":"","url":"https://api.github.com/users/zyga","html_url":"https://github.com/zyga","followers_url":"https://api.github.com/users/zyga/followers","following_url":"https://api.github.com/users/zyga/following{/other_user}","gists_url":"https://api.github.com/users/zyga/gists{/gist_id}","starred_url":"https://api.github.com/users/zyga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zyga/subscriptions","organizations_url":"https://api.github.com/users/zyga/orgs","repos_url":"https://api.github.com/users/zyga/repos","events_url":"https://api.github.com/users/zyga/events{/privacy}","received_events_url":"https://api.github.com/users/zyga/received_events","type":"User","site_admin":false},"body":"This is a combination of https://github.com/snapcore/snapd/pull/6181\r\nand https://github.com/snapcore/snapd/pull/6170","created_at":"2018-11-22T11:13:50Z","updated_at":"2018-12-12T10:44:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f4cf59beedc01e5c8f1280f688cfba0bdad7fa8f","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/snapcore/snapd/pulls/6190/commits","review_comments_url":"https://api.github.com/repos/snapcore/snapd/pulls/6190/comments","review_comment_url":"https://api.github.com/repos/snapcore/snapd/pulls/comments{/number}","comments_url":"https://api.github.com/repos/snapcore/snapd/issues/6190/comments","statuses_url":"https://api.github.com/repos/snapcore/snapd/statuses/3f5cd538f5ba64d088ab3c8fa5f10e0fe89a4c42","head":{"label":"zyga:feature/user-mount-ns-13","ref":"feature/user-mount-ns-13","sha":"3f5cd538f5ba64d088ab3c8fa5f10e0fe89a4c42","user":{"login":"zyga","id":784262,"node_id":"MDQ6VXNlcjc4NDI2Mg==","avatar_url":"https://avatars0.githubusercontent.com/u/784262?v=4","gravatar_id":"","url":"https://api.github.com/users/zyga","html_url":"https://github.com/zyga","followers_url":"https://api.github.com/users/zyga/followers","following_url":"https://api.github.com/users/zyga/following{/other_user}","gists_url":"https://api.github.com/users/zyga/gists{/gist_id}","starred_url":"https://api.github.com/users/zyga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zyga/subscriptions","organizations_url":"https://api.github.com/users/zyga/orgs","repos_url":"https://api.github.com/users/zyga/repos","events_url":"https://api.github.com/users/zyga/events{/privacy}","received_events_url":"https://api.github.com/users/zyga/received_events","type":"User","site_admin":false},"repo":{"id":45263078,"node_id":"MDEwOlJlcG9zaXRvcnk0NTI2MzA3OA==","name":"snapd","full_name":"zyga/snapd","private":false,"owner":{"login":"zyga","id":784262,"node_id":"MDQ6VXNlcjc4NDI2Mg==","avatar_url":"https://avatars0.githubusercontent.com/u/784262?v=4","gravatar_id":"","url":"https://api.github.com/users/zyga","html_url":"https://github.com/zyga","followers_url":"https://api.github.com/users/zyga/followers","following_url":"https://api.github.com/users/zyga/following{/other_user}","gists_url":"https://api.github.com/users/zyga/gists{/gist_id}","starred_url":"https://api.github.com/users/zyga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zyga/subscriptions","organizations_url":"https://api.github.com/users/zyga/orgs","repos_url":"https://api.github.com/users/zyga/repos","events_url":"https://api.github.com/users/zyga/events{/privacy}","received_events_url":"https://api.github.com/users/zyga/received_events","type":"User","site_admin":false},"html_url":"https://github.com/zyga/snapd","description":"Snappy is the software at the heart of Ubuntu Core.","fork":true,"url":"https://api.github.com/repos/zyga/snapd","forks_url":"https://api.github.com/repos/zyga/snapd/forks","keys_url":"https://api.github.com/repos/zyga/snapd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zyga/snapd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zyga/snapd/teams","hooks_url":"https://api.github.com/repos/zyga/snapd/hooks","issue_events_url":"https://api.github.com/repos/zyga/snapd/issues/events{/number}","events_url":"https://api.github.com/repos/zyga/snapd/events","assignees_url":"https://api.github.com/repos/zyga/snapd/assignees{/user}","branches_url":"https://api.github.com/repos/zyga/snapd/branches{/branch}","tags_url":"https://api.github.com/repos/zyga/snapd/tags","blobs_url":"https://api.github.com/repos/zyga/snapd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zyga/snapd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zyga/snapd/git/refs{/sha}","trees_url":"https://api.github.com/repos/zyga/snapd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zyga/snapd/statuses/{sha}","languages_url":"https://api.github.com/repos/zyga/snapd/languages","stargazers_url":"https://api.github.com/repos/zyga/snapd/stargazers","contributors_url":"https://api.github.com/repos/zyga/snapd/contributors","subscribers_url":"https://api.github.com/repos/zyga/snapd/subscribers","subscription_url":"https://api.github.com/repos/zyga/snapd/subscription","commits_url":"https://api.github.com/repos/zyga/snapd/commits{/sha}","git_commits_url":"https://api.github.com/repos/zyga/snapd/git/commits{/sha}","comments_url":"https://api.github.com/repos/zyga/snapd/comments{/number}","issue_comment_url":"https://api.github.com/repos/zyga/snapd/issues/comments{/number}","contents_url":"https://api.github.com/repos/zyga/snapd/contents/{+path}","compare_url":"https://api.github.com/repos/zyga/snapd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zyga/snapd/merges","archive_url":"https://api.github.com/repos/zyga/snapd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zyga/snapd/downloads","issues_url":"https://api.github.com/repos/zyga/snapd/issues{/number}","pulls_url":"https://api.github.com/repos/zyga/snapd/pulls{/number}","milestones_url":"https://api.github.com/repos/zyga/snapd/milestones{/number}","notifications_url":"https://api.github.com/repos/zyga/snapd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zyga/snapd/labels{/name}","releases_url":"https://api.github.com/repos/zyga/snapd/releases{/id}","deployments_url":"https://api.github.com/repos/zyga/snapd/deployments","created_at":"2015-10-30T16:30:25Z","updated_at":"2018-12-06T14:04:50Z","pushed_at":"2018-12-12T09:13:49Z","git_url":"git://github.com/zyga/snapd.git","ssh_url":"git@github.com:zyga/snapd.git","clone_url":"https://github.com/zyga/snapd.git","svn_url":"https://github.com/zyga/snapd","homepage":null,"size":77304,"stargazers_count":1,"watchers_count":1,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"snapcore:master","ref":"master","sha":"622bbf36f8b8a7341e6d5fa19e4440d4dd0bdad4","user":{"login":"snapcore","id":19532717,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE5NTMyNzE3","avatar_url":"https://avatars1.githubusercontent.com/u/19532717?v=4","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":44672744,"node_id":"MDEwOlJlcG9zaXRvcnk0NDY3Mjc0NA==","name":"snapd","full_name":"snapcore/snapd","private":false,"owner":{"login":"snapcore","id":19532717,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE5NTMyNzE3","avatar_url":"https://avatars1.githubusercontent.com/u/19532717?v=4","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},"html_url":"https://github.com/snapcore/snapd","description":"The snapd and snap tools enable systems to work with .snap files.","fork":false,"url":"https://api.github.com/repos/snapcore/snapd","forks_url":"https://api.github.com/repos/snapcore/snapd/forks","keys_url":"https://api.github.com/repos/snapcore/snapd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/snapcore/snapd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/snapcore/snapd/teams","hooks_url":"https://api.github.com/repos/snapcore/snapd/hooks","issue_events_url":"https://api.github.com/repos/snapcore/snapd/issues/events{/number}","events_url":"https://api.github.com/repos/snapcore/snapd/events","assignees_url":"https://api.github.com/repos/snapcore/snapd/assignees{/user}","branches_url":"https://api.github.com/repos/snapcore/snapd/branches{/branch}","tags_url":"https://api.github.com/repos/snapcore/snapd/tags","blobs_url":"https://api.github.com/repos/snapcore/snapd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/snapcore/snapd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/snapcore/snapd/git/refs{/sha}","trees_url":"https://api.github.com/repos/snapcore/snapd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/snapcore/snapd/statuses/{sha}","languages_url":"https://api.github.com/repos/snapcore/snapd/languages","stargazers_url":"https://api.github.com/repos/snapcore/snapd/stargazers","contributors_url":"https://api.github.com/repos/snapcore/snapd/contributors","subscribers_url":"https://api.github.com/repos/snapcore/snapd/subscribers","subscription_url":"https://api.github.com/repos/snapcore/snapd/subscription","commits_url":"https://api.github.com/repos/snapcore/snapd/commits{/sha}","git_commits_url":"https://api.github.com/repos/snapcore/snapd/git/commits{/sha}","comments_url":"https://api.github.com/repos/snapcore/snapd/comments{/number}","issue_comment_url":"https://api.github.com/repos/snapcore/snapd/issues/comments{/number}","contents_url":"https://api.github.com/repos/snapcore/snapd/contents/{+path}","compare_url":"https://api.github.com/repos/snapcore/snapd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/snapcore/snapd/merges","archive_url":"https://api.github.com/repos/snapcore/snapd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/snapcore/snapd/downloads","issues_url":"https://api.github.com/repos/snapcore/snapd/issues{/number}","pulls_url":"https://api.github.com/repos/snapcore/snapd/pulls{/number}","milestones_url":"https://api.github.com/repos/snapcore/snapd/milestones{/number}","notifications_url":"https://api.github.com/repos/snapcore/snapd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/snapcore/snapd/labels{/name}","releases_url":"https://api.github.com/repos/snapcore/snapd/releases{/id}","deployments_url":"https://api.github.com/repos/snapcore/snapd/deployments","created_at":"2015-10-21T11:51:46Z","updated_at":"2018-12-11T19:27:32Z","pushed_at":"2018-12-12T10:27:06Z","git_url":"git://github.com/snapcore/snapd.git","ssh_url":"git@github.com:snapcore/snapd.git","clone_url":"https://github.com/snapcore/snapd.git","svn_url":"https://github.com/snapcore/snapd","homepage":"","size":76556,"stargazers_count":1053,"watchers_count":1053,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":265,"mirror_url":null,"archived":false,"open_issues_count":45,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":265,"open_issues":45,"watchers":1053,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/snapcore/snapd/pulls/6190"},"html":{"href":"https://github.com/snapcore/snapd/pull/6190"},"issue":{"href":"https://api.github.com/repos/snapcore/snapd/issues/6190"},"comments":{"href":"https://api.github.com/repos/snapcore/snapd/issues/6190/comments"},"review_comments":{"href":"https://api.github.com/repos/snapcore/snapd/pulls/6190/comments"},"review_comment":{"href":"https://api.github.com/repos/snapcore/snapd/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/snapcore/snapd/pulls/6190/commits"},"statuses":{"href":"https://api.github.com/repos/snapcore/snapd/statuses/3f5cd538f5ba64d088ab3c8fa5f10e0fe89a4c42"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"zyga"}}