class Murk::Model::Template

Attributes

filename[R]

Public Class Methods

new(filename) click to toggle source
# File lib/murk/model/template.rb, line 13
def initialize(filename)
  @filename = filename
end

Public Instance Methods

body() click to toggle source
# File lib/murk/model/template.rb, line 21
def body
  File.read(path)
end
parameter?(parameter_key) click to toggle source
# File lib/murk/model/template.rb, line 29
def parameter?(parameter_key)
  parameters.any? { |param| param.parameter_key == parameter_key.to_s }
end
parameters() click to toggle source
# File lib/murk/model/template.rb, line 25
def parameters
  validate.parameters
end
path() click to toggle source
# File lib/murk/model/template.rb, line 17
def path
  @path ||= resolve_path(@filename)
end

Private Instance Methods

resolve_path(filename) click to toggle source
# File lib/murk/model/template.rb, line 35
def resolve_path(filename)
  template_paths = Murk.options[:template_path].split(':')
  template_paths.each do |path|
    real_path = File.absolute_path(path, Murk.config_dir)
    if File.exist?(File.join(real_path, filename))
      return File.join(real_path, filename)
    end
  end
  fail TemplateError, "Template '#{filename}' not found in path #{Murk.options[:template_path]}"
end
validate() click to toggle source
# File lib/murk/model/template.rb, line 46
def validate
  @validate_output ||= cloudformation.validate_template(template_body: body)
rescue Aws::CloudFormation::Errors::ValidationError
  raise TemplateError, "Failed to validate template at #{path}"
end