Class: Cumulus::Route53::ZoneDiff
- Inherits:
-
Common::Diff
- Object
- Common::Diff
- Cumulus::Route53::ZoneDiff
- Includes:
- ZoneChange
- Defined in:
- lib/route53/models/ZoneDiff.rb
Overview
Public: Represents a single difference between local configuration and AWS configuration of zones.
Constant Summary
Constants included from ZoneChange
Cumulus::Route53::ZoneChange::COMMENT, Cumulus::Route53::ZoneChange::DOMAIN, Cumulus::Route53::ZoneChange::PRIVATE, Cumulus::Route53::ZoneChange::RECORD, Cumulus::Route53::ZoneChange::VPC
Constants included from Common::DiffChange
Common::DiffChange::ADD, Common::DiffChange::MODIFIED, Common::DiffChange::UNMANAGED
Instance Attribute Summary collapse
-
#changed_records ⇒ Object
Returns the value of attribute changed_records.
Attributes inherited from Common::Diff
Class Method Summary collapse
-
.records(changed_records, local) ⇒ Object
Public: Static method that produces a diff representing changes in records.
Instance Method Summary collapse
- #add_string ⇒ Object
-
#added_vpc_ids ⇒ Object
Public: Get the VPCs that have been added locally.
- #asset_type ⇒ Object
- #aws_name ⇒ Object
- #diff_string ⇒ Object
-
#info_only ⇒ Object
Public: Override the info_only attribute such that if this diff is a record diff and it contains only ignored record diffs, we return true.
-
#removed_vpc_ids ⇒ Object
Public: Get the VPCs that have been removed locally.
Methods included from Common::DiffChange
Methods inherited from Common::Diff
added, #initialize, #local_name, modified, #to_s, unmanaged, #unmanaged_string
Constructor Details
This class inherits a constructor from Cumulus::Common::Diff
Instance Attribute Details
#changed_records ⇒ Object
Returns the value of attribute changed_records.
24 25 26 |
# File 'lib/route53/models/ZoneDiff.rb', line 24 def changed_records @changed_records end |
Class Method Details
.records(changed_records, local) ⇒ Object
Public: Static method that produces a diff representing changes in records
changed_records - the RecordDiffs local - the local configuration for the zone
Returns the diff
32 33 34 35 36 |
# File 'lib/route53/models/ZoneDiff.rb', line 32 def self.records(changed_records, local) diff = ZoneDiff.new(RECORD, nil, local) diff.changed_records = changed_records diff end |
Instance Method Details
#add_string ⇒ Object
47 48 49 |
# File 'lib/route53/models/ZoneDiff.rb', line 47 def add_string "has been added locally, but must be created in AWS manually." end |
#added_vpc_ids ⇒ Object
Public: Get the VPCs that have been added locally.
Returns an array of vpc ids
94 95 96 |
# File 'lib/route53/models/ZoneDiff.rb', line 94 def added_vpc_ids @local.vpc - @aws.vpc end |
#asset_type ⇒ Object
38 39 40 |
# File 'lib/route53/models/ZoneDiff.rb', line 38 def asset_type "Zone" end |
#aws_name ⇒ Object
42 43 44 45 |
# File 'lib/route53/models/ZoneDiff.rb', line 42 def aws_name access = if @aws.config.private_zone then "private" else "public" end "#{@aws.name} (#{access})" end |
#diff_string ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/route53/models/ZoneDiff.rb', line 51 def diff_string case @type when COMMENT [ "Comment:", Colors.aws_changes("\tAWS - #{@aws.config.comment}"), Colors.local_changes("\tLocal - #{@local.comment}") ].join("\n") when DOMAIN [ "Domain: AWS - #{Colors.aws_changes(@aws.name)}, Local - #{Colors.local_changes(@local.domain)}", "\tAWS doesn't allow you to change the domain for a zone." ].join("\n") when PRIVATE [ "Private: AWS - #{Colors.aws_changes(@aws.config.private_zone)}, Local - #{Colors.local_changes(@local.private)}", "\tAWS doesn't allow you to change whether a zone is private." ].join("\n") when RECORD if Configuration.instance.route53.print_all_ignored [ "Records:", @changed_records.map { |r| "\t#{r}" } ].flatten.join("\n") else [ "Records:", @changed_records.reject { |r| r.type == RecordChange::IGNORED }.map { |r| "\t#{r}" }, "\tYour blacklist ignored #{@changed_records.select { |r| r.type == RecordChange::IGNORED }.size} records." ].flatten.join("\n") end when VPC [ "VPCs:", added_vpc_ids.map { |vpc| Colors.added("\t#{vpc["id"]} | #{vpc["region"]}") }, removed_vpc_ids.map { |vpc| Colors.removed("\t#{vpc["id"]} | #{vpc["region"]}") } ].flatten.join("\n") end end |
#info_only ⇒ Object
Public: Override the info_only attribute such that if this diff is a record diff and it contains only ignored record diffs, we return true.
Returns whether or not this is an info only diff
109 110 111 112 113 114 115 |
# File 'lib/route53/models/ZoneDiff.rb', line 109 def info_only if @type == RECORD @changed_records.all? { |r| r.type == RecordChange::IGNORED } else false end end |
#removed_vpc_ids ⇒ Object
Public: Get the VPCs that have been removed locally.
Returns an array of vpc ids
101 102 103 |
# File 'lib/route53/models/ZoneDiff.rb', line 101 def removed_vpc_ids @aws.vpc - @local.vpc end |