Skip to content

Commit

Permalink
Simplify lazy_find_* methods using lazy_find_by
Browse files Browse the repository at this point in the history
  • Loading branch information
cben committed Jul 10, 2017
1 parent ef39c14 commit 4043d24
Showing 1 changed file with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1269,29 +1269,23 @@ def lazy_find_node(name:)

def lazy_find_replicator(hash)
return nil if hash.nil?
index = "#{hash[:namespace]}__#{hash[:name]}"
@inv_collections[:container_replicators].lazy_find(index, :ref => :by_namespace_and_name)
@inv_collections[:container_replicators].lazy_find_by(hash, :ref => :by_namespace_and_name)
end

def lazy_find_container_group(hash)
return nil if hash.nil?
index = "#{hash[:namespace]}__#{hash[:name]}"
@inv_collections[:container_groups].lazy_find(index, :ref => :by_namespace_and_name)
@inv_collections[:container_groups].lazy_find_by(hash, :ref => :by_namespace_and_name)
end

def lazy_find_image(hash)
return nil if hash.nil?
hash = hash.merge(:container_image_registry => lazy_find_image_registry(hash[:container_image_registry]))
@inv_collections[:container_images].lazy_find(
@inv_collections[:container_images].object_index(hash)
)
@inv_collections[:container_images].lazy_find_by(hash)
end

def lazy_find_image_registry(hash)
return nil if hash.nil?
@inv_collections[:container_image_registries].lazy_find(
@inv_collections[:container_image_registries].object_index(hash)
)
@inv_collections[:container_image_registries].lazy_find_by(hash)
end
end
end

0 comments on commit 4043d24

Please sign in to comment.