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

Unused code in ExecutablePolicyRule #1356

Open
rbrady opened this issue Jan 11, 2022 · 0 comments
Open

Unused code in ExecutablePolicyRule #1356

rbrady opened this issue Jan 11, 2022 · 0 comments
Assignees

Comments

@rbrady
Copy link
Contributor

rbrady commented Jan 11, 2022

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)]

@rbrady rbrady self-assigned this Jan 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant