gruntwork-io / boilerplate

A tool for generating files and folders ("boilerplate") from a set of templates
https://www.gruntwork.io
Mozilla Public License 2.0
158 stars 12 forks source link

Do type checking after rendering variables #40

Closed brikis98 closed 6 years ago

brikis98 commented 6 years ago

In recent releases of boilerplate, I added support for using interpolations in variable values (e.g., default: "{{ .Foo }}"), but that had a bug in it where I was checking types before rendering a variable. So if you set a variable with type: bool to an interpolation such as "{{ eq .SomeValue 42}}", you would get an error that the value was of the wrong type.

It took a bit of refactoring (99% of the code changes are moving things into different packages to avoid circular dependencies), but the code should now check types after rendering, including coercing values to an expected type (e.g., coercing the string “true” to the bool value true) to make these sorts of interpolations work correctly.

brikis98 commented 6 years ago

Merging now. Feedback welcome!