Class: Cumulus::VPC::EndpointDiff

Inherits:
Common::Diff show all
Includes:
EndpointChange
Defined in:
lib/vpc/models/EndpointDiff.rb

Overview

Public: Represents a single difference between local configuration and AWS configuration

Constant Summary

Constants included from EndpointChange

Cumulus::VPC::EndpointChange::POLICY, Cumulus::VPC::EndpointChange::ROUTE_TABLES

Constants included from Common::DiffChange

Common::DiffChange::ADD, Common::DiffChange::MODIFIED, Common::DiffChange::UNMANAGED

Instance Attribute Summary

Attributes inherited from Common::Diff

#aws, #changes, #info_only, #local, #type

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Common::DiffChange

next_change_id

Methods inherited from Common::Diff

#add_string, added, #initialize, #local_name, modified, #to_s, unmanaged, #unmanaged_string

Constructor Details

This class inherits a constructor from Cumulus::Common::Diff

Class Method Details

.policy(aws, local) ⇒ Object



30
31
32
33
34
35
# File 'lib/vpc/models/EndpointDiff.rb', line 30

def self.policy(aws, local)
  if aws != local
    diff = EndpointDiff.new(POLICY, aws, local)
    diff
  end
end

.route_tables(aws, local) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/vpc/models/EndpointDiff.rb', line 21

def self.route_tables(aws, local)
  changes = Common::ListChange.simple_list_diff(aws, local)
  if changes
    diff = EndpointDiff.new(ROUTE_TABLES, aws, local)
    diff.changes = changes
    diff
  end
end

Instance Method Details

#asset_typeObject



37
38
39
# File 'lib/vpc/models/EndpointDiff.rb', line 37

def asset_type
  "Endpoint"
end

#aws_nameObject



41
42
43
# File 'lib/vpc/models/EndpointDiff.rb', line 41

def aws_name
  @aws.service_name
end

#diff_stringObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/vpc/models/EndpointDiff.rb', line 45

def diff_string
  case @type
  when POLICY
    [
      "Policy Statement:",
      Colors.unmanaged([
        "\tRemoving:",
        JSON.pretty_generate(aws).lines.map { |l| "\t\t#{l}".chomp("\n") }
      ].join("\n")),
      Colors.added([
        "\tAdding:",
        JSON.pretty_generate(local).lines.map { |l| "\t\t#{l}".chomp("\n") }
      ].join("\n"))
    ].join("\n")
  when ROUTE_TABLES
    [
      "Route Tables:",
      @changes.removed.map { |d| Colors.unmanaged("\t#{d}") },
      @changes.added.map { |d| Colors.added("\t#{d}") },
    ].flatten.join("\n")
  end
end