lukasjarosch / skipper

Inventory based templated configuration library inspired by the kapitan project
https://lukasjarosch.github.io/skipper/
MIT License
11 stars 3 forks source link

More precise error message for undefined template variables #60

Open SimonDreher opened 1 year ago

SimonDreher commented 1 year ago

Is your feature request related to a problem? Please describe. If I reference an undeclared variable in my template, the error message is like template 'example.filef' uses variables with undefined value on line 36 (line number is based on the rendered output and might not be accurate).

The line number is partially helpful, since it is only roughly in that line in the source file.

Describe the solution you'd like In many cases it would help me if the variable that is missing would be mentioned.

For example the error message could look like template 'example.filef' uses variable '.Inventory.foo.bar' with undefined value on line 36 (line number is based on the rendered output and might not be accurate)

lukasjarosch commented 1 year ago

I absolutely feel your pain, but this might be a tricky one. The way it is currently handled is that the template package will replace any undefined variable with <no value>. The undefined value detection leverages that behaviour to detect that there is some undefined variable, but not which one.

I'll try to figure out a viable solution for this :smiley: