How to Handle undefined Rule Evaluations in Rego and Execute Alternative Logic? #653
Unanswered
aashishkr
asked this question in
OPA and Rego
Replies: 1 comment 8 replies
-
Could be that I don't fully understand what you want, but it sounds like you want to use the So instead of: check_for_policy_override_exists("inventory") != "undefined" you'd do not check_for_policy_override_exists("inventory") which negates an undefined result and moves on to evaluate the next line. |
Beta Was this translation helpful? Give feedback.
8 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I'm trying to implement an override in Rego and need help handling the undefined case. Here's the code snippet:
The owner-level override is defined like this:
Goal
:I want allow to be determined as follows:
check_for_policy_override_exists("inventory")
returnstrue
orfalse
, use that value.check_for_policy_override_exists("inventory")
is undefined, fallback tocheck_base_policy_implementation("inventory")
.check_for_policy_override_exists("inventory")
,check_base_policy_implementation("inventory")
] don't exist default the value tofalse
.How can I refactor this to handle the undefined case more effectively? Any ideas or suggestions are welcome!
Beta Was this translation helpful? Give feedback.
All reactions