Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only use the ImageAcquireError field #222

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def analyze
_log.error("analyzing image-inspector metadata for #{options[:docker_image_id]} failed with error: #{e}")
end

if inspector_metadata.ImageAcquireSuccess == false
if inspector_metadata.ImageAcquireError.present?
msg = "image acquiring error: #{inspector_metadata.ImageAcquireError}"
_log.error(msg)
return queue_signal(:abort_job, msg, 'error')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,17 @@ def fetch_oscap_arf
end

class MockFailedImageInspectorClient < MockImageInspectorClient
def initialize(oscap_status, oscap_msg, image_acq_success = true, image_acq_error = "", *args)
def initialize(oscap_status, oscap_msg, image_acq_error = "", *args)
super(*args)
@oscap_status = oscap_status
@oscap_msg = oscap_msg
@image_acq_success = image_acq_success
@image_acq_error = image_acq_error
end

def fetch_metadata(*_args)
os = super
os["OpenSCAP"] = OpenStruct.new("Status" => @oscap_status,
"ErrorMessage" => @oscap_msg)
os["ImageAcquireSuccess"] = @image_acq_success
os["ImageAcquireError"] = @image_acq_error
os
end
Expand Down Expand Up @@ -459,7 +457,7 @@ def create_pod_definition

it 'set the ok status from image-inspector OSCAP' do
allow_any_instance_of(described_class).to receive_messages(
:image_inspector_client => MockFailedImageInspectorClient.new("Success", "", true, "", IMAGE_ID)
:image_inspector_client => MockFailedImageInspectorClient.new("Success", "", "", IMAGE_ID)
)
@job.signal(:start)
expect(@job.state).to eq 'finished'
Expand All @@ -470,7 +468,7 @@ def create_pod_definition

it 'set the warn status from image-inspector OSCAP' do
allow_any_instance_of(described_class).to receive_messages(
:image_inspector_client => MockFailedImageInspectorClient.new("Error", OSCAP_ERROR_MSG, true, "", IMAGE_ID)
:image_inspector_client => MockFailedImageInspectorClient.new("Error", OSCAP_ERROR_MSG, "", IMAGE_ID)
)
@job.signal(:start)
expect(@job.state).to eq 'finished'
Expand All @@ -484,7 +482,7 @@ def create_pod_definition
it 'Detects when image acquiring failed and reports the error' do
IMG_ACQ_ERR = "can't find image".freeze
allow_any_instance_of(described_class).to receive_messages(
:image_inspector_client => MockFailedImageInspectorClient.new("Sucess", "", false, IMG_ACQ_ERR, IMAGE_ID)
:image_inspector_client => MockFailedImageInspectorClient.new("Sucess", "", IMG_ACQ_ERR, IMAGE_ID)
)
@job.signal(:start)
expect(@job.state).to eq 'finished'
Expand Down