mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-07-20 20:44:51 -04:00
Bumps [github.com/open-policy-agent/opa](https://github.com/open-policy-agent/opa) from 1.15.2 to 1.17.1. - [Release notes](https://github.com/open-policy-agent/opa/releases) - [Changelog](https://github.com/open-policy-agent/opa/blob/v1.17.1/CHANGELOG.md) - [Commits](https://github.com/open-policy-agent/opa/compare/v1.15.2...v1.17.1) --- updated-dependencies: - dependency-name: github.com/open-policy-agent/opa dependency-version: 1.17.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
61 lines
1.3 KiB
Go
61 lines
1.3 KiB
Go
// Copyright 2017 The OPA Authors. All rights reserved.
|
|
// Use of this source code is governed by an Apache2
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package topdown
|
|
|
|
import (
|
|
"github.com/open-policy-agent/opa/v1/ast"
|
|
"github.com/open-policy-agent/opa/v1/topdown/builtins"
|
|
)
|
|
|
|
func builtinBinaryAnd(_ BuiltinContext, operands []*ast.Term, iter func(*ast.Term) error) error {
|
|
s1, err := builtins.SetOperand(operands[0].Value, 1)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
s2, err := builtins.SetOperand(operands[1].Value, 2)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if s1.Len() == 0 || s2.Len() == 0 {
|
|
return iter(ast.InternedEmptySet)
|
|
}
|
|
|
|
i := s1.Intersect(s2)
|
|
if i.Len() == 0 {
|
|
return iter(ast.InternedEmptySet)
|
|
}
|
|
|
|
return iter(ast.NewTerm(i))
|
|
}
|
|
|
|
func builtinBinaryOr(_ BuiltinContext, operands []*ast.Term, iter func(*ast.Term) error) error {
|
|
s1, err := builtins.SetOperand(operands[0].Value, 1)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
s2, err := builtins.SetOperand(operands[1].Value, 2)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if s1.Len() == 0 {
|
|
return iter(operands[1])
|
|
}
|
|
|
|
if s2.Len() == 0 {
|
|
return iter(operands[0])
|
|
}
|
|
|
|
return iter(ast.NewTerm(s1.Union(s2)))
|
|
}
|
|
|
|
func init() {
|
|
RegisterBuiltinFunc(ast.And.Name, builtinBinaryAnd)
|
|
RegisterBuiltinFunc(ast.Or.Name, builtinBinaryOr)
|
|
}
|