Documentation
¶
Index ¶
- func FilterCapabilities(allowedNames []string, allowedCats []string) *ast.Capabilities
- func New(opts ...Option) (func(*rego.Rego), error)
- func RegisterBuiltin0[R any](name string, categories []string, nondeterministic bool, ...)
- func RegisterBuiltin0_(name string, categories []string, nondeterministic bool, ...)
- func RegisterBuiltin1[T1 any, R any](name string, categories []string, nondeterministic bool, ...)
- func RegisterBuiltin1_[T1 any](name string, categories []string, nondeterministic bool, ...)
- func RegisterBuiltin2[T1 any, T2 any, R any](name string, categories []string, nondeterministic bool, ...)
- func RegisterBuiltin2_[T1 any, T2 any](name string, categories []string, nondeterministic bool, ...)
- func RegisterBuiltin3[T1 any, T2 any, T3 any, R any](name string, categories []string, nondeterministic bool, ...)
- func RegisterBuiltin3_[T1 any, T2 any, T3 any](name string, categories []string, nondeterministic bool, ...)
- func RegisterBuiltin4[T1 any, T2 any, T3 any, T4 any, R any](name string, categories []string, nondeterministic bool, ...)
- func RegisterBuiltin4_[T1 any, T2 any, T3 any, T4 any](name string, categories []string, nondeterministic bool, ...)
- func RegisterBuiltin5[T1 any, T2 any, T3 any, T4 any, T5 any, R any](name string, categories []string, nondeterministic bool, ...)
- func RegisterBuiltin5_[T1 any, T2 any, T3 any, T4 any, T5 any](name string, categories []string, nondeterministic bool, ...)
- type Option
- type RegoModule
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FilterCapabilities ¶ added in v0.3.0
func FilterCapabilities(allowedNames []string, allowedCats []string) *ast.Capabilities
FilterCapabilities filters OPA built-in functions based on a list of allowed names and categories, along with built-ins whose infix is in coreInfixes.
- If a built-in's infix is one of the core infixes, it is kept.
- Otherwise, if the built-in name is in allowedNames or any of its categories are in allowedCats, it is kept.
- If a built-in has custom category mappings, those are also checked against allowedCats.
The resulting capabilities object contains only the filtered built-ins.
func New ¶ added in v0.3.0
New processes the given options, parses each Rego module, and returns a function that can be directly passed to rego.New(...).
Example:
fn, err := regobrick.New(
regobrick.WithModule("modA.rego", regoSrc, []string{"data.regobrick.default_false"}),
)
r := rego.New(rego.Query("data.demo.allow"), fn)
func RegisterBuiltin0 ¶ added in v0.2.0
func RegisterBuiltin0[R any](name string, categories []string, nondeterministic bool, fn func(ctx rego.BuiltinContext) (R, error))
RegisterBuiltin0 registers a builtin with no arguments, returning a value + error.
func RegisterBuiltin0_ ¶ added in v0.2.0
func RegisterBuiltin0_(name string, categories []string, nondeterministic bool, fn func(ctx rego.BuiltinContext) error)
RegisterBuiltin0_ registers a builtin with no arguments and returns only error. On the Rego side, this builtin produces null.
func RegisterBuiltin1 ¶ added in v0.2.0
func RegisterBuiltin1[T1 any, R any](name string, categories []string, nondeterministic bool, fn func(ctx rego.BuiltinContext, arg1 T1) (R, error))
RegisterBuiltin1 registers a builtin with 1 argument, returning a value + error.
func RegisterBuiltin1_ ¶ added in v0.2.0
func RegisterBuiltin1_[T1 any](name string, categories []string, nondeterministic bool, fn func(ctx rego.BuiltinContext, arg1 T1) error)
RegisterBuiltin1_ registers a builtin with 1 argument and returns only error. On the Rego side, this builtin produces null.
func RegisterBuiltin2 ¶ added in v0.2.0
func RegisterBuiltin2[T1 any, T2 any, R any](name string, categories []string, nondeterministic bool, fn func(ctx rego.BuiltinContext, arg1 T1, arg2 T2) (R, error))
RegisterBuiltin2 registers a builtin with 2 arguments, returning a value + error.
func RegisterBuiltin2_ ¶ added in v0.2.0
func RegisterBuiltin2_[T1 any, T2 any](name string, categories []string, nondeterministic bool, fn func(ctx rego.BuiltinContext, arg1 T1, arg2 T2) error)
RegisterBuiltin2_ registers a builtin with 2 arguments and returns only error. On the Rego side, this builtin produces null.
func RegisterBuiltin3 ¶ added in v0.2.0
func RegisterBuiltin3[T1 any, T2 any, T3 any, R any](name string, categories []string, nondeterministic bool, fn func(ctx rego.BuiltinContext, arg1 T1, arg2 T2, arg3 T3) (R, error))
RegisterBuiltin3 registers a builtin with 3 arguments, returning a value + error.
func RegisterBuiltin3_ ¶ added in v0.2.0
func RegisterBuiltin3_[T1 any, T2 any, T3 any](name string, categories []string, nondeterministic bool, fn func(ctx rego.BuiltinContext, arg1 T1, arg2 T2, arg3 T3) error)
RegisterBuiltin3_ registers a builtin with 3 arguments and returns only error. On the Rego side, this builtin produces null.
func RegisterBuiltin4 ¶ added in v0.2.0
func RegisterBuiltin4[T1 any, T2 any, T3 any, T4 any, R any](name string, categories []string, nondeterministic bool, fn func(ctx rego.BuiltinContext, arg1 T1, arg2 T2, arg3 T3, arg4 T4) (R, error))
RegisterBuiltin4 registers a builtin with 4 arguments, returning a value + error.
func RegisterBuiltin4_ ¶ added in v0.2.0
func RegisterBuiltin4_[T1 any, T2 any, T3 any, T4 any](name string, categories []string, nondeterministic bool, fn func(ctx rego.BuiltinContext, arg1 T1, arg2 T2, arg3 T3, arg4 T4) error)
RegisterBuiltin4_ registers a builtin with 4 arguments and returns only error. On the Rego side, this builtin produces null.
func RegisterBuiltin5 ¶ added in v0.2.0
func RegisterBuiltin5[T1 any, T2 any, T3 any, T4 any, T5 any, R any](name string, categories []string, nondeterministic bool, fn func(ctx rego.BuiltinContext, arg1 T1, arg2 T2, arg3 T3, arg4 T4, arg5 T5) (R, error))
RegisterBuiltin5 registers a builtin with 5 arguments, returning a value + error.
func RegisterBuiltin5_ ¶ added in v0.2.0
func RegisterBuiltin5_[T1 any, T2 any, T3 any, T4 any, T5 any](name string, categories []string, nondeterministic bool, fn func(ctx rego.BuiltinContext, arg1 T1, arg2 T2, arg3 T3, arg4 T4, arg5 T5) error)
RegisterBuiltin5_ registers a builtin with 5 arguments and returns only error. On the Rego side, this builtin produces null.
Types ¶
type Option ¶ added in v0.3.0
type Option func(*[]RegoModule) error
Option is used to collect module information before parsing.
func WithModule ¶ added in v0.3.0
WithModule registers a Rego module (filename, source, imports).