Method: CfnFlow::CLI#validate

Defined in:
lib/cfn_flow/cli.rb

#validate(*templates) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/cfn_flow/cli.rb', line 12

def validate(*templates)

  if templates.empty?
    raise Thor::RequiredArgumentMissingError.new('You must specify a template to validate')
  end

  templates.map{|path| Template.new(path) }.each do |template|
    say "Validating #{template.local_path}... "
    template.validate!
    say 'valid.', :green
  end
rescue Aws::CloudFormation::Errors::ValidationError => e
  raise Thor::Error.new("Invalid template. Message: #{e.message}")
rescue CfnFlow::Template::Error => e
  raise Thor::Error.new("Error loading template. (#{e.class}) Message: #{e.message}")
end