(declarations []*celpb.Decl)
| 337 | } |
| 338 | |
| 339 | func 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 | |
| 361 | func envToStdLib(pbEnv *configpb.Environment) (*env.LibrarySubset, error) { |
| 362 | stdLib := env.NewLibrarySubset() |
no test coverage detected