veracross / consult

Configuration and secrets management for Rails
MIT License
12 stars 0 forks source link

Allow rendering templates that contain consul/vault template helpers even when consul/vault can't be reached #18

Open aharpervc opened 6 years ago

aharpervc commented 6 years ago

Given a template file that references consul or vault key paths for staging or production, but not development, I would still like this template file to be rendered for disconnected local development.

Currently, you'll get an unhandled exception when the relevant template helper is called. For example, I would like this to work fine in development:


development:
  username: fake
  password: hardcoded

production:
  <% with secret "secret/data/database_credentials" do |s| %>
  username: <%= s.data.dig(:data, :username) %>
  password: <%= s.data.dig(:data, :password) %>
  <% end %>

https://github.com/veracross/consult/blob/9354c09b51cb7397ae1dfc08858572e040f19ff7/lib/consult/template_functions.rb#L12-L14

Perhaps this could be done with an env-specific consult.yml config option that says "allow render on fail", which would be falsey by default but that you could set to true for development, if you wanted.

sixfeetover commented 5 years ago

You can do this by separating these into multiple files, and configuring consult.yml to render the appropriate file for your environment.

aharpervc commented 4 years ago

Yes, but that adds an administrative burden of managing multiple templates. I was thinking something along the lines of this might be useful:


development:
  username: fake
  password: hardcoded

production:
  <% with secret "secret/data/database_credentials", only: :production do |s| %>
  username: <%= s.data.dig(:data, :username) %>
  password: <%= s.data.dig(:data, :password) %>
  <% end %>