Class: StackMaster::Commands::Lint

Inherits:
Object
  • Object
show all
Includes:
Commander::UI, StackMaster::Command
Defined in:
lib/stack_master/commands/lint.rb

Instance Method Summary collapse

Methods included from StackMaster::Command

included, #success?

Constructor Details

#initialize(config, stack_definition, options = {}) ⇒ Lint

Returns a new instance of Lint.



9
10
11
12
# File 'lib/stack_master/commands/lint.rb', line 9

def initialize(config, stack_definition, options = {})
  @config = config
  @stack_definition = stack_definition
end

Instance Method Details

#performObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/stack_master/commands/lint.rb', line 14

def perform
  unless cfn_lint_available
    failed! 'Failed to run cfn-lint. You may need to install it using'\
            '`pip install cfn-lint`, or add it to $PATH.'\
            "\n"\
            '(See https://github.com/aws-cloudformation/cfn-python-lint'\
            ' for package information)'
  end

  Tempfile.open(['stack', ".#{proposed_stack.template_format}"]) do |f|
    f.write(proposed_stack.template_body)
    f.flush
    system('cfn-lint', f.path)
    puts "cfn-lint run complete"
  end
end