Class: Lono::Template::ConfigsetInjector

Inherits:
AbstractBase show all
Defined in:
lib/lono/template/configset_injector.rb

Instance Method Summary collapse

Methods inherited from AbstractBase

#reinitialize

Methods included from Blueprint::Root

#find_blueprint_root, #set_blueprint_root

Constructor Details

#initialize(options = {}) ⇒ ConfigsetInjector

Returns a new instance of ConfigsetInjector.



3
4
5
# File 'lib/lono/template/configset_injector.rb', line 3

def initialize(options={})
  super
end

Instance Method Details

#injectObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/lono/template/configset_injector.rb', line 14

def inject
  .each do |logical_id, |
    resource = @cfn["Resources"][logical_id]

    unless resource
      puts "WARN: Resources.#{logical_id} not found in the template. Are you sure you are specifying the correct resource id in your configsets configs?".color(:yellow)
      next
    end

    resource["Metadata"] ||= ["Metadata"]

    # metdata = resource["Metadata"] ||= {}
    # metdata["AWS::CloudFormation::Init"] ||= {}
    # # The metadata_configset has been combined with the original AWS::CloudFormation::Init if it exists
    # metdata["AWS::CloudFormation::Init"] = metadata_configset["AWS::CloudFormation::Init"]
  end

  @cfn
end

#load_templateObject



44
45
46
# File 'lib/lono/template/configset_injector.rb', line 44

def load_template
  YAML.load_file(template_path)
end

#metadata_mapObject



34
35
36
37
# File 'lib/lono/template/configset_injector.rb', line 34

def 
  combiner = Lono::Configset::Combiner.new(@cfn, @options)
  combiner.
end

#runObject



7
8
9
10
11
12
# File 'lib/lono/template/configset_injector.rb', line 7

def run
  @cfn = load_template # initial
  @cfn = inject # overwrite
  write(@cfn)
  @cfn
end

#template_pathObject



48
49
50
# File 'lib/lono/template/configset_injector.rb', line 48

def template_path
  "#{Lono.config.output_path}/#{@blueprint}/templates/#{@template}.yml"
end

#write(cfn) ⇒ Object



40
41
42
# File 'lib/lono/template/configset_injector.rb', line 40

def write(cfn)
  IO.write(template_path, YAML.dump(cfn))
end