Class: Lono::Sets::Preview::Codediff

Inherits:
Base show all
Includes:
Cfn::Preview::DiffViewer
Defined in:
lib/lono/sets/preview/codediff.rb

Instance Method Summary collapse

Methods included from Cfn::Preview::DiffViewer

#diff_viewer, #show_diff

Methods inherited from Base

#build_options, #exit_unless_updatable!, #initialize, #operation_preferences

Methods inherited from Cfn::Base

#capabilities, #command_with_iam, #continue_update_rollback, #continue_update_rollback_sure?, #delete_rollback_stack, #exit_unless_updatable!, #generate_all, #notification_arns, #pretty_path, #prompt_for_iam, #quit, #rerun_with_iam?, #set_template_url!, #show_options, #stack_status, #starting_message, #status, #tags

Methods included from Utils::Sure

#sure?

Methods included from AwsServices

#cfn, #ec2, #iam, #s3, #s3_presigner, #s3_resource, #sts

Methods included from AwsServices::Helper

#rollback_complete?, #testing_update?

Methods included from AwsServices::StackSet

#find_stack_set, #stack_set_exists?

Methods included from AwsServices::Stack

#find_stack, #stack_exists?

Methods inherited from AbstractBase

#initialize, #reinitialize, #template_path

Methods included from Blueprint::Root

#find_blueprint_root, #set_blueprint_root

Constructor Details

This class inherits a constructor from Lono::Sets::Base

Instance Method Details

#download_existing_cfn_templateObject



21
22
23
24
# File 'lib/lono/sets/preview/codediff.rb', line 21

def download_existing_cfn_template
  resp = cfn.describe_stack_set(stack_set_name: @stack)
  IO.write(existing_template_path, resp.stack_set.template_body)
end

#existing_template_pathObject



31
32
33
# File 'lib/lono/sets/preview/codediff.rb', line 31

def existing_template_path
  "/tmp/existing_stack_set.yml"
end

#new_cfn_templateObject

for clarity



27
28
29
# File 'lib/lono/sets/preview/codediff.rb', line 27

def new_cfn_template
  template_path
end

#runObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/lono/sets/preview/codediff.rb', line 5

def run
  unless stack_set_exists?(@stack)
    puts "WARN: Cannot create a diff for the stack set because the #{@stack} does not exists.".color(:yellow)
    return
  end

  if @options[:noop]
    puts "NOOP Generating CloudFormation source code diff..."
  else
    generate_all # from Base superclass. Generates the output lono teplates
    puts "Generating CloudFormation source code diff..."
    download_existing_cfn_template
    show_diff(existing_template_path, new_cfn_template)
  end
end