Class: PuppetX::Puppetlabs::Migration::CatalogDeltaModel::ResourceConflict

Inherits:
Diff
  • Object
show all
Defined in:
lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb

Overview

Represents a resource conflict between a resource in the baseline and a resource with the same type and title in the preview

Instance Attribute Summary collapse

Attributes inherited from Diff

#diff_id

Instance Method Summary collapse

Methods inherited from DeltaEntity

from_hash

Methods included from ModelObject

#to_hash

Constructor Details

#initialize(baseline_location, preview_location, type, title, equal_attribute_count, added_attributes, missing_attributes, conflicting_attributes) ⇒ ResourceConflict

Returns a new instance of ResourceConflict.

Parameters:



356
357
358
359
360
361
362
363
364
365
366
367
368
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 356

def initialize(baseline_location, preview_location, type, title, equal_attribute_count, added_attributes, missing_attributes, conflicting_attributes)
  @baseline_location = baseline_location
  @preview_location = preview_location
  @type = type
  @title = title
  @equal_attribute_count = equal_attribute_count
  @added_attributes = added_attributes
  @added_attribute_count = added_attributes.size
  @missing_attributes = missing_attributes
  @missing_attribute_count = missing_attributes.size
  @conflicting_attributes = conflicting_attributes
  @conflicting_attribute_count = conflicting_attributes.size
end

Instance Attribute Details

#added_attribute_countObject (readonly)



336
337
338
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 336

def added_attribute_count
  @added_attribute_count
end

#added_attributesObject (readonly)



316
317
318
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 316

def added_attributes
  @added_attributes
end

#baseline_locationObject (readonly)



296
297
298
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 296

def baseline_location
  @baseline_location
end

#conflicting_attribute_countObject (readonly)



346
347
348
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 346

def conflicting_attribute_count
  @conflicting_attribute_count
end

#conflicting_attributesObject (readonly)



326
327
328
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 326

def conflicting_attributes
  @conflicting_attributes
end

#equal_attribute_countObject (readonly)



331
332
333
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 331

def equal_attribute_count
  @equal_attribute_count
end

#missing_attribute_countObject (readonly)



341
342
343
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 341

def missing_attribute_count
  @missing_attribute_count
end

#missing_attributesObject (readonly)



321
322
323
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 321

def missing_attributes
  @missing_attributes
end

#preview_locationObject (readonly)



301
302
303
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 301

def preview_location
  @preview_location
end

#titleObject (readonly)



311
312
313
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 311

def title
  @title
end

#typeObject (readonly)



306
307
308
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 306

def type
  @type
end

Instance Method Details

#assign_ids(start) ⇒ Object



370
371
372
373
374
375
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 370

def assign_ids(start)
  start = super
  start = assign_ids_on_each(start, added_attributes)
  start = assign_ids_on_each(start, missing_attributes)
  assign_ids_on_each(start, conflicting_attributes)
end

#compliant?Boolean

Returns:

  • (Boolean)


377
378
379
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 377

def compliant?
  @missing_attribute_count == 0 && @conflicting_attributes.all? { |ca| ca.compliant? }
end

#finish_attributesObject



381
382
383
384
385
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 381

def finish_attributes
  @added_attributes.each {|a| a.finish}
  @missing_attributes.each {|a| a.finish}
  @conflicting_attributes.each {|a| a.finish}
end

#initialize_from_hash(hash) ⇒ Object



387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 387

def initialize_from_hash(hash)
  hash.each_pair do |k, v|
    k = :"@#{k}"
    instance_variable_set(k,
      case k
      when :@baseline_location, :@preview_location
        Location.from_hash(v)
      when :@added_attributes, :@missing_attributes
        v.map { |rh| Attribute.from_hash(rh) }
      when :@conflicting_attributes
        v.map { |rh| AttributeConflict.from_hash(rh) }
      else
        v
      end)
  end
end