I created a Rego Policy but I would like to hide some of the objects from the output of the Rego.
Lets take this simple Rego as an example.
package cats
default cats := false
cats{
input.cat == my_cats[_]}
my_cats:= {
"Pumpkin Spice",
"Dr Meow"
}
Input:
{
"cat": "Pumpkin Spice"
}
Output:
{
"cats": true,
"my_cats": [
"Dr Meow",
"Pumpkin Spice"
]
}
I would like to hide the my_cats
Object from the Output, while only keeping the cat
.
There is the mask
functionality, but I couldn't get it to work since I think it's only supposed to working with the content of the input
.
Is there any way to accomplish this?
The response you get depends on what you query for. So if you query the
cats
rule, you'd get onlytrue
back. You can test this with e.g.opa eval -d policy.rego 'data.cats.cats'
The first element following
data
would be the package (cats
), and the next element the rule in that package (also namedcats
).If you're using the Rego Playground for evaluation, you can simply select the rule and the "Evaluate" button will change to "Evaluate Selection", which will evaluate only the rule if selected.