Skip to content

Commit

Permalink
Comments and small refactorings
Browse files Browse the repository at this point in the history
  • Loading branch information
slemrmartin committed Jul 3, 2018
1 parent 118b840 commit 6dbb06d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,6 @@ def custom_reconnect_block
lambda do |inventory_collection, inventory_objects_index, attributes_index|
relation = inventory_collection.model_class.where(:ems_id => inventory_collection.parent.id).archived


# Skip reconnect if there are no archived entities
return if relation.archived.count <= 0
raise "Allowed only manager_ref size of 1, got #{inventory_collection.manager_ref}" if inventory_collection.manager_ref.count > 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,12 @@ class ManageIQ::Providers::Kubernetes::Inventory::Persister < ManagerRefresh::In
def add_collection_directly(collection)
@collections[collection.name] = collection
end

# ManagerRefresh::InventoryCollection.inventory_object_attributes
# are not defined
def make_builder_settings(extra_settings = {})
opts = super
opts[:auto_inventory_attributes] = false
opts
end
end
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
class ManageIQ::Providers::Kubernetes::Inventory::Persister::ContainerManager < ManageIQ::Providers::Kubernetes::Inventory::Persister
# include ManageIQ::Providers::Kubernetes::ContainerManager::InventoryCollections
include ManageIQ::Providers::Kubernetes::Inventory::Persister::Definitions::ContainerCollections

def initialize_inventory_collections
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ def initialize_container_inventory_collections
container_build_pods
container_env_vars
container_groups
container_images
container_image_registries
container_images
container_limits
container_limit_items
container_nodes
Expand Down Expand Up @@ -88,6 +88,8 @@ def initialize_taggings
end

# ContainerCondition is polymorphic child of ContainerNode & ContainerGroup.
# @param manager [ExtManagementSystem]
# @param association [Symbol]
def add_container_conditions(manager, association)
relation = manager.public_send(association)
query = ContainerCondition.where(
Expand All @@ -111,11 +113,13 @@ def add_container_conditions(manager, association)
end

# CustomAttribute is polymorphic child of many models
# @param parent [Symbol]
# @param sections [Array<String>]
def add_custom_attributes(parent, sections)
parent_collection = @collections[parent]

type = parent_type(parent_collection)
relation = parent_id(parent_collection)
type = parent_collection.model_class.base_class.name
relation = parent_collection.full_collection_for_comparison

sections.each do |section|
query = ::CustomAttribute.where(
Expand All @@ -137,10 +141,11 @@ def add_custom_attributes(parent, sections)
end
end

def add_taggings(parent)
parent_collection = @collections[parent]
type = parent_type(parent_collection)
relation = parent_id(parent_collection)
# @param parent_name [Symbol]
def add_taggings(parent_name)
parent_collection = @collections[parent_name]
type = parent_collection.model_class.base_class.name
relation = parent_collection.full_collection_for_comparison

query = Tagging.where(
:taggable_type => type,
Expand All @@ -158,12 +163,4 @@ def add_taggings(parent)
)
end
end

def parent_type(parent_collection)
parent_collection.model_class.base_class.name
end

def parent_id(parent_collection)
parent_collection.full_collection_for_comparison
end
end

0 comments on commit 6dbb06d

Please sign in to comment.