Skip to content

Commit

Permalink
refactor: typo and better comment
Browse files Browse the repository at this point in the history
  • Loading branch information
fredmaggiowski committed Jun 28, 2023
1 parent f565e21 commit 898c193
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions core/opaevaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,10 +449,15 @@ func LoadRegoModule(rootDirectory string) (*OPAModuleConfig, error) {
}, nil
}

// verifyAllowed replicates the ResultSet.Allowed function with a sligth difference
// since we allow for non boolean return values we use the type assertion to understand
// whether the returned value is an actual boolean and use it, otherwise we assume this
// is a custom payload for a response policy and return true regardless.
// verifyAllowed replicates the ResultSet.Allowed function with some slight differences.
// Since we allow for non boolean return values we use the type assertion to understand
// whether the returned value is an actual boolean and use it, otherwise we verify the
// returned value is at least a set containing something, if that's the case we assume
// this is a custom payload for a response policy and return true regardless.
//
// NOTE: do not rely on this function for decision-making conditions; use it only for
// debugging and informative logging!
//
// cfr: https://pkg.go.dev/github.com/open-policy-agent/opa/rego#ResultSet.Allowed
func verifyAllowed(rs rego.ResultSet) bool {
if len(rs) == 1 && len(rs[0].Bindings) == 0 {
Expand Down

0 comments on commit 898c193

Please sign in to comment.