As a Chef cookbook developer,
I would like an easy way to validate the syntax of a cookbook’s ERB templates,
So that I can have a shorter feedback loop into whether or not my ERB templates are valid, therefore increasing my velocity and hopefully raising the confidence in the cookbook I am trying to deploy
Yes, I am aware of the command
erb -x -T '-' <filename> | ruby -c .. But what if my cookbook has 10s or 100s of ERB templates ?? Am I expected to run that command against each and everyone??
What I would really like is a command that allows me to ::
Test all of my cookbook’s ERB templates (<< would be awesome as part of a pipeline, just like `cookstyle`) OR
Test a specific cookbook ERB templates
For example ::
chef validate template << tests all ERB templates in a cookbook
chef validate template templates/hello.erb << tests a specific ERB template in a cookbook
I will leave it to the UX experts to decide what the interface should look like ..
I tested the
chef push command, and it does fail when there is an ERB syntax error .. So it appears a bad ERB cannot be uploaded to the Chef Server .. That said:
1) the error message is vague, even in debug mode
chef push dev -D
Uploading policy hello (a0d9d666e1) to policy group dev
[2019-10-04T10:04:49-04:00] FATAL: Erb template has a syntax error:
2) not all developers will have access to a usable Test Kitchen setup, meaning it would be the pipeline that catches these errors -- and in my humble opinion, that is already too late in the development process .. Again, goal is to shorten the feedback loop to increase the velocity of the Chef cookbook developer
3) what does validation look like in an Effortless world ?? Since I won't be using the
chef push command -- what will validate that all my templates are of correct syntax before I commit code ??
chef install will install the cookbook locally even if there is invalid syntax in one of my templates ..