Skip to content
Discussion options

You must be logged in to vote

Heya. This might not be possible in rego, as recursion is forbidden.

One workaround is to unroll the logic for a bounded depth, but it would need you to drop this constraint:

  • Note that the nesting of the parentOf relation is arbitrary, we could have any number of levels of nesting.

Say, if you only allow nesting of level <= 3, you could write out the rules explicitly.

This is a start, to get the gist of it 👇

package play
import future.keywords

# direct decendants
result[entity.name] contains child if {
    some entity in input.entities
    some rel in entity.relations
    rel.type == "parentOf"
    child := rel.name
}

# one indirection
result[entity.name] contains child if {
    some 

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@nchengyeeshen
Comment options

Answer selected by nchengyeeshen
Comment options

You must be logged in to vote
2 replies
@nchengyeeshen
Comment options

@charlieegan3
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants