class Cumulus::Route53::SingleRecordDiff

Public: Represents a single difference between local configuration and AWS configuration for a single record. This class allows all the changes for a record to be grouped together when printed.

Public Instance Methods

diff_string() click to toggle source
# File lib/route53/models/RecordDiff.rb, line 101
def diff_string
  case @type
  when ALIAS
    if @local.is_elb_alias?
      aws_name = ELB::get_aws_by_dns_name(@aws.alias_target.elb_dns_name).load_balancer_name
      "Alias: AWS - #{Colors.aws_changes(aws_name)}, Local - #{Colors.local_changes(@local.alias_target.name)}"
    else
      "Alias: AWS - #{Colors.aws_changes(@aws.alias_target.chomped_dns)}, Local - #{Colors.local_changes(@local.alias_target.dns_name)}"
    end
  when TTL
    "TTL: AWS - #{Colors.aws_changes(@aws.ttl)}, Local - #{Colors.local_changes(@local.ttl)}"
  when VALUE
    [
      "Value:",
      values_to_add.map { |v| Colors.added("\t\t\t#{v}") },
      values_to_remove.map { |v| Colors.removed("\t\t\t#{v}") }
    ].flatten.join("\n")
  end
end

Private Instance Methods

values_to_add() click to toggle source

Internal: Get the value parts that are in local configuration but not in AWS

Returns the local value parts

# File lib/route53/models/RecordDiff.rb, line 126
def values_to_add
  aws_value = @aws.resource_records.map(&:value)
  @local.value.reject { |v| aws_value.include?(v) }
end
values_to_remove() click to toggle source

Internal: Get the value parts that are in AWS but not local configuration

Returns the AWS value parts

# File lib/route53/models/RecordDiff.rb, line 134
def values_to_remove
  aws_value = @aws.resource_records.map(&:value)
  aws_value.reject { |v| @local.value.include?(v) }
end