Skip to content

Commit

Permalink
Merge pull request #23 from enoodle/openshift_container_image_class_p…
Browse files Browse the repository at this point in the history
…rocessing

Adding openshift_container_images
  • Loading branch information
simon3z authored Jul 20, 2017
2 parents 51eb435 + ad5ac8a commit 8f1ab78
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class ManageIQ::Providers::Openshift::ContainerManager::ContainerImage < ContainerImage
def annotate_deny_execution(causing_policy)
ext_management_system.annotate(
"image",
digest,
"security.manageiq.org/failed-policy" => causing_policy,
"images.openshift.io/deny-execution" => "true"
)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ def parse_openshift_image(openshift_image)
:ref => "#{ContainerImage::DOCKER_PULLABLE_PREFIX}#{id}",
}

new_result[:type] = 'ManageIQ::Providers::Openshift::ContainerManager::ContainerImage'

if openshift_image[:dockerImageManifest].present?
begin
json = JSON.parse(openshift_image[:dockerImageManifest])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
RecursiveOpenStruct.new(
:metadata => {
:name => image_digest,
:creationTimestamp => '2015-08-17T09:16:46Z'
:creationTimestamp => '2015-08-17T09:16:46Z',
:uid => '123'
},
:dockerImageReference => "#{image_registry}:#{image_registry_port}/#{image_name}@#{image_digest}",
:dockerImageManifest => '{"name": "%s", "tag": "%s"}' % [image_name, image_tag],
Expand Down Expand Up @@ -72,6 +73,7 @@
image_from_openshift)).to eq(
:name => image_name,
:registered_on => Time.parse('2015-08-17T09:16:46Z').utc,
:type => 'ManageIQ::Providers::Openshift::ContainerManager::ContainerImage',
:digest => image_digest,
:image_ref => image_ref,
:tag => image_tag,
Expand Down Expand Up @@ -105,7 +107,8 @@
:digest => nil,
:image_ref => "docker-pullable://sha256:abcdefg",
:name => "sha256",
:tag => "abcdefg"
:tag => "abcdefg",
:type => "ManageIQ::Providers::Openshift::ContainerManager::ContainerImage",
)
end

Expand All @@ -123,6 +126,7 @@
:docker_version => nil,
:size => nil,
:labels => [],
:type => "ManageIQ::Providers::Openshift::ContainerManager::ContainerImage",
)
end

Expand All @@ -145,7 +149,8 @@
:environment_variables => {},
:size => nil,
:labels => [],
:docker_labels => []
:docker_labels => [],
:type => "ManageIQ::Providers::Openshift::ContainerManager::ContainerImage",
)
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
describe ManageIQ::Providers::Openshift::ContainerManager::Refresher do
let(:all_images_count) { 40 } # including /oapi/v1/images data
let(:pod_images_count) { 12 } # only images mentioned by pods
let(:images_managed_by_openshift_count) { 32 } # only images from /oapi/v1/images

before(:each) do
allow(MiqServer).to receive(:my_zone).and_return("default")
Expand Down Expand Up @@ -249,6 +250,7 @@ def assert_table_counts
expect(ContainerTemplate.count).to eq(26)
expect(ContainerImage.count).to eq(all_images_count)
expect(ContainerImage.joins(:containers).distinct.count).to eq(pod_images_count)
expect(ManageIQ::Providers::Openshift::ContainerManager::ContainerImage.count).to eq(images_managed_by_openshift_count)
end

def assert_ems
Expand Down

0 comments on commit 8f1ab78

Please sign in to comment.