Skip to content
This repository was archived by the owner on Jan 27, 2023. It is now read-only.
This repository was archived by the owner on Jan 27, 2023. It is now read-only.

Unused code in ExecutablePolicyRule #1356

Open
@rbrady

Description

@rbrady

I reviewed a file and saw unused code with no additional context information other than "currently unused".

def _safe_execute(self, image_obj, exec_context):
"""
An alternate execution path that treats failures like specific triggers so they can be handled with
whitelists etc. NOT CURRENTLY USED!
:param image_obj:
:param exec_context:
:return:
"""
pass
# matches = None
# try:
# if not self.configured_trigger:
# if self.gate_cls:
# err_trigger = ErrorMatch.EmptyTrigger(parent_gate_cls=self.gate_cls,
# msg='Trigger not found: {}'.format(self.trigger_name))
# err_trigger._fire(instance_id='invalid_trigger',
# msg='Trigger {} not found in gate'.format(self.trigger_name))
# self.configured_trigger = err_trigger
# else:
# match = None
# return [PolicyRuleFailure(trigger_match=match, policy_rule=self,
# failure_msg='No implementation found for gate/trigger: {}/{}'.format(
# self.gate_name, self.trigger_name), failure_cause=self.error_exc)]
# else:
# # Normal execution
# try:
# self.configured_trigger.execute(image_obj, exec_context)
# except Exception as e:
# log.exception('Error executing trigger on image {}'.format(image_obj.id))
# if self.configured_trigger.fired:
#
#
#
# matches = self.configured_trigger.fired
# raise Exception('Always fail!!')
# decisions = [PolicyRuleDecision(trigger_match=match, policy_rule=self) for match in matches]
# return decisions
# except Exception as e:
# if matches:
# return [PolicyRuleFailure(trigger_match=matches, policy_rule=self, failure_msg='Error evaluating rule', failure_cause=e)]
# else:
# return [PolicyRuleFailure(trigger_match=ErrorMatch(trigger=self.configured_trigger), policy_rule=self, failure_msg='Error evaluating rule', failure_cause=e)]

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions