MCPcopy Create free account
hub / github.com/cel-expr/cel-go / Declarations

Function Declarations

cel/options.go:178–203  ·  view source on GitHub ↗

Declarations option extends the declaration set configured in the environment. Note: Declarations will by default be appended to the pre-existing declaration set configured for the environment. The NewEnv call builds on top of the standard CEL declarations. For a purely custom set of declarations u

(decls ...*exprpb.Decl)

Source from the content-addressed store, hash-verified

176//
177// Deprecated: use FunctionDecls and VariableDecls or FromConfig instead.
178func Declarations(decls ...*exprpb.Decl) EnvOption {
179 declOpts := []EnvOption{}
180 var err error
181 var opt EnvOption
182 // Convert the declarations to `EnvOption` values ahead of time.
183 // Surface any errors in conversion when the options are applied.
184 for _, d := range decls {
185 opt, err = ExprDeclToDeclaration(d)
186 if err != nil {
187 break
188 }
189 declOpts = append(declOpts, opt)
190 }
191 return func(e *Env) (*Env, error) {
192 if err != nil {
193 return nil, err
194 }
195 for _, o := range declOpts {
196 e, err = o(e)
197 if err != nil {
198 return nil, err
199 }
200 }
201 return e, nil
202 }
203}
204
205// EagerlyValidateDeclarations ensures that any collisions between configured declarations are caught
206// at the time of the `NewEnv` call.

Callers 1

TestAstToProtoFunction · 0.85

Calls 1

ExprDeclToDeclarationFunction · 0.85

Tested by 1

TestAstToProtoFunction · 0.68