Class: Bosh::Director::JobTemplateRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/bosh/director/job_template_renderer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, monit_template, templates) ⇒ JobTemplateRenderer

Returns a new instance of JobTemplateRenderer.



9
10
11
12
13
14
# File 'lib/bosh/director/job_template_renderer.rb', line 9

def initialize(name, monit_template, templates)
  @name = name
  @monit_template = monit_template
  @templates = templates
  @logger = Config.logger
end

Instance Attribute Details

#monit_templateObject (readonly)

Returns the value of attribute monit_template.



7
8
9
# File 'lib/bosh/director/job_template_renderer.rb', line 7

def monit_template
  @monit_template
end

#templatesObject (readonly)

Returns the value of attribute templates.



7
8
9
# File 'lib/bosh/director/job_template_renderer.rb', line 7

def templates
  @templates
end

Instance Method Details

#render(job_name, instance) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/bosh/director/job_template_renderer.rb', line 16

def render(job_name, instance)
  template_context = Bosh::Common::TemplateEvaluationContext.new(instance.spec)

  monit = render_erb(job_name, monit_template, template_context, instance.index)

  rendered_templates = templates.map do |template_file|
    file_contents = render_erb(job_name, template_file.erb_file, template_context, instance.index)
    RenderedFileTemplate.new(template_file.src_name, template_file.dest_name, file_contents)
  end

  RenderedJobTemplate.new(name, monit, rendered_templates)
end