Open mjallday opened 10 years ago
I think this was resolved with the template_content changes?
Ahh okay, I see what you were referencing. Time for an infodump:
So to render a template, Chef needs two bits of information: the template name and which cookbook the template is in (hereafter template source and template cookbook). For the template source, you either have to pass that when you create the resource instance, or optionally give a default_source when defining the resource. For the template cookbook you have four options (checked in order):
Most of the time we want to be using case 4, but there is a hitch. What 4 is actually computing is the cookbook of the thing that called attribute('', template: true, ...)
. This means that when you subclass ci_job
, it was still looking for templates in the ci
cookbook even though the new class is in balanced-ci
.
So how do we fix this? I just pushed a change to poise that should provide flexible enough semantics. In short the change is that if you define the same template_content attribute again in a subclass, it inherits the options from the original. This means that in balanced_ci_job
you can just add attribute('', template:true)
and that will leave the default_source
and default_options
from the base class intact, but reset the cookbook detected in case 4.
This has been a 2AM braindump. We now return you to your regularly scheduled programming.
@coderanger this is no longer an issue given https://github.com/balanced-cookbooks/jenkins/pull/2 rght?
how does chef know how to include templates?
if i change this line https://github.com/balanced-cookbooks/balanced-ci/blob/new-jobs/libraries/balanced_ci_job.rb#L16
to
source 'job-balanced.xml.erb'
i get the error