Class: LonoCfn::Diff
Instance Method Summary
collapse
#cfn, #stack_exists?, #testing_update?
Methods inherited from Base
#check_files, #check_for_errors, #convention_path, #detect_format, #exist_unless_updatable, #generate_all, #generate_params, #generate_templates, #get_source_path, #initialize, #quit, #stack_status
Methods included from Util
#are_you_sure?
Constructor Details
This class inherits a constructor from LonoCfn::Base
Instance Method Details
#diff_viewer ⇒ Object
36
37
38
39
|
# File 'lib/lono-cfn/diff.rb', line 36
def diff_viewer
return ENV['LONO_CFN_DIFF'] if ENV['LONO_CFN_DIFF']
system("type colordiff > /dev/null") ? "colordiff" : "diff"
end
|
#download_existing_cfn_template ⇒ Object
16
17
18
19
20
21
22
23
|
# File 'lib/lono-cfn/diff.rb', line 16
def download_existing_cfn_template
resp = cfn.get_template(
stack_name: @stack_name,
template_stage: "Original"
)
resp.template_body
IO.write(existing_template_path, resp.template_body)
end
|
#existing_template_path ⇒ Object
41
42
43
|
# File 'lib/lono-cfn/diff.rb', line 41
def existing_template_path
"/tmp/existing_cfn_template.json"
end
|
#new_cfn_template ⇒ Object
32
33
34
|
# File 'lib/lono-cfn/diff.rb', line 32
def new_cfn_template
@template_path
end
|
#run ⇒ Object
5
6
7
8
9
10
11
12
13
14
|
# File 'lib/lono-cfn/diff.rb', line 5
def run
if @options[:noop]
puts "NOOP Generating CloudFormation source code diff..."
else
generate_all puts "Generating CloudFormation source code diff..."
download_existing_cfn_template
show_changes
end
end
|
#show_changes ⇒ Object
25
26
27
28
29
|
# File 'lib/lono-cfn/diff.rb', line 25
def show_changes
command = "#{diff_viewer} #{existing_template_path} #{new_cfn_template}"
puts "Running: #{command}"
system(command)
end
|