Skip to content

Commit

Permalink
Merge pull request #13724 from enoodle/openshift_refresh_recollect_im…
Browse files Browse the repository at this point in the history
…age_registries

Container Provider Refresh Refactor Image Registries Collection
  • Loading branch information
Fryguy authored Feb 6, 2017
2 parents a7a141c + dc816de commit 82b0db1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def ems_inv_to_hashes(inventory)
get_endpoints(inventory)
get_services(inventory)
get_component_statuses(inventory)
get_registries
get_images
EmsRefresh.log_inv_debug_trace(@data, "data:")
@data
Expand All @@ -37,11 +36,6 @@ def get_images
process_collection(images, :container_images) { |n| n }
end

def get_registries
registries = @data_index.fetch_path(:container_image_registry, :by_host_and_port).try(:values) || []
process_collection(registries, :container_image_registries) { |n| n }
end

def get_nodes(inventory)
process_collection(inventory["node"], :container_nodes) { |n| parse_node(n) }
@data[:container_nodes].each do |cn|
Expand Down Expand Up @@ -692,6 +686,7 @@ def parse_container_image(image, imageID)
if stored_container_image_registry.nil?
@data_index.store_path(
:container_image_registry, :by_host_and_port, host_port, container_image_registry)
process_collection_item(container_image_registry, :container_image_registries) { |r| r }
stored_container_image_registry = container_image_registry
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,35 @@
parser.instance_variable_get('@data_index')[:container_image][:by_ref_and_registry_host_port].values[0])
expect(parser.instance_variable_get('@data')[:container_images][0][:architecture]).to eq('amd64')
end

context "image registries from openshift images" do
def parse_single_openshift_image_with_registry
inventory = {"image" => [image_from_openshift]}

parser.get_openshift_images(inventory)
expect(parser.instance_variable_get('@data_index')[:container_image_registry][:by_host_and_port].size).to eq(1)
expect(parser.instance_variable_get('@data')[:container_image_registries].size).to eq(1)
end

it "collects image registries from openshift images that are not also running pods images" do
parse_single_openshift_image_with_registry
end

it "avoids duplicate image registries from both running pods and openshift images" do
parser.instance_variable_get('@data')[:container_image_registries] = [{
:name => image_registry,
:host => image_registry,
:port => image_registry_port,
},]
parser.instance_variable_get('@data_index').store_path(
:container_image_registry,
:by_host_and_port,
"#{image_registry}:#{image_registry_port}",
parser.instance_variable_get('@data')[:container_image_registries][0]
)
parse_single_openshift_image_with_registry
end
end
end

describe "parse_build" do
Expand Down

0 comments on commit 82b0db1

Please sign in to comment.