Private variables? #391
-
Is it possible to declare a variable that can only be referenced by expressions within the same package? I find I commonly import some untrusted input, and then build an internal local variable that does things like |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
No, this is not possible. You could introduce your own convention, like starting with an underscore, python-style. |
Beta Was this translation helpful? Give feedback.
-
Only what was queried for will be included in the policy response :) So if the caller doesn't want them, they should be more specific in their query. I.e. if you have a policy like this: package policy
foo := input.foo
bar := input.bar
default allow := false
allow {
foo == bar
} With OPA running as a server, you either query the whole package, i.e. |
Beta Was this translation helpful? Give feedback.
-
Another way is to make it a function instead of a variable. Like:
Functions are not a part of the result object. |
Beta Was this translation helpful? Give feedback.
No, this is not possible. You could introduce your own convention, like starting with an underscore, python-style.