Allow rendering templates that contain consul/vault template helpers even when consul/vault can't be reached
aharpervc opened this issue · 2 comments
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 %>
consult/lib/consult/template_functions.rb
Lines 12 to 14 in 9354c09
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.
You can do this by separating these into multiple files, and configuring consult.yml
to render the appropriate file for your environment.
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 %>