Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added an example to show how common secrets can be shared across multiple environments in secrets.yml #19898

Merged
merged 1 commit into from Oct 20, 2015

Conversation

prathamesh-sonpatki
Copy link
Member

  • Earlier, if there were common configurations under all environments then
    they had to be duplicated under each environment in
    config/secrets.yml.
  • This commit adds a way to specify them under common key such that
    they will be loaded in all environments.
  • Environment specific configurations will override the common configurations if they
    are present under both sections.

Edit

Common secrets is a bit confusing here. I meant to say common configuration options or settings like lets say default_from_email_address. It can be support@example.com in development, test and in production can be something else.

@vipulnsward
Copy link
Member

👍
We use this all the time to share common configurations.

@simi
Copy link
Contributor

simi commented Apr 25, 2015

What about to add this to all YAML configurations? For example to ActiveRecord's database.yml.

@mechanicles
Copy link
Contributor

👍

@prathamesh-sonpatki
Copy link
Member Author

@simi Good point. I think if we agree to add it for secrets.yml then we can also add it for other files.

@matthewd
Copy link
Member

What does this offer over using YAML's built-in anchor/reference syntax?

@prathamesh-sonpatki
Copy link
Member Author

@matthewd You are right. Same functionality can be achieved using YAML's anchor/reference syntax. This is just another way to do it.

@egilburg
Copy link
Contributor

I'm concerned that providing documented application API to do so would encourage this practice which IMO is an anti-pattern (at least as far as presenting it to new users go), as secrets by their nature are best not to reuse across environments, especially in the most common case of production vs non-production.

For someone who went beyond the basics and has a bona fide use case for this (for example, multiple production envs who need to share secret for communicating with each other), as mentioned in comments, this could be done manually using .yaml reference syntax.

@prathamesh-sonpatki prathamesh-sonpatki changed the title Added a way to group common secrets at one place in secrets.yml Added a way to group common configurations/settings at one place in secrets.yml Apr 25, 2015
@senny
Copy link
Member

senny commented Apr 26, 2015

We use the YAML reference syntax already in our database.yml templates. We should keep using that instead of introducing a new concept. To make it easier to use that pattern, we could prepare the template accordingly.

@prathamesh-sonpatki
Copy link
Member Author

@senny I agree. What do you mean by To make it easier to use that pattern, we could prepare the template accordingly.

@vipulnsward
Copy link
Member

Add an example for YAML linking in default file generated.

On Sunday, April 26, 2015, प्रथमेश notifications@github.com wrote:

@senny https://github.com/senny I agree. What do you mean by To make it
easier to use that pattern, we could prepare the template accordingly.


Reply to this email directly or view it on GitHub
#19898 (comment).

Vipul A.M.
+91-8149-204995

@prathamesh-sonpatki
Copy link
Member Author

@senny Updated the PR. The only issue I think is development and test environments will have same secret_key_base. Or should we add a commented example for showing how secrets can be shared?

@senny
Copy link
Member

senny commented May 5, 2015

@prathamesh-sonpatki better add a commented example. I don't think development and test should share their secret.

@prathamesh-sonpatki
Copy link
Member Author

@senny Updated. Please check.

@prathamesh-sonpatki
Copy link
Member Author

@senny What do you think about this?

@senny
Copy link
Member

senny commented May 13, 2015

@prathamesh-sonpatki it's on my list. Please don't make ping comments continuously. We get enough emails as is.

@senny
Copy link
Member

senny commented May 26, 2015

Looking at the example I don't think we should promote that in the file itself. What about only including the sentence:

# You can also share common secrets in multiple environments
# using YAML anchor/reference syntax.

Followed by a link to find more details.

@prathamesh-sonpatki
Copy link
Member Author

Can we update the example to use api_url instead of api_secret? I like the idea of adding a link to actual docs also but would be good to have a example like we have in database.yml.

@senny
Copy link
Member

senny commented May 26, 2015

In my projects I rarely find myself in the situation of sharing secrets with development and test environment.

Let's wait for more feedback before we decide.

/cc @sgrif @carlosantoniodasilva @rafaelfranca @chancancode

@prathamesh-sonpatki
Copy link
Member Author

Ok. Here is an example of secrets.yml sharing settings - https://github.com/bigbinary/wheel/blob/master/config/secrets.yml.

Then all the initializers access these values throguh Rails.application.secrets.

@senny
Copy link
Member

senny commented May 26, 2015

Yes, putting the ENV[] in the shared group certainly makes more sense.

@prathamesh-sonpatki
Copy link
Member Author

I have updated the example to use ENV variables.

@prathamesh-sonpatki prathamesh-sonpatki changed the title Added a way to group common configurations/settings at one place in secrets.yml Added an example to show how common secrets can be shared across multiple environments in secrets.yml May 26, 2015
@arthurnn arthurnn added the docs label Jun 15, 2015
sgrif added a commit that referenced this pull request Oct 20, 2015
 Added an example to show how common secrets can be shared across multiple environments in secrets.yml [ci skip]
@sgrif sgrif merged commit 6ae515d into rails:master Oct 20, 2015
@sgrif
Copy link
Contributor

sgrif commented Oct 20, 2015

This broke the build as the ERB is still interpolated, even though it's inside of a comment. Please re-open once you fix

@prathamesh-sonpatki prathamesh-sonpatki deleted the common-secrets branch July 21, 2016 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants