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

Method AsCELFunction

common/env/env.go:378–394  ·  view source on GitHub ↗

AsCELFunction converts the serializable form of the Function into CEL environment declaration.

(tp types.Provider)

Source from the content-addressed store, hash-verified

376
377// AsCELFunction converts the serializable form of the Function into CEL environment declaration.
378func (fn *Function) AsCELFunction(tp types.Provider) (*decls.FunctionDecl, error) {
379 if err := fn.Validate(); err != nil {
380 return nil, err
381 }
382 opts := make([]decls.FunctionOpt, 0, len(fn.Overloads)+1)
383 for _, o := range fn.Overloads {
384 opt, err := o.AsFunctionOption(tp)
385 opts = append(opts, opt)
386 if err != nil {
387 return nil, fmt.Errorf("invalid function %q: %w", fn.Name, err)
388 }
389 }
390 if len(fn.Description) != 0 {
391 opts = append(opts, decls.FunctionDocs(fn.Description))
392 }
393 return decls.NewFunction(fn.Name, opts...)
394}
395
396// NewOverload returns a new serializable representation of a global overload.
397func NewOverload(id string, args []*TypeDesc, ret *TypeDesc, examples ...string) *Overload {

Callers 2

configToEnvOptionsFunction · 0.80

Calls 4

ValidateMethod · 0.95
FunctionDocsFunction · 0.92
NewFunctionFunction · 0.92
AsFunctionOptionMethod · 0.80

Tested by 1