Class: Bosh::Director::Core::Templates::JobTemplateLoader
- Inherits:
-
Object
- Object
- Bosh::Director::Core::Templates::JobTemplateLoader
- Defined in:
- lib/bosh/director/core/templates/job_template_loader.rb
Instance Method Summary collapse
-
#initialize(logger) ⇒ JobTemplateLoader
constructor
A new instance of JobTemplateLoader.
- #process(job_template) ⇒ Object
Constructor Details
#initialize(logger) ⇒ JobTemplateLoader
Returns a new instance of JobTemplateLoader.
7 8 9 |
# File 'lib/bosh/director/core/templates/job_template_loader.rb', line 7 def initialize(logger) @logger = logger end |
Instance Method Details
#process(job_template) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/bosh/director/core/templates/job_template_loader.rb', line 11 def process(job_template) template_dir = extract_template(job_template) manifest = Psych.load_file(File.join(template_dir, 'job.MF')) monit_erb_file = File.read(File.join(template_dir, 'monit')) monit_source_erb = SourceErb.new('monit', 'monit', monit_erb_file, job_template.name) source_erbs = [] template_name = manifest.fetch('name', {}) manifest.fetch('templates', {}).each_pair do |src_name, dest_name| erb_file = File.read(File.join(template_dir, 'templates', src_name)) source_erbs << SourceErb.new(src_name, dest_name, erb_file, job_template.name) end JobTemplateRenderer.new(job_template.name, template_name, monit_source_erb, source_erbs, @logger) ensure FileUtils.rm_rf(template_dir) if template_dir end |