{"action":"created","comment":{"url":"https://api.github.com/repos/coreos/rkt/pulls/comments/27991733","id":27991733,"diff_hunk":"@@ -0,0 +1,276 @@\n+// Copyright 2015 CoreOS, Inc.\n+//\n+// Licensed under the Apache License, Version 2.0 (the \"License\");\n+// you may not use this file except in compliance with the License.\n+// You may obtain a copy of the License at\n+//\n+//     http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// Unless required by applicable law or agreed to in writing, software\n+// distributed under the License is distributed on an \"AS IS\" BASIS,\n+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+// See the License for the specific language governing permissions and\n+// limitations under the License.\n+\n+package config\n+\n+import (\n+\t\"encoding/json\"\n+\t\"fmt\"\n+\t\"io/ioutil\"\n+\t\"net/http\"\n+\t\"os\"\n+\t\"path/filepath\"\n+\t\"sort\"\n+\t\"strings\"\n+)\n+\n+// Headerer is an interface for getting additional HTTP headers to use\n+// when downloading data (images, signatures).\n+type Headerer interface {\n+\tHeader() http.Header\n+}\n+\n+// Config is a single place where configuration for rkt frontend needs\n+// resides.\n+type Config struct {\n+\tAuthPerHost map[string]Headerer\n+}\n+\n+type configParser interface {\n+\tparse(config *Config, raw []byte) error\n+}\n+\n+var (\n+\t// configSubDirs is a map saying what kinds of configuration\n+\t// (values) are acceptable in a config subdirectory (key)\n+\tconfigSubDirs  = make(map[string][]string)\n+\tparsersForKind = make(map[string]map[string]configParser)\n+)\n+\n+// Default paths for vendor and custom configuration\n+const (\n+\tDefaultVendorPath = \"/usr/lib/rkt\"\n+\tDefaultCustomPath = \"/etc/rkt\"\n+)\n+\n+func addParser(kind, version string, parser configParser) {\n+\tif len(kind) == 0 {\n+\t\tpanic(\"empty kind string when registering a config parser\")\n+\t}\n+\tif len(version) == 0 {\n+\t\tpanic(\"empty version string when registering a config parser\")\n+\t}\n+\tif parser == nil {\n+\t\tpanic(\"trying to register a nil parser\")\n+\t}\n+\tif _, err := getParser(kind, version); err == nil {\n+\t\tpanic(fmt.Sprintf(\"A parser for kind %q and version %q already exist\", kind, version))\n+\t}\n+\tif _, ok := parsersForKind[kind]; !ok {\n+\t\tparsersForKind[kind] = make(map[string]configParser)\n+\t}\n+\tparsersForKind[kind][version] = parser\n+}\n+\n+func registerSubDir(dir string, kinds []string) {\n+\tif len(dir) == 0 {\n+\t\tpanic(\"trying to register empty config subdirectory\")\n+\t}\n+\tif len(kinds) == 0 {\n+\t\tpanic(\"kinds array cannot be empty when registering config subdir\")\n+\t}\n+\tallKinds := toArray(toSet(append(configSubDirs[dir], kinds...)))\n+\tsort.Strings(allKinds)","path":"rkt/config/config.go","position":84,"original_position":84,"commit_id":"61fe759ddb523f8ff881e9a279959936a900ab1f","original_commit_id":"61fe759ddb523f8ff881e9a279959936a900ab1f","user":{"login":"jonboulle","id":2601015,"avatar_url":"https://avatars.githubusercontent.com/u/2601015?v=3","gravatar_id":"","url":"https://api.github.com/users/jonboulle","html_url":"https://github.com/jonboulle","followers_url":"https://api.github.com/users/jonboulle/followers","following_url":"https://api.github.com/users/jonboulle/following{/other_user}","gists_url":"https://api.github.com/users/jonboulle/gists{/gist_id}","starred_url":"https://api.github.com/users/jonboulle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonboulle/subscriptions","organizations_url":"https://api.github.com/users/jonboulle/orgs","repos_url":"https://api.github.com/users/jonboulle/repos","events_url":"https://api.github.com/users/jonboulle/events{/privacy}","received_events_url":"https://api.github.com/users/jonboulle/received_events","type":"User","site_admin":false},"body":"redundant with 101 fwiw, could just define that func as returning sorted results (or really inline all that here since it isn't used elsewhere yet)","created_at":"2015-04-08T17:21:53Z","updated_at":"2015-04-08T17:21:53Z","html_url":"https://github.com/coreos/rkt/pull/364#discussion_r27991733","pull_request_url":"https://api.github.com/repos/coreos/rkt/pulls/364","_links":{"self":{"href":"https://api.github.com/repos/coreos/rkt/pulls/comments/27991733"},"html":{"href":"https://github.com/coreos/rkt/pull/364#discussion_r27991733"},"pull_request":{"href":"https://api.github.com/repos/coreos/rkt/pulls/364"}}},"pull_request":{"url":"https://api.github.com/repos/coreos/rkt/pulls/364","id":27207834,"html_url":"https://github.com/coreos/rkt/pull/364","diff_url":"https://github.com/coreos/rkt/pull/364.diff","patch_url":"https://github.com/coreos/rkt/pull/364.patch","issue_url":"https://api.github.com/repos/coreos/rkt/issues/364","number":364,"state":"open","locked":false,"title":"fetch: add config and auth for #194","user":{"login":"krnowak","id":96081,"avatar_url":"https://avatars.githubusercontent.com/u/96081?v=3","gravatar_id":"","url":"https://api.github.com/users/krnowak","html_url":"https://github.com/krnowak","followers_url":"https://api.github.com/users/krnowak/followers","following_url":"https://api.github.com/users/krnowak/following{/other_user}","gists_url":"https://api.github.com/users/krnowak/gists{/gist_id}","starred_url":"https://api.github.com/users/krnowak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krnowak/subscriptions","organizations_url":"https://api.github.com/users/krnowak/orgs","repos_url":"https://api.github.com/users/krnowak/repos","events_url":"https://api.github.com/users/krnowak/events{/privacy}","received_events_url":"https://api.github.com/users/krnowak/received_events","type":"User","site_admin":false},"body":"This adds JSON config in /etc/rkt/config.json and options for basic auth and oauth bearer token auth.\r\n\r\nCredentials are sent only over HTTPS.\r\n\r\nSee #194.","created_at":"2015-01-12T16:49:17Z","updated_at":"2015-04-08T17:21:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e64340d47ea4ab956816f7785ba3f2c7c69afd59","assignee":null,"milestone":{"url":"https://api.github.com/repos/coreos/rkt/milestones/11","html_url":"https://github.com/coreos/rkt/milestones/v0.6.0","labels_url":"https://api.github.com/repos/coreos/rkt/milestones/11/labels","id":1037040,"number":11,"title":"v0.6.0","description":"","creator":{"login":"philips","id":33544,"avatar_url":"https://avatars.githubusercontent.com/u/33544?v=3","gravatar_id":"","url":"https://api.github.com/users/philips","html_url":"https://github.com/philips","followers_url":"https://api.github.com/users/philips/followers","following_url":"https://api.github.com/users/philips/following{/other_user}","gists_url":"https://api.github.com/users/philips/gists{/gist_id}","starred_url":"https://api.github.com/users/philips/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philips/subscriptions","organizations_url":"https://api.github.com/users/philips/orgs","repos_url":"https://api.github.com/users/philips/repos","events_url":"https://api.github.com/users/philips/events{/privacy}","received_events_url":"https://api.github.com/users/philips/received_events","type":"User","site_admin":false},"open_issues":17,"closed_issues":7,"state":"open","created_at":"2015-03-24T19:40:37Z","updated_at":"2015-04-08T17:18:01Z","due_on":"2015-04-11T07:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/coreos/rkt/pulls/364/commits","review_comments_url":"https://api.github.com/repos/coreos/rkt/pulls/364/comments","review_comment_url":"https://api.github.com/repos/coreos/rkt/pulls/comments{/number}","comments_url":"https://api.github.com/repos/coreos/rkt/issues/364/comments","statuses_url":"https://api.github.com/repos/coreos/rkt/statuses/61fe759ddb523f8ff881e9a279959936a900ab1f","head":{"label":"endocode:krnowak/config-and-auth","ref":"krnowak/config-and-auth","sha":"61fe759ddb523f8ff881e9a279959936a900ab1f","user":{"login":"endocode","id":4068543,"avatar_url":"https://avatars.githubusercontent.com/u/4068543?v=3","gravatar_id":"","url":"https://api.github.com/users/endocode","html_url":"https://github.com/endocode","followers_url":"https://api.github.com/users/endocode/followers","following_url":"https://api.github.com/users/endocode/following{/other_user}","gists_url":"https://api.github.com/users/endocode/gists{/gist_id}","starred_url":"https://api.github.com/users/endocode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/endocode/subscriptions","organizations_url":"https://api.github.com/users/endocode/orgs","repos_url":"https://api.github.com/users/endocode/repos","events_url":"https://api.github.com/users/endocode/events{/privacy}","received_events_url":"https://api.github.com/users/endocode/received_events","type":"Organization","site_admin":false},"repo":{"id":28082853,"name":"rkt","full_name":"endocode/rkt","owner":{"login":"endocode","id":4068543,"avatar_url":"https://avatars.githubusercontent.com/u/4068543?v=3","gravatar_id":"","url":"https://api.github.com/users/endocode","html_url":"https://github.com/endocode","followers_url":"https://api.github.com/users/endocode/followers","following_url":"https://api.github.com/users/endocode/following{/other_user}","gists_url":"https://api.github.com/users/endocode/gists{/gist_id}","starred_url":"https://api.github.com/users/endocode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/endocode/subscriptions","organizations_url":"https://api.github.com/users/endocode/orgs","repos_url":"https://api.github.com/users/endocode/repos","events_url":"https://api.github.com/users/endocode/events{/privacy}","received_events_url":"https://api.github.com/users/endocode/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/endocode/rkt","description":"App Container runtime","fork":true,"url":"https://api.github.com/repos/endocode/rkt","forks_url":"https://api.github.com/repos/endocode/rkt/forks","keys_url":"https://api.github.com/repos/endocode/rkt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/endocode/rkt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/endocode/rkt/teams","hooks_url":"https://api.github.com/repos/endocode/rkt/hooks","issue_events_url":"https://api.github.com/repos/endocode/rkt/issues/events{/number}","events_url":"https://api.github.com/repos/endocode/rkt/events","assignees_url":"https://api.github.com/repos/endocode/rkt/assignees{/user}","branches_url":"https://api.github.com/repos/endocode/rkt/branches{/branch}","tags_url":"https://api.github.com/repos/endocode/rkt/tags","blobs_url":"https://api.github.com/repos/endocode/rkt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/endocode/rkt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/endocode/rkt/git/refs{/sha}","trees_url":"https://api.github.com/repos/endocode/rkt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/endocode/rkt/statuses/{sha}","languages_url":"https://api.github.com/repos/endocode/rkt/languages","stargazers_url":"https://api.github.com/repos/endocode/rkt/stargazers","contributors_url":"https://api.github.com/repos/endocode/rkt/contributors","subscribers_url":"https://api.github.com/repos/endocode/rkt/subscribers","subscription_url":"https://api.github.com/repos/endocode/rkt/subscription","commits_url":"https://api.github.com/repos/endocode/rkt/commits{/sha}","git_commits_url":"https://api.github.com/repos/endocode/rkt/git/commits{/sha}","comments_url":"https://api.github.com/repos/endocode/rkt/comments{/number}","issue_comment_url":"https://api.github.com/repos/endocode/rkt/issues/comments{/number}","contents_url":"https://api.github.com/repos/endocode/rkt/contents/{+path}","compare_url":"https://api.github.com/repos/endocode/rkt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/endocode/rkt/merges","archive_url":"https://api.github.com/repos/endocode/rkt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/endocode/rkt/downloads","issues_url":"https://api.github.com/repos/endocode/rkt/issues{/number}","pulls_url":"https://api.github.com/repos/endocode/rkt/pulls{/number}","milestones_url":"https://api.github.com/repos/endocode/rkt/milestones{/number}","notifications_url":"https://api.github.com/repos/endocode/rkt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/endocode/rkt/labels{/name}","releases_url":"https://api.github.com/repos/endocode/rkt/releases{/id}","created_at":"2014-12-16T10:52:13Z","updated_at":"2015-04-01T08:28:55Z","pushed_at":"2015-04-08T14:16:19Z","git_url":"git://github.com/endocode/rkt.git","ssh_url":"git@github.com:endocode/rkt.git","clone_url":"https://github.com/endocode/rkt.git","svn_url":"https://github.com/endocode/rkt","homepage":"","size":5821,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"coreos:master","ref":"master","sha":"96d0cc03f28c63440ea2f1d7b3e145e0b7333d0b","user":{"login":"coreos","id":3730757,"avatar_url":"https://avatars.githubusercontent.com/u/3730757?v=3","gravatar_id":"","url":"https://api.github.com/users/coreos","html_url":"https://github.com/coreos","followers_url":"https://api.github.com/users/coreos/followers","following_url":"https://api.github.com/users/coreos/following{/other_user}","gists_url":"https://api.github.com/users/coreos/gists{/gist_id}","starred_url":"https://api.github.com/users/coreos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coreos/subscriptions","organizations_url":"https://api.github.com/users/coreos/orgs","repos_url":"https://api.github.com/users/coreos/repos","events_url":"https://api.github.com/users/coreos/events{/privacy}","received_events_url":"https://api.github.com/users/coreos/received_events","type":"Organization","site_admin":false},"repo":{"id":26509369,"name":"rkt","full_name":"coreos/rkt","owner":{"login":"coreos","id":3730757,"avatar_url":"https://avatars.githubusercontent.com/u/3730757?v=3","gravatar_id":"","url":"https://api.github.com/users/coreos","html_url":"https://github.com/coreos","followers_url":"https://api.github.com/users/coreos/followers","following_url":"https://api.github.com/users/coreos/following{/other_user}","gists_url":"https://api.github.com/users/coreos/gists{/gist_id}","starred_url":"https://api.github.com/users/coreos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coreos/subscriptions","organizations_url":"https://api.github.com/users/coreos/orgs","repos_url":"https://api.github.com/users/coreos/repos","events_url":"https://api.github.com/users/coreos/events{/privacy}","received_events_url":"https://api.github.com/users/coreos/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/coreos/rkt","description":"App Container runtime","fork":false,"url":"https://api.github.com/repos/coreos/rkt","forks_url":"https://api.github.com/repos/coreos/rkt/forks","keys_url":"https://api.github.com/repos/coreos/rkt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/coreos/rkt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/coreos/rkt/teams","hooks_url":"https://api.github.com/repos/coreos/rkt/hooks","issue_events_url":"https://api.github.com/repos/coreos/rkt/issues/events{/number}","events_url":"https://api.github.com/repos/coreos/rkt/events","assignees_url":"https://api.github.com/repos/coreos/rkt/assignees{/user}","branches_url":"https://api.github.com/repos/coreos/rkt/branches{/branch}","tags_url":"https://api.github.com/repos/coreos/rkt/tags","blobs_url":"https://api.github.com/repos/coreos/rkt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/coreos/rkt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/coreos/rkt/git/refs{/sha}","trees_url":"https://api.github.com/repos/coreos/rkt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/coreos/rkt/statuses/{sha}","languages_url":"https://api.github.com/repos/coreos/rkt/languages","stargazers_url":"https://api.github.com/repos/coreos/rkt/stargazers","contributors_url":"https://api.github.com/repos/coreos/rkt/contributors","subscribers_url":"https://api.github.com/repos/coreos/rkt/subscribers","subscription_url":"https://api.github.com/repos/coreos/rkt/subscription","commits_url":"https://api.github.com/repos/coreos/rkt/commits{/sha}","git_commits_url":"https://api.github.com/repos/coreos/rkt/git/commits{/sha}","comments_url":"https://api.github.com/repos/coreos/rkt/comments{/number}","issue_comment_url":"https://api.github.com/repos/coreos/rkt/issues/comments{/number}","contents_url":"https://api.github.com/repos/coreos/rkt/contents/{+path}","compare_url":"https://api.github.com/repos/coreos/rkt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/coreos/rkt/merges","archive_url":"https://api.github.com/repos/coreos/rkt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/coreos/rkt/downloads","issues_url":"https://api.github.com/repos/coreos/rkt/issues{/number}","pulls_url":"https://api.github.com/repos/coreos/rkt/pulls{/number}","milestones_url":"https://api.github.com/repos/coreos/rkt/milestones{/number}","notifications_url":"https://api.github.com/repos/coreos/rkt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/coreos/rkt/labels{/name}","releases_url":"https://api.github.com/repos/coreos/rkt/releases{/id}","created_at":"2014-11-11T23:13:18Z","updated_at":"2015-04-08T17:18:02Z","pushed_at":"2015-04-08T17:18:02Z","git_url":"git://github.com/coreos/rkt.git","ssh_url":"git@github.com:coreos/rkt.git","clone_url":"https://github.com/coreos/rkt.git","svn_url":"https://github.com/coreos/rkt","homepage":"","size":12331,"stargazers_count":3731,"watchers_count":3731,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":279,"mirror_url":null,"open_issues_count":88,"forks":279,"open_issues":88,"watchers":3731,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/coreos/rkt/pulls/364"},"html":{"href":"https://github.com/coreos/rkt/pull/364"},"issue":{"href":"https://api.github.com/repos/coreos/rkt/issues/364"},"comments":{"href":"https://api.github.com/repos/coreos/rkt/issues/364/comments"},"review_comments":{"href":"https://api.github.com/repos/coreos/rkt/pulls/364/comments"},"review_comment":{"href":"https://api.github.com/repos/coreos/rkt/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/coreos/rkt/pulls/364/commits"},"statuses":{"href":"https://api.github.com/repos/coreos/rkt/statuses/61fe759ddb523f8ff881e9a279959936a900ab1f"}}}}