{"action":"created","comment":{"url":"https://api.github.com/repos/conjurinc/summon/pulls/comments/66106617","id":66106617,"diff_hunk":"@@ -102,6 +102,25 @@ the secrets stored in temp files and in the Python process environment are gone.\n \n     This flag can be useful for when you have secrets that you don't need access to for development. For example API keys for monitoring tools. This flag can be used multiple times.\n \n+* `-e, --environment` Specify section (environment) to parse from secret YAML\n+\n+    This flag specifies which specific environment/section to parse from the secrets YAML file (or string). In addition, it will also enable the usage of a `common` section which will be inherited by other sections/environments. In other words, if your `secrets.yaml` looks something like this:\n+\n+```yaml\n+common:\n+  DB_USER: db-user\n+  DB_NAME: db-name\n+  DB_HOST: db-host.example.com\n+\n+staging:\n+  DB_PASS: some_password","path":"README.md","position":15,"original_position":15,"commit_id":"eb86e9d6a046f3836def36508414812e63bc7448","original_commit_id":"eb86e9d6a046f3836def36508414812e63bc7448","user":{"login":"dividedmind","id":823636,"avatar_url":"https://avatars.githubusercontent.com/u/823636?v=3","gravatar_id":"","url":"https://api.github.com/users/dividedmind","html_url":"https://github.com/dividedmind","followers_url":"https://api.github.com/users/dividedmind/followers","following_url":"https://api.github.com/users/dividedmind/following{/other_user}","gists_url":"https://api.github.com/users/dividedmind/gists{/gist_id}","starred_url":"https://api.github.com/users/dividedmind/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dividedmind/subscriptions","organizations_url":"https://api.github.com/users/dividedmind/orgs","repos_url":"https://api.github.com/users/dividedmind/repos","events_url":"https://api.github.com/users/dividedmind/events{/privacy}","received_events_url":"https://api.github.com/users/dividedmind/received_events","type":"User","site_admin":false},"body":"For the sake of the example being more educational, this should perhaps be a !var.","created_at":"2016-06-07T16:37:59Z","updated_at":"2016-06-07T16:37:59Z","html_url":"https://github.com/conjurinc/summon/pull/29#discussion_r66106617","pull_request_url":"https://api.github.com/repos/conjurinc/summon/pulls/29","_links":{"self":{"href":"https://api.github.com/repos/conjurinc/summon/pulls/comments/66106617"},"html":{"href":"https://github.com/conjurinc/summon/pull/29#discussion_r66106617"},"pull_request":{"href":"https://api.github.com/repos/conjurinc/summon/pulls/29"}}},"pull_request":{"url":"https://api.github.com/repos/conjurinc/summon/pulls/29","id":72773307,"html_url":"https://github.com/conjurinc/summon/pull/29","diff_url":"https://github.com/conjurinc/summon/pull/29.diff","patch_url":"https://github.com/conjurinc/summon/pull/29.patch","issue_url":"https://api.github.com/repos/conjurinc/summon/issues/29","number":29,"state":"open","locked":false,"title":"Environment support","user":{"login":"dselans","id":1938759,"avatar_url":"https://avatars.githubusercontent.com/u/1938759?v=3","gravatar_id":"","url":"https://api.github.com/users/dselans","html_url":"https://github.com/dselans","followers_url":"https://api.github.com/users/dselans/followers","following_url":"https://api.github.com/users/dselans/following{/other_user}","gists_url":"https://api.github.com/users/dselans/gists{/gist_id}","starred_url":"https://api.github.com/users/dselans/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dselans/subscriptions","organizations_url":"https://api.github.com/users/dselans/orgs","repos_url":"https://api.github.com/users/dselans/repos","events_url":"https://api.github.com/users/dselans/events{/privacy}","received_events_url":"https://api.github.com/users/dselans/received_events","type":"User","site_admin":false},"body":"Hi there!\r\n\r\nThis PR introduces some new functionality:\r\n\r\n- It allows you to specify a `-e` or `--environment` flag to parse a specific section from the secrets YAML. If this section does not exist, `summon` will exit with 1 (as expected). Old functionality still remains - it is not _required_ to use the `environment` bit.\r\n- Added parsing of a `common` section from the YAML. Having a `common` section allows other sections to inherit env vars from it (primary sections will override env vars in `common). Unfortunately YAML's inheritance is more akin to a map merge, so we have to resort to our own merge-handling.\r\n- Expanded tests\r\n- Cleaned up runAction() signature as it was getting a bit unruly after adding 'env'; replaced the parameters with a single `ActionConfig` struct; besides looking a bit cleaner, it also has the benefit of being less guess work as to what each parameter means, both in tests and in-code).\r\n- Upped minor version\r\n- Forgot to expand README, will do that in a quick follow up commit\r\n\r\nSome other quick notes:\r\n\r\nTo avoid a slew of type assertions and various if/else blocks (due to the new map becoming `map[string]interface{}`, I opted to separate `parse()` into two additional functions: `parseRegular()` and `parseEnvironment`. I feel that this is a bit cleaner than expanding `parse()` to handle both cases - but please let me know if you don't like the approach.\r\n\r\nPlease let me know what you think!\r\n\r\ncc @jonDowdle","created_at":"2016-06-06T20:35:19Z","updated_at":"2016-06-07T16:37:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b03e4f1907be7cb270da986ccad1c7e8fa4d83b0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/conjurinc/summon/pulls/29/commits","review_comments_url":"https://api.github.com/repos/conjurinc/summon/pulls/29/comments","review_comment_url":"https://api.github.com/repos/conjurinc/summon/pulls/comments{/number}","comments_url":"https://api.github.com/repos/conjurinc/summon/issues/29/comments","statuses_url":"https://api.github.com/repos/conjurinc/summon/statuses/eb86e9d6a046f3836def36508414812e63bc7448","head":{"label":"dselans:environment-support","ref":"environment-support","sha":"eb86e9d6a046f3836def36508414812e63bc7448","user":{"login":"dselans","id":1938759,"avatar_url":"https://avatars.githubusercontent.com/u/1938759?v=3","gravatar_id":"","url":"https://api.github.com/users/dselans","html_url":"https://github.com/dselans","followers_url":"https://api.github.com/users/dselans/followers","following_url":"https://api.github.com/users/dselans/following{/other_user}","gists_url":"https://api.github.com/users/dselans/gists{/gist_id}","starred_url":"https://api.github.com/users/dselans/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dselans/subscriptions","organizations_url":"https://api.github.com/users/dselans/orgs","repos_url":"https://api.github.com/users/dselans/repos","events_url":"https://api.github.com/users/dselans/events{/privacy}","received_events_url":"https://api.github.com/users/dselans/received_events","type":"User","site_admin":false},"repo":{"id":60545169,"name":"summon","full_name":"dselans/summon","owner":{"login":"dselans","id":1938759,"avatar_url":"https://avatars.githubusercontent.com/u/1938759?v=3","gravatar_id":"","url":"https://api.github.com/users/dselans","html_url":"https://github.com/dselans","followers_url":"https://api.github.com/users/dselans/followers","following_url":"https://api.github.com/users/dselans/following{/other_user}","gists_url":"https://api.github.com/users/dselans/gists{/gist_id}","starred_url":"https://api.github.com/users/dselans/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dselans/subscriptions","organizations_url":"https://api.github.com/users/dselans/orgs","repos_url":"https://api.github.com/users/dselans/repos","events_url":"https://api.github.com/users/dselans/events{/privacy}","received_events_url":"https://api.github.com/users/dselans/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dselans/summon","description":"A command-line tool to make working with secrets easier","fork":true,"url":"https://api.github.com/repos/dselans/summon","forks_url":"https://api.github.com/repos/dselans/summon/forks","keys_url":"https://api.github.com/repos/dselans/summon/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dselans/summon/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dselans/summon/teams","hooks_url":"https://api.github.com/repos/dselans/summon/hooks","issue_events_url":"https://api.github.com/repos/dselans/summon/issues/events{/number}","events_url":"https://api.github.com/repos/dselans/summon/events","assignees_url":"https://api.github.com/repos/dselans/summon/assignees{/user}","branches_url":"https://api.github.com/repos/dselans/summon/branches{/branch}","tags_url":"https://api.github.com/repos/dselans/summon/tags","blobs_url":"https://api.github.com/repos/dselans/summon/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dselans/summon/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dselans/summon/git/refs{/sha}","trees_url":"https://api.github.com/repos/dselans/summon/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dselans/summon/statuses/{sha}","languages_url":"https://api.github.com/repos/dselans/summon/languages","stargazers_url":"https://api.github.com/repos/dselans/summon/stargazers","contributors_url":"https://api.github.com/repos/dselans/summon/contributors","subscribers_url":"https://api.github.com/repos/dselans/summon/subscribers","subscription_url":"https://api.github.com/repos/dselans/summon/subscription","commits_url":"https://api.github.com/repos/dselans/summon/commits{/sha}","git_commits_url":"https://api.github.com/repos/dselans/summon/git/commits{/sha}","comments_url":"https://api.github.com/repos/dselans/summon/comments{/number}","issue_comment_url":"https://api.github.com/repos/dselans/summon/issues/comments{/number}","contents_url":"https://api.github.com/repos/dselans/summon/contents/{+path}","compare_url":"https://api.github.com/repos/dselans/summon/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dselans/summon/merges","archive_url":"https://api.github.com/repos/dselans/summon/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dselans/summon/downloads","issues_url":"https://api.github.com/repos/dselans/summon/issues{/number}","pulls_url":"https://api.github.com/repos/dselans/summon/pulls{/number}","milestones_url":"https://api.github.com/repos/dselans/summon/milestones{/number}","notifications_url":"https://api.github.com/repos/dselans/summon/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dselans/summon/labels{/name}","releases_url":"https://api.github.com/repos/dselans/summon/releases{/id}","deployments_url":"https://api.github.com/repos/dselans/summon/deployments","created_at":"2016-06-06T16:56:00Z","updated_at":"2016-06-06T16:56:01Z","pushed_at":"2016-06-06T20:43:53Z","git_url":"git://github.com/dselans/summon.git","ssh_url":"git@github.com:dselans/summon.git","clone_url":"https://github.com/dselans/summon.git","svn_url":"https://github.com/dselans/summon","homepage":"https://conjurinc.github.io/summon","size":1079,"stargazers_count":0,"watchers_count":0,"language":"Go","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":"conjurinc:master","ref":"master","sha":"de7114434dfda95550393b65122c22524ba38da2","user":{"login":"conjurinc","id":4996946,"avatar_url":"https://avatars.githubusercontent.com/u/4996946?v=3","gravatar_id":"","url":"https://api.github.com/users/conjurinc","html_url":"https://github.com/conjurinc","followers_url":"https://api.github.com/users/conjurinc/followers","following_url":"https://api.github.com/users/conjurinc/following{/other_user}","gists_url":"https://api.github.com/users/conjurinc/gists{/gist_id}","starred_url":"https://api.github.com/users/conjurinc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/conjurinc/subscriptions","organizations_url":"https://api.github.com/users/conjurinc/orgs","repos_url":"https://api.github.com/users/conjurinc/repos","events_url":"https://api.github.com/users/conjurinc/events{/privacy}","received_events_url":"https://api.github.com/users/conjurinc/received_events","type":"Organization","site_admin":false},"repo":{"id":35568823,"name":"summon","full_name":"conjurinc/summon","owner":{"login":"conjurinc","id":4996946,"avatar_url":"https://avatars.githubusercontent.com/u/4996946?v=3","gravatar_id":"","url":"https://api.github.com/users/conjurinc","html_url":"https://github.com/conjurinc","followers_url":"https://api.github.com/users/conjurinc/followers","following_url":"https://api.github.com/users/conjurinc/following{/other_user}","gists_url":"https://api.github.com/users/conjurinc/gists{/gist_id}","starred_url":"https://api.github.com/users/conjurinc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/conjurinc/subscriptions","organizations_url":"https://api.github.com/users/conjurinc/orgs","repos_url":"https://api.github.com/users/conjurinc/repos","events_url":"https://api.github.com/users/conjurinc/events{/privacy}","received_events_url":"https://api.github.com/users/conjurinc/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/conjurinc/summon","description":"A command-line tool to make working with secrets easier","fork":false,"url":"https://api.github.com/repos/conjurinc/summon","forks_url":"https://api.github.com/repos/conjurinc/summon/forks","keys_url":"https://api.github.com/repos/conjurinc/summon/keys{/key_id}","collaborators_url":"https://api.github.com/repos/conjurinc/summon/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/conjurinc/summon/teams","hooks_url":"https://api.github.com/repos/conjurinc/summon/hooks","issue_events_url":"https://api.github.com/repos/conjurinc/summon/issues/events{/number}","events_url":"https://api.github.com/repos/conjurinc/summon/events","assignees_url":"https://api.github.com/repos/conjurinc/summon/assignees{/user}","branches_url":"https://api.github.com/repos/conjurinc/summon/branches{/branch}","tags_url":"https://api.github.com/repos/conjurinc/summon/tags","blobs_url":"https://api.github.com/repos/conjurinc/summon/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/conjurinc/summon/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/conjurinc/summon/git/refs{/sha}","trees_url":"https://api.github.com/repos/conjurinc/summon/git/trees{/sha}","statuses_url":"https://api.github.com/repos/conjurinc/summon/statuses/{sha}","languages_url":"https://api.github.com/repos/conjurinc/summon/languages","stargazers_url":"https://api.github.com/repos/conjurinc/summon/stargazers","contributors_url":"https://api.github.com/repos/conjurinc/summon/contributors","subscribers_url":"https://api.github.com/repos/conjurinc/summon/subscribers","subscription_url":"https://api.github.com/repos/conjurinc/summon/subscription","commits_url":"https://api.github.com/repos/conjurinc/summon/commits{/sha}","git_commits_url":"https://api.github.com/repos/conjurinc/summon/git/commits{/sha}","comments_url":"https://api.github.com/repos/conjurinc/summon/comments{/number}","issue_comment_url":"https://api.github.com/repos/conjurinc/summon/issues/comments{/number}","contents_url":"https://api.github.com/repos/conjurinc/summon/contents/{+path}","compare_url":"https://api.github.com/repos/conjurinc/summon/compare/{base}...{head}","merges_url":"https://api.github.com/repos/conjurinc/summon/merges","archive_url":"https://api.github.com/repos/conjurinc/summon/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/conjurinc/summon/downloads","issues_url":"https://api.github.com/repos/conjurinc/summon/issues{/number}","pulls_url":"https://api.github.com/repos/conjurinc/summon/pulls{/number}","milestones_url":"https://api.github.com/repos/conjurinc/summon/milestones{/number}","notifications_url":"https://api.github.com/repos/conjurinc/summon/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/conjurinc/summon/labels{/name}","releases_url":"https://api.github.com/repos/conjurinc/summon/releases{/id}","deployments_url":"https://api.github.com/repos/conjurinc/summon/deployments","created_at":"2015-05-13T19:05:03Z","updated_at":"2016-05-30T13:39:10Z","pushed_at":"2016-06-06T20:43:54Z","git_url":"git://github.com/conjurinc/summon.git","ssh_url":"git@github.com:conjurinc/summon.git","clone_url":"https://github.com/conjurinc/summon.git","svn_url":"https://github.com/conjurinc/summon","homepage":"https://conjurinc.github.io/summon","size":1178,"stargazers_count":204,"watchers_count":204,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":5,"mirror_url":null,"open_issues_count":5,"forks":5,"open_issues":5,"watchers":204,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/conjurinc/summon/pulls/29"},"html":{"href":"https://github.com/conjurinc/summon/pull/29"},"issue":{"href":"https://api.github.com/repos/conjurinc/summon/issues/29"},"comments":{"href":"https://api.github.com/repos/conjurinc/summon/issues/29/comments"},"review_comments":{"href":"https://api.github.com/repos/conjurinc/summon/pulls/29/comments"},"review_comment":{"href":"https://api.github.com/repos/conjurinc/summon/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/conjurinc/summon/pulls/29/commits"},"statuses":{"href":"https://api.github.com/repos/conjurinc/summon/statuses/eb86e9d6a046f3836def36508414812e63bc7448"}}}}
{"actor":{"display_login":"dividedmind"}}