Class: Bosh::Director::JobTemplateLoader

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

Instance Method Summary collapse

Instance Method Details

#process(job_template) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/bosh/director/job_template_loader.rb', line 7

def process(job_template)
  template_dir = extract_template(job_template)
  manifest = Psych.load_file(File.join(template_dir, 'job.MF'))

  monit_template = erb(File.join(template_dir, 'monit'))
  monit_template.filename = File.join(job_template.name, 'monit')

  templates = []

  manifest.fetch('templates', {}).each_pair do |src_name, dest_name|
    erb_file = erb(File.join(template_dir, 'templates', src_name))
    erb_file.filename = File.join(job_template.name, src_name)
    templates << SrcFileTemplate.new(src_name, dest_name, erb_file)
  end

  JobTemplateRenderer.new(job_template.name, monit_template, templates)
ensure
  FileUtils.rm_rf(template_dir) if template_dir
end