Sha256: 2b4a4db07011fc4b7e391a9e39b7c0623755902bf15a10155b3f1b8e87790ccb

Contents?: true

Size: 972 Bytes

Versions: 2

Compression:

Stored size: 972 Bytes

Contents

require 'bora/stack'

class Bora
  class Template
    def initialize(template_name, template_config)
      @template_name = template_name
      @template_config = template_config
      @stacks = {}
      template_config['stacks'].each do |stack_name, stack_config|
        stack_name = "#{template_name}-#{stack_name}"
        stack_config = resolve_stack_config(template_config, stack_config)
        @stacks[stack_name] = Stack.new(stack_name, template_config['template_file'], stack_config)
      end
    end

    def stack(name)
      @stacks[name]
    end

    def stacks
      @stacks.values
    end

    def rake_tasks
      @stacks.each { |_, s| s.rake_tasks }
    end


    private

    def resolve_stack_config(template_config, stack_config)
      extract_cfn_options(template_config).merge(stack_config)
    end

    def extract_cfn_options(config)
      valid_options = ["capabilities"]
      config.select { |k| valid_options.include?(k) }
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bora-1.0.1 lib/bora/template.rb
bora-1.0.0 lib/bora/template.rb