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

Add global -error-on-missing-key CLI argument #1434

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

imalsogreg
Copy link

@imalsogreg imalsogreg commented Dec 16, 2020

This addresses #1047 by adding a -error-on-missing-key CLI argument, which applies to all templates rendered in the current consult-template call, except for those that individually override it the template's configuration.

This allows a user to turn on missing-key error checking in situations where it is not convenient to write per-template configs, e.g. when we have many calls to consul-template that already use CLI arguments rather than config files to specify template source and target locations.

@hashicorp-cla
Copy link

hashicorp-cla commented Dec 16, 2020

CLA assistant check
All committers have signed the CLA.

@imalsogreg imalsogreg marked this pull request as ready for review December 17, 2020 17:50
@eikenb
Copy link
Contributor

eikenb commented Jan 5, 2021

Hey @imalsogreg, thanks for the PR.

I'm not sure about this as the idea was already turned down for pretty good reasons. I see that this attempts to work around those concerns by having it change the global default instead of being a global override, which makes sense. But I don't think it convinces me.

If I were to consider it, I'd want it reworked as I don't like adding arguments to Finalize. That call only deals with making sure things are internally good based on the current config... passing an arg changes the semantics and I already think the config semantics are overly complex.

Thinking about it some more I have a few lines of thought...

  1. I think consul-template has to many arguments now, and those are kind of all over the place.
  2. @jsok's solution in the comments of configuration parameter "error_on_missing_key" not available via cli #1047 has a certain appeal as it's more general (allows you to set any template specific options) and builds on a existing (already complex) argument instead of adding a new one.
  3. really seems to me that error_on_missing_key should default to "true" when using -once, but I'm loath to change that as it would certainly break something.

@imalsogreg
Copy link
Author

@eikenb Thanks for having a look!

What would your preference be, between

  1. Keep the current behavior
  2. Try to rework my global-default logic so that it doesn't add arguments to Finalize()
  3. Implement the in_tmpl:out_tmpl[:opts]:cmd suggestion from issue configuration parameter "error_on_missing_key" not available via cli #1047
  4. Change the behavior of -once to be strict (breaking old users)
  5. Add -once-strict

Totally understand if you don't want to add complexity to the config story here :)

@eikenb
Copy link
Contributor

eikenb commented Jan 6, 2021

A colleague pointed out #1420 which looks pretty similar to this in ways and has me leaning toward your 2nd option (rework w/o Finalize change). You could probably even find some ideas on how to work around the Finalize thing there.

I do have to say your 5th option does have a certain appeal. Maybe even changing -once to take an optional argument so -once is like now but -once=strict adds this. Not 100% on this but it seems to have some promise. I guess it'd depend on how easy that to thread through the logic to where it'd need to go.

Really threading through the logic is the hardest part given the current code organization. Whichever does that best would be my first choice... maybe compare what #1420 does vs. converting config.Once from a boolean to a enum-ish type and see which looks cleaner.

Thanks.

@toransahu
Copy link

toransahu commented Feb 28, 2023

@imalsogreg Thanks for the pull request. As a consumer of consul-template, I also want this to get merged. BTW, what has stopped this from getting merged?

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

4 participants