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

Function protoDeclToFunctionsAndVariables

tools/compiler/compiler.go:339–359  ·  view source on GitHub ↗
(declarations []*celpb.Decl)

Source from the content-addressed store, hash-verified

337}
338
339func protoDeclToFunctionsAndVariables(declarations []*celpb.Decl) ([]*env.Function, []*env.Variable, error) {
340 functions := make([]*env.Function, 0, len(declarations))
341 variables := make([]*env.Variable, 0, len(declarations))
342 for _, decl := range declarations {
343 switch decl.GetDeclKind().(type) {
344 case *celpb.Decl_Function:
345 fn, err := protoDeclToFunction(decl)
346 if err != nil {
347 return nil, nil, fmt.Errorf("protoDeclToFunction(%s) failed to create function: %w", decl.GetName(), err)
348 }
349 functions = append(functions, fn)
350 case *celpb.Decl_Ident:
351 t, err := types.ProtoAsType(decl.GetIdent().GetType())
352 if err != nil {
353 return nil, nil, fmt.Errorf("types.ProtoAsType(%s) failed to create type: %w", decl.GetIdent().GetType(), err)
354 }
355 variables = append(variables, env.NewVariable(decl.GetName(), env.SerializeTypeDesc(t)))
356 }
357 }
358 return functions, variables, nil
359}
360
361func envToStdLib(pbEnv *configpb.Environment) (*env.LibrarySubset, error) {
362 stdLib := env.NewLibrarySubset()

Callers 1

envProtoToConfigFunction · 0.85

Calls 6

ProtoAsTypeFunction · 0.92
NewVariableFunction · 0.92
SerializeTypeDescFunction · 0.92
protoDeclToFunctionFunction · 0.85
GetNameMethod · 0.45
GetTypeMethod · 0.45

Tested by

no test coverage detected