MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / ParseFunctionConfigs

Function ParseFunctionConfigs

env/env_yaml.cc:635–680  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

633}
634
635absl::Status ParseFunctionConfigs(Config& config, absl::string_view yaml,
636 const YAML::Node& root) {
637 const YAML::Node functions = root["functions"];
638 if (!functions.IsDefined()) {
639 return absl::OkStatus();
640 }
641 if (!functions.IsSequence()) {
642 return YamlError(yaml, functions, "Node 'functions' is not a sequence");
643 }
644
645 for (const YAML::Node& function : functions) {
646 Config::FunctionConfig function_config;
647 if (!function || !function.IsMap()) {
648 return YamlError(yaml, function, "Function is not a map");
649 }
650 const YAML::Node name = function["name"];
651 if (!name || !name.IsScalar()) {
652 return YamlError(yaml, name, "Function name is not a string");
653 }
654 function_config.name = GetString(yaml, name);
655 const YAML::Node description = function["description"];
656 if (description.IsDefined()) {
657 if (!description.IsScalar()) {
658 return YamlError(yaml, description,
659 "Function description is not a string");
660 }
661 function_config.description = GetString(yaml, description);
662 }
663 const YAML::Node overloads = function["overloads"];
664 if (overloads.IsDefined()) {
665 if (!overloads.IsSequence()) {
666 return YamlError(yaml, overloads,
667 "Function 'overloads' item is not a sequence");
668 }
669
670 for (const YAML::Node& overload : overloads) {
671 CEL_ASSIGN_OR_RETURN(Config::FunctionOverloadConfig overload_config,
672 ParseFunctionOverloadConfig(yaml, overload));
673 function_config.overload_configs.push_back(std::move(overload_config));
674 }
675 }
676
677 CEL_RETURN_IF_ERROR(config.AddFunctionConfig(function_config));
678 }
679 return absl::OkStatus();
680}
681
682void EmitContainerConfig(const Config& env_config, YAML::Emitter& out) {
683 const auto& container_config = env_config.GetContainerConfig();

Callers 1

EnvConfigFromYamlFunction · 0.85

Calls 4

YamlErrorFunction · 0.85
GetStringFunction · 0.85
AddFunctionConfigMethod · 0.80
IsMapMethod · 0.45

Tested by

no test coverage detected