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:



344
345
346
347
348
349
350
351
352
353
354
355
356
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 344

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)



324
325
326
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 324

def added_attribute_count
  @added_attribute_count
end

#added_attributesObject (readonly)



304
305
306
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 304

def added_attributes
  @added_attributes
end

#baseline_locationObject (readonly)



284
285
286
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 284

def baseline_location
  @baseline_location
end

#conflicting_attribute_countObject (readonly)



334
335
336
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 334

def conflicting_attribute_count
  @conflicting_attribute_count
end

#conflicting_attributesObject (readonly)



314
315
316
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 314

def conflicting_attributes
  @conflicting_attributes
end

#equal_attribute_countObject (readonly)



319
320
321
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 319

def equal_attribute_count
  @equal_attribute_count
end

#missing_attribute_countObject (readonly)



329
330
331
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 329

def missing_attribute_count
  @missing_attribute_count
end

#missing_attributesObject (readonly)



309
310
311
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 309

def missing_attributes
  @missing_attributes
end

#preview_locationObject (readonly)



289
290
291
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 289

def preview_location
  @preview_location
end

#titleObject (readonly)



299
300
301
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 299

def title
  @title
end

#typeObject (readonly)



294
295
296
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 294

def type
  @type
end

Instance Method Details

#assign_ids(start) ⇒ Object



358
359
360
361
362
363
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 358

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)


365
366
367
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 365

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

#initialize_from_hash(hash) ⇒ Object



369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 369

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