consul-template icon indicating copy to clipboard operation
consul-template copied to clipboard

Add check command for templates

Open alvaroaleman opened this issue 6 years ago • 5 comments

Hi, would it be possible to add a check command for rendered templates? I imagine something like

  • If check command is configured, render template first to a temporary location
  • Run check command with the temporary location as first argument
  • If the check command returns with rc 0, render the template to the destination
  • Otherwise log a warning and do not render the template to the destination

alvaroaleman avatar Jan 22 '18 11:01 alvaroaleman

Hi @alvaroaleman realized we need to update the README but consul-template has a "dry run" mode that will print the templates to stdout and check that they are properly formed:

  -dry
      Print generated templates to stdout instead of rendering

slackpad avatar Feb 02 '18 20:02 slackpad

Hey, thanks for the info, however it doesn't help for the actual use case: Testing the validity of a rendered template like conf does: check_cmd = "/usr/sbin/nginx -t -c {{.src}}"

alvaroaleman avatar Feb 02 '18 20:02 alvaroaleman

There may be several ways to work around this by rendering multiple templates, piping the dry run to stdout and validating that, or various other methods, but going to tag this as an enhancement as first-class support would be a new feature as described.

pearkes avatar Jul 31 '18 21:07 pearkes

Are there any plans to support this after 2 years?

ShimiTaNaka avatar Jul 01 '20 16:07 ShimiTaNaka

Hey @ShimiTaNaka,

I apologize for the lack of progress on the backlog, consul-template didn't have any dedicated resources when this was submitted and now that it does we're still catching up.

If you would like to see this implemented please consider adding a :+1: to the original issue as we use those to gauge community priorities.

eikenb avatar Jul 01 '20 18:07 eikenb