{"action":"created","comment":{"url":"https://api.github.com/repos/segmentio/conf/pulls/comments/96104400","pull_request_review_id":16683293,"id":96104400,"diff_hunk":"@@ -0,0 +1,156 @@\n+package conf\n+\n+import (\n+\t\"bytes\"\n+\t\"flag\"\n+\t\"html/template\"\n+\t\"reflect\"\n+\t\"strings\"\n+)\n+\n+// Source is the interface that allow new types to be plugged into a loader to\n+// make it possible to load configuration from new places.\n+//\n+// When the configuration is loaded the Load method of each source that was set\n+// on a loader is called with a pointer to an in-memory structure representing\n+// the configuration object passed as dst.\n+type Source interface {\n+\tLoad(dst interface{}) error\n+}\n+\n+// FlagSource is a special case of a source that receives a configuration value","path":"source.go","position":21,"original_position":21,"commit_id":"a9ec6e23d3a326d8528fec493436f76f4c838738","original_commit_id":"a9ec6e23d3a326d8528fec493436f76f4c838738","user":{"login":"achille-roussel","id":865510,"avatar_url":"https://avatars.githubusercontent.com/u/865510?v=3","gravatar_id":"","url":"https://api.github.com/users/achille-roussel","html_url":"https://github.com/achille-roussel","followers_url":"https://api.github.com/users/achille-roussel/followers","following_url":"https://api.github.com/users/achille-roussel/following{/other_user}","gists_url":"https://api.github.com/users/achille-roussel/gists{/gist_id}","starred_url":"https://api.github.com/users/achille-roussel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/achille-roussel/subscriptions","organizations_url":"https://api.github.com/users/achille-roussel/orgs","repos_url":"https://api.github.com/users/achille-roussel/repos","events_url":"https://api.github.com/users/achille-roussel/events{/privacy}","received_events_url":"https://api.github.com/users/achille-roussel/received_events","type":"User","site_admin":false},"body":"That's really not how it would work.\r\n\r\nThe config struct has just your configuration, the custom sources you set are just different places to get the configuration from. And the default loader has been reimplemented with a file and env sources to mirror the historical behavior using the new concepts (as a proof that it's working).\r\n\r\nNothing is fancy here, the source just injects a flag is the set of flags supported by the loader so it we can pass the path to a configuration file to load the config from (the way it used to work).\r\n","created_at":"2017-01-14T01:42:19Z","updated_at":"2017-01-14T01:42:19Z","html_url":"https://github.com/segmentio/conf/pull/5#discussion_r96104400","pull_request_url":"https://api.github.com/repos/segmentio/conf/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/segmentio/conf/pulls/comments/96104400"},"html":{"href":"https://github.com/segmentio/conf/pull/5#discussion_r96104400"},"pull_request":{"href":"https://api.github.com/repos/segmentio/conf/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/segmentio/conf/pulls/5","id":101540702,"html_url":"https://github.com/segmentio/conf/pull/5","diff_url":"https://github.com/segmentio/conf/pull/5.diff","patch_url":"https://github.com/segmentio/conf/pull/5.patch","issue_url":"https://api.github.com/repos/segmentio/conf/issues/5","number":5,"state":"open","locked":false,"title":"Sources","user":{"login":"achille-roussel","id":865510,"avatar_url":"https://avatars.githubusercontent.com/u/865510?v=3","gravatar_id":"","url":"https://api.github.com/users/achille-roussel","html_url":"https://github.com/achille-roussel","followers_url":"https://api.github.com/users/achille-roussel/followers","following_url":"https://api.github.com/users/achille-roussel/following{/other_user}","gists_url":"https://api.github.com/users/achille-roussel/gists{/gist_id}","starred_url":"https://api.github.com/users/achille-roussel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/achille-roussel/subscriptions","organizations_url":"https://api.github.com/users/achille-roussel/orgs","repos_url":"https://api.github.com/users/achille-roussel/repos","events_url":"https://api.github.com/users/achille-roussel/events{/privacy}","received_events_url":"https://api.github.com/users/achille-roussel/received_events","type":"User","site_admin":false},"body":"@f2prateek \r\n@tejasmanohar \r\n@andreiko \r\n\r\nPrateek had a discussion around the need for being able to customize where the program loads its configuration from.\r\n\r\nBecause this includes some non-backward compatible changes I wanted to get it out as quickly as possible while we don't have too many dependencies yet. Note that the basic use case is left unchanged, code that just relies on `conf.Load` will compile and run as expected.\r\n\r\nThe way it works is by configuration a `conf.Loader` with a list of values that implement the `conf.Source` or `conf.FlagSource` interface. The documentation for each of them in in the files bellow.\r\n\r\nOverall I believe this change is good because the implementation looks much cleaner, I was able to get rid of some code to cover special cases I had before, and add more tests.\r\n\r\nPlease take a look and let me know if you have any concerns.","created_at":"2017-01-14T00:32:36Z","updated_at":"2017-01-14T01:42:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7b4ed4d52c3b48b1be9c53bcd1fc40ac10d141b8","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/segmentio/conf/pulls/5/commits","review_comments_url":"https://api.github.com/repos/segmentio/conf/pulls/5/comments","review_comment_url":"https://api.github.com/repos/segmentio/conf/pulls/comments{/number}","comments_url":"https://api.github.com/repos/segmentio/conf/issues/5/comments","statuses_url":"https://api.github.com/repos/segmentio/conf/statuses/a9ec6e23d3a326d8528fec493436f76f4c838738","head":{"label":"segmentio:sources","ref":"sources","sha":"a9ec6e23d3a326d8528fec493436f76f4c838738","user":{"login":"segmentio","id":819518,"avatar_url":"https://avatars.githubusercontent.com/u/819518?v=3","gravatar_id":"","url":"https://api.github.com/users/segmentio","html_url":"https://github.com/segmentio","followers_url":"https://api.github.com/users/segmentio/followers","following_url":"https://api.github.com/users/segmentio/following{/other_user}","gists_url":"https://api.github.com/users/segmentio/gists{/gist_id}","starred_url":"https://api.github.com/users/segmentio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/segmentio/subscriptions","organizations_url":"https://api.github.com/users/segmentio/orgs","repos_url":"https://api.github.com/users/segmentio/repos","events_url":"https://api.github.com/users/segmentio/events{/privacy}","received_events_url":"https://api.github.com/users/segmentio/received_events","type":"Organization","site_admin":false},"repo":{"id":75683617,"name":"conf","full_name":"segmentio/conf","owner":{"login":"segmentio","id":819518,"avatar_url":"https://avatars.githubusercontent.com/u/819518?v=3","gravatar_id":"","url":"https://api.github.com/users/segmentio","html_url":"https://github.com/segmentio","followers_url":"https://api.github.com/users/segmentio/followers","following_url":"https://api.github.com/users/segmentio/following{/other_user}","gists_url":"https://api.github.com/users/segmentio/gists{/gist_id}","starred_url":"https://api.github.com/users/segmentio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/segmentio/subscriptions","organizations_url":"https://api.github.com/users/segmentio/orgs","repos_url":"https://api.github.com/users/segmentio/repos","events_url":"https://api.github.com/users/segmentio/events{/privacy}","received_events_url":"https://api.github.com/users/segmentio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/segmentio/conf","description":"Go package for loading program configuration from multiple sources.","fork":false,"url":"https://api.github.com/repos/segmentio/conf","forks_url":"https://api.github.com/repos/segmentio/conf/forks","keys_url":"https://api.github.com/repos/segmentio/conf/keys{/key_id}","collaborators_url":"https://api.github.com/repos/segmentio/conf/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/segmentio/conf/teams","hooks_url":"https://api.github.com/repos/segmentio/conf/hooks","issue_events_url":"https://api.github.com/repos/segmentio/conf/issues/events{/number}","events_url":"https://api.github.com/repos/segmentio/conf/events","assignees_url":"https://api.github.com/repos/segmentio/conf/assignees{/user}","branches_url":"https://api.github.com/repos/segmentio/conf/branches{/branch}","tags_url":"https://api.github.com/repos/segmentio/conf/tags","blobs_url":"https://api.github.com/repos/segmentio/conf/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/segmentio/conf/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/segmentio/conf/git/refs{/sha}","trees_url":"https://api.github.com/repos/segmentio/conf/git/trees{/sha}","statuses_url":"https://api.github.com/repos/segmentio/conf/statuses/{sha}","languages_url":"https://api.github.com/repos/segmentio/conf/languages","stargazers_url":"https://api.github.com/repos/segmentio/conf/stargazers","contributors_url":"https://api.github.com/repos/segmentio/conf/contributors","subscribers_url":"https://api.github.com/repos/segmentio/conf/subscribers","subscription_url":"https://api.github.com/repos/segmentio/conf/subscription","commits_url":"https://api.github.com/repos/segmentio/conf/commits{/sha}","git_commits_url":"https://api.github.com/repos/segmentio/conf/git/commits{/sha}","comments_url":"https://api.github.com/repos/segmentio/conf/comments{/number}","issue_comment_url":"https://api.github.com/repos/segmentio/conf/issues/comments{/number}","contents_url":"https://api.github.com/repos/segmentio/conf/contents/{+path}","compare_url":"https://api.github.com/repos/segmentio/conf/compare/{base}...{head}","merges_url":"https://api.github.com/repos/segmentio/conf/merges","archive_url":"https://api.github.com/repos/segmentio/conf/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/segmentio/conf/downloads","issues_url":"https://api.github.com/repos/segmentio/conf/issues{/number}","pulls_url":"https://api.github.com/repos/segmentio/conf/pulls{/number}","milestones_url":"https://api.github.com/repos/segmentio/conf/milestones{/number}","notifications_url":"https://api.github.com/repos/segmentio/conf/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/segmentio/conf/labels{/name}","releases_url":"https://api.github.com/repos/segmentio/conf/releases{/id}","deployments_url":"https://api.github.com/repos/segmentio/conf/deployments","created_at":"2016-12-06T01:49:22Z","updated_at":"2017-01-12T01:21:53Z","pushed_at":"2017-01-14T00:32:36Z","git_url":"git://github.com/segmentio/conf.git","ssh_url":"git@github.com:segmentio/conf.git","clone_url":"https://github.com/segmentio/conf.git","svn_url":"https://github.com/segmentio/conf","homepage":null,"size":58,"stargazers_count":3,"watchers_count":3,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":3,"default_branch":"master"}},"base":{"label":"segmentio:master","ref":"master","sha":"99fdde50d74d2db7aec946ed55677304ff041cbb","user":{"login":"segmentio","id":819518,"avatar_url":"https://avatars.githubusercontent.com/u/819518?v=3","gravatar_id":"","url":"https://api.github.com/users/segmentio","html_url":"https://github.com/segmentio","followers_url":"https://api.github.com/users/segmentio/followers","following_url":"https://api.github.com/users/segmentio/following{/other_user}","gists_url":"https://api.github.com/users/segmentio/gists{/gist_id}","starred_url":"https://api.github.com/users/segmentio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/segmentio/subscriptions","organizations_url":"https://api.github.com/users/segmentio/orgs","repos_url":"https://api.github.com/users/segmentio/repos","events_url":"https://api.github.com/users/segmentio/events{/privacy}","received_events_url":"https://api.github.com/users/segmentio/received_events","type":"Organization","site_admin":false},"repo":{"id":75683617,"name":"conf","full_name":"segmentio/conf","owner":{"login":"segmentio","id":819518,"avatar_url":"https://avatars.githubusercontent.com/u/819518?v=3","gravatar_id":"","url":"https://api.github.com/users/segmentio","html_url":"https://github.com/segmentio","followers_url":"https://api.github.com/users/segmentio/followers","following_url":"https://api.github.com/users/segmentio/following{/other_user}","gists_url":"https://api.github.com/users/segmentio/gists{/gist_id}","starred_url":"https://api.github.com/users/segmentio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/segmentio/subscriptions","organizations_url":"https://api.github.com/users/segmentio/orgs","repos_url":"https://api.github.com/users/segmentio/repos","events_url":"https://api.github.com/users/segmentio/events{/privacy}","received_events_url":"https://api.github.com/users/segmentio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/segmentio/conf","description":"Go package for loading program configuration from multiple sources.","fork":false,"url":"https://api.github.com/repos/segmentio/conf","forks_url":"https://api.github.com/repos/segmentio/conf/forks","keys_url":"https://api.github.com/repos/segmentio/conf/keys{/key_id}","collaborators_url":"https://api.github.com/repos/segmentio/conf/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/segmentio/conf/teams","hooks_url":"https://api.github.com/repos/segmentio/conf/hooks","issue_events_url":"https://api.github.com/repos/segmentio/conf/issues/events{/number}","events_url":"https://api.github.com/repos/segmentio/conf/events","assignees_url":"https://api.github.com/repos/segmentio/conf/assignees{/user}","branches_url":"https://api.github.com/repos/segmentio/conf/branches{/branch}","tags_url":"https://api.github.com/repos/segmentio/conf/tags","blobs_url":"https://api.github.com/repos/segmentio/conf/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/segmentio/conf/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/segmentio/conf/git/refs{/sha}","trees_url":"https://api.github.com/repos/segmentio/conf/git/trees{/sha}","statuses_url":"https://api.github.com/repos/segmentio/conf/statuses/{sha}","languages_url":"https://api.github.com/repos/segmentio/conf/languages","stargazers_url":"https://api.github.com/repos/segmentio/conf/stargazers","contributors_url":"https://api.github.com/repos/segmentio/conf/contributors","subscribers_url":"https://api.github.com/repos/segmentio/conf/subscribers","subscription_url":"https://api.github.com/repos/segmentio/conf/subscription","commits_url":"https://api.github.com/repos/segmentio/conf/commits{/sha}","git_commits_url":"https://api.github.com/repos/segmentio/conf/git/commits{/sha}","comments_url":"https://api.github.com/repos/segmentio/conf/comments{/number}","issue_comment_url":"https://api.github.com/repos/segmentio/conf/issues/comments{/number}","contents_url":"https://api.github.com/repos/segmentio/conf/contents/{+path}","compare_url":"https://api.github.com/repos/segmentio/conf/compare/{base}...{head}","merges_url":"https://api.github.com/repos/segmentio/conf/merges","archive_url":"https://api.github.com/repos/segmentio/conf/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/segmentio/conf/downloads","issues_url":"https://api.github.com/repos/segmentio/conf/issues{/number}","pulls_url":"https://api.github.com/repos/segmentio/conf/pulls{/number}","milestones_url":"https://api.github.com/repos/segmentio/conf/milestones{/number}","notifications_url":"https://api.github.com/repos/segmentio/conf/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/segmentio/conf/labels{/name}","releases_url":"https://api.github.com/repos/segmentio/conf/releases{/id}","deployments_url":"https://api.github.com/repos/segmentio/conf/deployments","created_at":"2016-12-06T01:49:22Z","updated_at":"2017-01-12T01:21:53Z","pushed_at":"2017-01-14T00:32:36Z","git_url":"git://github.com/segmentio/conf.git","ssh_url":"git@github.com:segmentio/conf.git","clone_url":"https://github.com/segmentio/conf.git","svn_url":"https://github.com/segmentio/conf","homepage":null,"size":58,"stargazers_count":3,"watchers_count":3,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/segmentio/conf/pulls/5"},"html":{"href":"https://github.com/segmentio/conf/pull/5"},"issue":{"href":"https://api.github.com/repos/segmentio/conf/issues/5"},"comments":{"href":"https://api.github.com/repos/segmentio/conf/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/segmentio/conf/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/segmentio/conf/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/segmentio/conf/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/segmentio/conf/statuses/a9ec6e23d3a326d8528fec493436f76f4c838738"}}}}
{"actor":{"display_login":"achille-roussel"}}