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

Method AsCELVariable

common/env/env.go:305–314  ·  view source on GitHub ↗

AsCELVariable converts the serializable form of the Variable into a CEL environment declaration.

(tp types.Provider)

Source from the content-addressed store, hash-verified

303
304// AsCELVariable converts the serializable form of the Variable into a CEL environment declaration.
305func (v *Variable) AsCELVariable(tp types.Provider) (*decls.VariableDecl, error) {
306 if err := v.Validate(); err != nil {
307 return nil, err
308 }
309 t, err := v.GetType().AsCELType(tp)
310 if err != nil {
311 return nil, fmt.Errorf("invalid variable %q: %w", v.Name, err)
312 }
313 return decls.NewVariableWithDoc(v.Name, t, v.Description), nil
314}
315
316// NewContextVariable returns a serializable context variable with a specific type name.
317func NewContextVariable(typeName string) *ContextVariable {

Callers 2

configToEnvOptionsFunction · 0.80

Calls 4

ValidateMethod · 0.95
GetTypeMethod · 0.95
NewVariableWithDocFunction · 0.92
AsCELTypeMethod · 0.80

Tested by 1