Class: Roadworker::Batch::Update
- Defined in:
- lib/roadworker/batch.rb
Instance Attribute Summary
Attributes inherited from Operation
#dry_run, #health_checks, #hosted_zone, #logger, #rrset
Instance Method Summary collapse
Methods inherited from Operation
#cname_first?, #initialize, #inspect, #op_size, #present_rrset, #sort_key, #to_s, #value_size
Methods included from Log
Constructor Details
This class inherits a constructor from Roadworker::Batch::Operation
Instance Method Details
#changes ⇒ Object
324 325 326 327 328 329 330 331 332 333 334 335 |
# File 'lib/roadworker/batch.rb', line 324 def changes [ { action: 'DELETE', resource_record_set: present_rrset.to_h, }, { action: 'CREATE', resource_record_set: desired_rrset.to_h, }, ] end |
#desired_rrset ⇒ Object
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
# File 'lib/roadworker/batch.rb', line 302 def desired_rrset return @desired_rrset if defined? @desired_rrset @desired_rrset = {name: rrset[:name]} Route53Wrapper::RRSET_ATTRS_WITH_TYPE.each do |attribute| value = rrset[attribute] next unless value case attribute when :dns_name dns_name, dns_name_opts = value @desired_rrset[:alias_target] = get_alias_target(dns_name, dns_name_opts) when :health_check @desired_rrset[:health_check_id] = get_health_check(value) else @desired_rrset[attribute] = value end end @desired_rrset end |
#diff! ⇒ Object
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 |
# File 'lib/roadworker/batch.rb', line 337 def diff! log(:info, 'Update ResourceRecordSet', :green) do "#{present_rrset.name} #{present_rrset.type}#{ present_rrset.set_identifier && " (#{present_rrset.set_identifier})" }" end # Note that desired_rrset is directly for Route 53, and present_record is also from Route 53 # Only given +rrset+ is brought from DSL, and dns_name & health_check is only valid in our DSL Route53Wrapper::RRSET_ATTRS_WITH_TYPE.each do |attribute| case attribute when :dns_name present = normalize_attribute_for_diff(attribute, present_rrset[:alias_target] && present_rrset[:alias_target][:dns_name]) desired = normalize_attribute_for_diff(attribute, desired_rrset[:alias_target] && desired_rrset[:alias_target][:dns_name]) when :health_check present = normalize_attribute_for_diff(attribute, present_rrset[:health_check_id]) desired = normalize_attribute_for_diff(attribute, desired_rrset[:health_check_id]) else present = normalize_attribute_for_diff(attribute, present_rrset[attribute]) desired = normalize_attribute_for_diff(attribute, desired_rrset[attribute]) end if desired != present color = Roadworker::StringHelper.colorize # XXX: log(:info, Roadworker::StringHelper.green(" #{attribute}:\n") + Roadworker::Utils.diff(present, desired, color: color, indent: ' '), false) end end end |