{"action":"created","comment":{"url":"https://api.github.com/repos/onefinestay/nameko/pulls/comments/80080136","id":80080136,"diff_hunk":"@@ -19,9 +22,27 @@ def setup_parser():\n     return parser\n \n \n+def _replace_env_var(match):\n+    env_var, _, default = match.groups()","path":"nameko/cli/main.py","position":15,"original_position":15,"commit_id":"a8a038e0a545f339f9a0277aa493a93ab1a37b46","original_commit_id":"a8a038e0a545f339f9a0277aa493a93ab1a37b46","user":{"login":"mattbennett","id":107611,"avatar_url":"https://avatars.githubusercontent.com/u/107611?v=3","gravatar_id":"","url":"https://api.github.com/users/mattbennett","html_url":"https://github.com/mattbennett","followers_url":"https://api.github.com/users/mattbennett/followers","following_url":"https://api.github.com/users/mattbennett/following{/other_user}","gists_url":"https://api.github.com/users/mattbennett/gists{/gist_id}","starred_url":"https://api.github.com/users/mattbennett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattbennett/subscriptions","organizations_url":"https://api.github.com/users/mattbennett/orgs","repos_url":"https://api.github.com/users/mattbennett/repos","events_url":"https://api.github.com/users/mattbennett/events{/privacy}","received_events_url":"https://api.github.com/users/mattbennett/received_events","type":"User","site_admin":false},"body":"What's the second match here? Can't we have the regex discard it? ","created_at":"2016-09-22T16:23:14Z","updated_at":"2016-09-22T16:32:49Z","html_url":"https://github.com/onefinestay/nameko/pull/362#discussion_r80080136","pull_request_url":"https://api.github.com/repos/onefinestay/nameko/pulls/362","_links":{"self":{"href":"https://api.github.com/repos/onefinestay/nameko/pulls/comments/80080136"},"html":{"href":"https://github.com/onefinestay/nameko/pull/362#discussion_r80080136"},"pull_request":{"href":"https://api.github.com/repos/onefinestay/nameko/pulls/362"}}},"pull_request":{"url":"https://api.github.com/repos/onefinestay/nameko/pulls/362","id":85763180,"html_url":"https://github.com/onefinestay/nameko/pull/362","diff_url":"https://github.com/onefinestay/nameko/pull/362.diff","patch_url":"https://github.com/onefinestay/nameko/pull/362.patch","issue_url":"https://api.github.com/repos/onefinestay/nameko/issues/362","number":362,"state":"open","locked":false,"title":"Basic support for environment variables.","user":{"login":"kooba","id":243257,"avatar_url":"https://avatars.githubusercontent.com/u/243257?v=3","gravatar_id":"","url":"https://api.github.com/users/kooba","html_url":"https://github.com/kooba","followers_url":"https://api.github.com/users/kooba/followers","following_url":"https://api.github.com/users/kooba/following{/other_user}","gists_url":"https://api.github.com/users/kooba/gists{/gist_id}","starred_url":"https://api.github.com/users/kooba/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kooba/subscriptions","organizations_url":"https://api.github.com/users/kooba/orgs","repos_url":"https://api.github.com/users/kooba/repos","events_url":"https://api.github.com/users/kooba/events{/privacy}","received_events_url":"https://api.github.com/users/kooba/received_events","type":"User","site_admin":false},"body":"This PR adds basic support for environment variables in configuration file.\r\n\r\nAfter playing around with different regexes and yaml constructors I came to conclusion that basic (strings only) support for env vars in config file will cover 80% of use cases. \r\n\r\nIn https://github.com/onefinestay/nameko/issues/223 @fabiocerqueira mentioned it would be nice to add support for other data types but implementation was getting too hairy. If we really need to add support for that, the simplest way would be to process config file before loading it with `yaml` package. This could be easily accomplished by bringing in `jinja` templates and using their custom filters functionality. I didn't feel bringing-in dependency like that would be justified for this functionality. \r\n\r\nAdditionally looking around I didn't see many project providing such a support (https://docs.docker.com/compose/compose-file/#/variable-substitution) \r\n\r\nAll the logic is in `nameko.utils` and initialised in `nameko.cli.main` please let me know if that's desired. \r\n\r\nThere is a catch that if value is quoted, explicit `!env_var` resolver has to be used. Possibly should document that. https://github.com/onefinestay/nameko/pull/362/files#diff-85c7da7d97a696e8017da5742a876475R212\r\n\r\nI had regexes set on constants and added to `constants.py` byt at the end decided to add them inline. \r\n\r\n","created_at":"2016-09-19T09:43:31Z","updated_at":"2016-09-22T16:32:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7133cdf43f8bd9070af117fa6995f2884d97c9c3","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/onefinestay/nameko/pulls/362/commits","review_comments_url":"https://api.github.com/repos/onefinestay/nameko/pulls/362/comments","review_comment_url":"https://api.github.com/repos/onefinestay/nameko/pulls/comments{/number}","comments_url":"https://api.github.com/repos/onefinestay/nameko/issues/362/comments","statuses_url":"https://api.github.com/repos/onefinestay/nameko/statuses/a8a038e0a545f339f9a0277aa493a93ab1a37b46","head":{"label":"kooba:env_var_configs","ref":"env_var_configs","sha":"a8a038e0a545f339f9a0277aa493a93ab1a37b46","user":{"login":"kooba","id":243257,"avatar_url":"https://avatars.githubusercontent.com/u/243257?v=3","gravatar_id":"","url":"https://api.github.com/users/kooba","html_url":"https://github.com/kooba","followers_url":"https://api.github.com/users/kooba/followers","following_url":"https://api.github.com/users/kooba/following{/other_user}","gists_url":"https://api.github.com/users/kooba/gists{/gist_id}","starred_url":"https://api.github.com/users/kooba/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kooba/subscriptions","organizations_url":"https://api.github.com/users/kooba/orgs","repos_url":"https://api.github.com/users/kooba/repos","events_url":"https://api.github.com/users/kooba/events{/privacy}","received_events_url":"https://api.github.com/users/kooba/received_events","type":"User","site_admin":false},"repo":{"id":40251480,"name":"nameko","full_name":"kooba/nameko","owner":{"login":"kooba","id":243257,"avatar_url":"https://avatars.githubusercontent.com/u/243257?v=3","gravatar_id":"","url":"https://api.github.com/users/kooba","html_url":"https://github.com/kooba","followers_url":"https://api.github.com/users/kooba/followers","following_url":"https://api.github.com/users/kooba/following{/other_user}","gists_url":"https://api.github.com/users/kooba/gists{/gist_id}","starred_url":"https://api.github.com/users/kooba/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kooba/subscriptions","organizations_url":"https://api.github.com/users/kooba/orgs","repos_url":"https://api.github.com/users/kooba/repos","events_url":"https://api.github.com/users/kooba/events{/privacy}","received_events_url":"https://api.github.com/users/kooba/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kooba/nameko","description":"Python framework for building microservices","fork":true,"url":"https://api.github.com/repos/kooba/nameko","forks_url":"https://api.github.com/repos/kooba/nameko/forks","keys_url":"https://api.github.com/repos/kooba/nameko/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kooba/nameko/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kooba/nameko/teams","hooks_url":"https://api.github.com/repos/kooba/nameko/hooks","issue_events_url":"https://api.github.com/repos/kooba/nameko/issues/events{/number}","events_url":"https://api.github.com/repos/kooba/nameko/events","assignees_url":"https://api.github.com/repos/kooba/nameko/assignees{/user}","branches_url":"https://api.github.com/repos/kooba/nameko/branches{/branch}","tags_url":"https://api.github.com/repos/kooba/nameko/tags","blobs_url":"https://api.github.com/repos/kooba/nameko/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kooba/nameko/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kooba/nameko/git/refs{/sha}","trees_url":"https://api.github.com/repos/kooba/nameko/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kooba/nameko/statuses/{sha}","languages_url":"https://api.github.com/repos/kooba/nameko/languages","stargazers_url":"https://api.github.com/repos/kooba/nameko/stargazers","contributors_url":"https://api.github.com/repos/kooba/nameko/contributors","subscribers_url":"https://api.github.com/repos/kooba/nameko/subscribers","subscription_url":"https://api.github.com/repos/kooba/nameko/subscription","commits_url":"https://api.github.com/repos/kooba/nameko/commits{/sha}","git_commits_url":"https://api.github.com/repos/kooba/nameko/git/commits{/sha}","comments_url":"https://api.github.com/repos/kooba/nameko/comments{/number}","issue_comment_url":"https://api.github.com/repos/kooba/nameko/issues/comments{/number}","contents_url":"https://api.github.com/repos/kooba/nameko/contents/{+path}","compare_url":"https://api.github.com/repos/kooba/nameko/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kooba/nameko/merges","archive_url":"https://api.github.com/repos/kooba/nameko/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kooba/nameko/downloads","issues_url":"https://api.github.com/repos/kooba/nameko/issues{/number}","pulls_url":"https://api.github.com/repos/kooba/nameko/pulls{/number}","milestones_url":"https://api.github.com/repos/kooba/nameko/milestones{/number}","notifications_url":"https://api.github.com/repos/kooba/nameko/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kooba/nameko/labels{/name}","releases_url":"https://api.github.com/repos/kooba/nameko/releases{/id}","deployments_url":"https://api.github.com/repos/kooba/nameko/deployments","created_at":"2015-08-05T14:55:46Z","updated_at":"2016-07-18T08:15:30Z","pushed_at":"2016-09-19T17:19:09Z","git_url":"git://github.com/kooba/nameko.git","ssh_url":"git@github.com:kooba/nameko.git","clone_url":"https://github.com/kooba/nameko.git","svn_url":"https://github.com/kooba/nameko","homepage":"https://nameko.readthedocs.org","size":2353,"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":"onefinestay:master","ref":"master","sha":"b8d469c78cd9d381da8dd4bd8076f572f4faba6f","user":{"login":"onefinestay","id":634153,"avatar_url":"https://avatars.githubusercontent.com/u/634153?v=3","gravatar_id":"","url":"https://api.github.com/users/onefinestay","html_url":"https://github.com/onefinestay","followers_url":"https://api.github.com/users/onefinestay/followers","following_url":"https://api.github.com/users/onefinestay/following{/other_user}","gists_url":"https://api.github.com/users/onefinestay/gists{/gist_id}","starred_url":"https://api.github.com/users/onefinestay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/onefinestay/subscriptions","organizations_url":"https://api.github.com/users/onefinestay/orgs","repos_url":"https://api.github.com/users/onefinestay/repos","events_url":"https://api.github.com/users/onefinestay/events{/privacy}","received_events_url":"https://api.github.com/users/onefinestay/received_events","type":"Organization","site_admin":false},"repo":{"id":8431589,"name":"nameko","full_name":"onefinestay/nameko","owner":{"login":"onefinestay","id":634153,"avatar_url":"https://avatars.githubusercontent.com/u/634153?v=3","gravatar_id":"","url":"https://api.github.com/users/onefinestay","html_url":"https://github.com/onefinestay","followers_url":"https://api.github.com/users/onefinestay/followers","following_url":"https://api.github.com/users/onefinestay/following{/other_user}","gists_url":"https://api.github.com/users/onefinestay/gists{/gist_id}","starred_url":"https://api.github.com/users/onefinestay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/onefinestay/subscriptions","organizations_url":"https://api.github.com/users/onefinestay/orgs","repos_url":"https://api.github.com/users/onefinestay/repos","events_url":"https://api.github.com/users/onefinestay/events{/privacy}","received_events_url":"https://api.github.com/users/onefinestay/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/onefinestay/nameko","description":"Python framework for building microservices","fork":false,"url":"https://api.github.com/repos/onefinestay/nameko","forks_url":"https://api.github.com/repos/onefinestay/nameko/forks","keys_url":"https://api.github.com/repos/onefinestay/nameko/keys{/key_id}","collaborators_url":"https://api.github.com/repos/onefinestay/nameko/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/onefinestay/nameko/teams","hooks_url":"https://api.github.com/repos/onefinestay/nameko/hooks","issue_events_url":"https://api.github.com/repos/onefinestay/nameko/issues/events{/number}","events_url":"https://api.github.com/repos/onefinestay/nameko/events","assignees_url":"https://api.github.com/repos/onefinestay/nameko/assignees{/user}","branches_url":"https://api.github.com/repos/onefinestay/nameko/branches{/branch}","tags_url":"https://api.github.com/repos/onefinestay/nameko/tags","blobs_url":"https://api.github.com/repos/onefinestay/nameko/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/onefinestay/nameko/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/onefinestay/nameko/git/refs{/sha}","trees_url":"https://api.github.com/repos/onefinestay/nameko/git/trees{/sha}","statuses_url":"https://api.github.com/repos/onefinestay/nameko/statuses/{sha}","languages_url":"https://api.github.com/repos/onefinestay/nameko/languages","stargazers_url":"https://api.github.com/repos/onefinestay/nameko/stargazers","contributors_url":"https://api.github.com/repos/onefinestay/nameko/contributors","subscribers_url":"https://api.github.com/repos/onefinestay/nameko/subscribers","subscription_url":"https://api.github.com/repos/onefinestay/nameko/subscription","commits_url":"https://api.github.com/repos/onefinestay/nameko/commits{/sha}","git_commits_url":"https://api.github.com/repos/onefinestay/nameko/git/commits{/sha}","comments_url":"https://api.github.com/repos/onefinestay/nameko/comments{/number}","issue_comment_url":"https://api.github.com/repos/onefinestay/nameko/issues/comments{/number}","contents_url":"https://api.github.com/repos/onefinestay/nameko/contents/{+path}","compare_url":"https://api.github.com/repos/onefinestay/nameko/compare/{base}...{head}","merges_url":"https://api.github.com/repos/onefinestay/nameko/merges","archive_url":"https://api.github.com/repos/onefinestay/nameko/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/onefinestay/nameko/downloads","issues_url":"https://api.github.com/repos/onefinestay/nameko/issues{/number}","pulls_url":"https://api.github.com/repos/onefinestay/nameko/pulls{/number}","milestones_url":"https://api.github.com/repos/onefinestay/nameko/milestones{/number}","notifications_url":"https://api.github.com/repos/onefinestay/nameko/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/onefinestay/nameko/labels{/name}","releases_url":"https://api.github.com/repos/onefinestay/nameko/releases{/id}","deployments_url":"https://api.github.com/repos/onefinestay/nameko/deployments","created_at":"2013-02-26T11:59:08Z","updated_at":"2016-09-22T03:37:38Z","pushed_at":"2016-09-19T17:19:09Z","git_url":"git://github.com/onefinestay/nameko.git","ssh_url":"git@github.com:onefinestay/nameko.git","clone_url":"https://github.com/onefinestay/nameko.git","svn_url":"https://github.com/onefinestay/nameko","homepage":"https://nameko.readthedocs.org","size":3389,"stargazers_count":1026,"watchers_count":1026,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":84,"mirror_url":null,"open_issues_count":41,"forks":84,"open_issues":41,"watchers":1026,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/onefinestay/nameko/pulls/362"},"html":{"href":"https://github.com/onefinestay/nameko/pull/362"},"issue":{"href":"https://api.github.com/repos/onefinestay/nameko/issues/362"},"comments":{"href":"https://api.github.com/repos/onefinestay/nameko/issues/362/comments"},"review_comments":{"href":"https://api.github.com/repos/onefinestay/nameko/pulls/362/comments"},"review_comment":{"href":"https://api.github.com/repos/onefinestay/nameko/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/onefinestay/nameko/pulls/362/commits"},"statuses":{"href":"https://api.github.com/repos/onefinestay/nameko/statuses/a8a038e0a545f339f9a0277aa493a93ab1a37b46"}}}}
{"actor":{"display_login":"mattbennett"}}