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

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

Open
aharpervc opened this issue Oct 23, 2018 · 2 comments

Comments

@aharpervc
Copy link
Contributor

aharpervc commented Oct 23, 2018

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 %>

def secrets(path)
Vault.logical.list(path)
end

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.

@aharpervc aharpervc changed the title Allow rendering when consul/vault can't be reached Allow rendering templates that contain consul/vault template helpers even when consul/vault can't be reached Oct 23, 2018
@sixfeetover
Copy link
Member

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

@aharpervc
Copy link
Contributor Author

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 %>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants