Skip to content

Commit

Permalink
Image scanning: Add image name to task name
Browse files Browse the repository at this point in the history
  • Loading branch information
zakiva committed Sep 18, 2017
1 parent e7128a9 commit cf53509
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,18 @@ def scan_job_create(entity)
check_policy_prevent(:request_containerimage_scan, entity, User.current_user.userid, :raw_scan_job_create)
end

def raw_scan_job_create(target_class, target_id = nil, userid = nil)
target_class, target_id = target_class.class.name, target_class.id if target_class.kind_of?(ContainerImage)
def raw_scan_job_create(target_class, target_id = nil, userid = nil, target_name = nil)
# maintain backward compatibility pre https://github.com/ManageIQ/manageiq/pull/13722
if target_class.kind_of?(ContainerImage)
target_id = target_class.id
target_name = target_class.name
target_class = target_class.class.name
end
userid ||= User.current_user.userid
Job.create_job(
"ManageIQ::Providers::Kubernetes::ContainerManager::Scanning::Job",
:userid => userid,
:name => "Container image analysis",
:name => "Container Image Analysis: '#{target_name}'",
:target_class => target_class,
:target_id => target_id,
:zone => my_zone,
Expand All @@ -197,7 +202,7 @@ def check_policy_prevent(policy_event, event_target, userid, cb_method)
:class_name => self.class.to_s,
:instance_id => id,
:method_name => :check_policy_prevent_callback,
:args => [cb_method, event_target.class.name, event_target.id, userid],
:args => [cb_method, event_target.class.name, event_target.id, userid, event_target.name],
:server_guid => MiqServer.my_guid
}
enforce_policy(event_target, policy_event, {}, { :miq_callback => cb }) unless policy_event.nil?
Expand Down

0 comments on commit cf53509

Please sign in to comment.