class Roadworker::Route53Wrapper::ResourceRecordSetWrapper

Public Class Methods

new(resource_record_set, hosted_zone, options) click to toggle source
# File lib/roadworker/route53-wrapper.rb, line 177
def initialize(resource_record_set, hosted_zone, options)
  @resource_record_set = resource_record_set
  @hosted_zone = hosted_zone
  @options = options
end

Public Instance Methods

dns_name() click to toggle source
# File lib/roadworker/route53-wrapper.rb, line 231
def dns_name
  alias_target = @resource_record_set.alias_target || {}
  dns_name = alias_target[:dns_name]

  if dns_name
    [
      dns_name,
      Aws::Route53.normalize_dns_name_options(alias_target),
    ]
  else
    nil
  end
end
eql?(expected_record) click to toggle source
# File lib/roadworker/route53-wrapper.rb, line 183
def eql?(expected_record)
  Route53Wrapper::RRSET_ATTRS_WITH_TYPE.all? do |attribute|
    expected = expected_record.public_send(attribute)
    expected = Aws::Route53.sort_rrset_values(attribute, expected) if expected.kind_of?(Array)
    expected = nil if expected.kind_of?(Array) && expected.empty?
    actual = self.public_send(attribute)
    actual = Aws::Route53.sort_rrset_values(attribute, actual) if actual.kind_of?(Array)
    actual = nil if actual.kind_of?(Array) && actual.empty?

    if attribute == :geo_location and actual
      actual = Hash[actual.each_pair.select {|k, v| not v.nil? }]
    end

    if !expected and !actual
      true
    elsif expected and actual
      case attribute
      when :health_check
        if actual[:alarm_identifier]
          actual[:alarm_identifier] = actual[:alarm_identifier].to_h
        end
      when :dns_name
        expected[0] = expected[0].downcase.sub(/\.\z/, '')
        actual[0] = actual[0].downcase.sub(/\.\z/, '')

        if expected[0] !~ /\Adualstack\./i and actual[0] =~ /\Adualstack\./i
          log(:warn, "`dualstack` prefix is used in the actual DNS name", :yellow) do
            log_id = [self.name, self.type].join(' ')
            rrset_setid = self.set_identifier
            rrset_setid ? (log_id + " (#{rrset_setid})") : log_id
          end

          actual[0].sub!(/\Adualstack\./i, '')
        end
      end

      (expected == actual)
    else
      false
    end
  end
end
health_check() click to toggle source
# File lib/roadworker/route53-wrapper.rb, line 245
def health_check
  @options.health_checks[@resource_record_set.health_check_id]
end
name() click to toggle source
# File lib/roadworker/route53-wrapper.rb, line 226
def name
  value = @resource_record_set.name
  value ? value.gsub("\\052", '*') : value
end

Private Instance Methods

method_missing(method_name, *args) click to toggle source
# File lib/roadworker/route53-wrapper.rb, line 251
def method_missing(method_name, *args)
  @resource_record_set.send(method_name, *args)
end