Skip to content

Commit

Permalink
Merge pull request #22 from cleardataeng/feature/support_conditional_…
Browse files Browse the repository at this point in the history
…evaluation

support conditional python policy evaluation.
  • Loading branch information
neerajtickoo authored Aug 19, 2024
2 parents 74b33d5 + 9e3e637 commit 0e4a2ea
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions rpe/engines/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,17 @@ def evaluate(self, resource):

for policy_name, policy_cls in matched_policies.items():
try:
if hasattr(policy_cls, "should_evaluate_policy"):
should_evaluate_policy_res = policy_cls.should_evaluate_policy(
resource
)
if not should_evaluate_policy_res:
print(
f"Policy: {policy_name}, will not be evaluated for resource {resource} "
f"as should_evaluate_policy returned {should_evaluate_policy_res}"
)
continue

if hasattr(policy_cls, "evaluate"):
eval_result = policy_cls.evaluate(resource)
if not isinstance(eval_result, EvaluationResult):
Expand Down

0 comments on commit 0e4a2ea

Please sign in to comment.