Documentation ¶
Index ¶
- Constants
- Variables
- func CerbosCELLib() cel.EnvOption
- func Eval(env *cel.Env, ast *cel.Ast, vars any, nowFunc func() time.Time, ...) (ref.Val, *cel.EvalDetails, error)
- func ExpandAbbrev(s string) string
- func Fqn(s string) string
- func ResourceAttributeNames(s string) []string
- func ResourceFieldNames(s string) []string
Constants ¶
View Source
const ( CELRequestIdent = "request" CELResourceAbbrev = "R" CELResourceKindField = "kind" CELResourceField = "resource" CELPrincipalAbbrev = "P" CELPrincipalField = "principal" CELRuntimeIdent = "runtime" CELVariablesIdent = "variables" CELVariablesAbbrev = "V" CELGlobalsIdent = "globals" CELGlobalsAbbrev = "G" CELAttrField = "attr" )
View Source
const (
IDFn = "id"
)
Variables ¶
View Source
var ( TrueExpr *exprpb.CheckedExpr FalseExpr *exprpb.CheckedExpr StdEnv *cel.Env StdEnvDecls = []*exprpb.Decl{ decls.NewVar(CELRequestIdent, decls.NewObjectType("cerbos.engine.v1.Request")), decls.NewVar(CELPrincipalAbbrev, decls.NewObjectType("cerbos.engine.v1.Request.Principal")), decls.NewVar(CELResourceAbbrev, decls.NewObjectType("cerbos.engine.v1.Request.Resource")), decls.NewVar(CELRuntimeIdent, decls.NewObjectType("cerbos.engine.v1.Runtime")), decls.NewVar(CELVariablesIdent, decls.NewMapType(decls.String, decls.Dyn)), decls.NewVar(CELVariablesAbbrev, decls.NewMapType(decls.String, decls.Dyn)), decls.NewVar(CELGlobalsIdent, decls.NewMapType(decls.String, decls.Dyn)), decls.NewVar(CELGlobalsAbbrev, decls.NewMapType(decls.String, decls.Dyn)), } StdEnvOptions = []cel.EnvOption{ cel.CrossTypeNumericComparisons(true), cel.Types(&enginev1.Request{}, &enginev1.Request_Principal{}, &enginev1.Request_Resource{}, &enginev1.Runtime{}), cel.Declarations(StdEnvDecls...), ext.Strings(), ext.Encoders(), ext.Math(), CerbosCELLib(), } )
Functions ¶
func CerbosCELLib ¶
CerbosCELLib returns the custom CEL functions provided by Cerbos.
func Eval ¶ added in v0.14.0
func Eval(env *cel.Env, ast *cel.Ast, vars any, nowFunc func() time.Time, opts ...cel.ProgramOption) (ref.Val, *cel.EvalDetails, error)
Eval returns the result of an evaluation of the ast and environment against the input vars, providing time-based functions with a static definition of the current time.
See https://pkg.go.dev/github.com/google/cel-go/cel#Program.Eval.
func ExpandAbbrev ¶ added in v0.18.0
func ResourceAttributeNames ¶ added in v0.12.0
func ResourceFieldNames ¶ added in v0.33.0
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.