Combining exit codes and 'defined' string return values from rules #228
Unanswered
stevend-15
asked this question in
OPA and Rego
Replies: 2 comments 2 replies
-
As you've noted, with the Commonly, you'd use |
Beta Was this translation helpful? Give feedback.
0 replies
-
@srenatus thank you for the confirmation. Maybe this limitation could be improved for greater evaluation flexibility? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I want to return a non-zero exit code when my policy fails so that my CI/CD buildspec stops building. I also want to return a string error message from my rule(s).
I noticed the --fail and --fail-defined options for opa eval command. These options seem perfect. However, returning a string
technically isn't 'failing' or returning 'undefined'. So, it seems to me impossible to return a string error message as well as
a non-zero exit code without also sabotaging a good output string and test case.
Am I correct here? Is there any way to get the best of both worlds? I'm still new to Rego
Ex rego file:
input:
{"message": "world"}
Running the following command will return a non-zero exit code no matter what
opa eval -i .\input.json -d .\test_rego.rego 'data.play.hello' --fail-defined -f raw
Similarly, the command below won't help because in this case the result is always defined
opa eval -i .\input.json -d .\test_rego.rego 'data.play.hello' --fail -f raw
Any help is appreciated
Beta Was this translation helpful? Give feedback.
All reactions