| 293 | } |
| 294 | |
| 295 | absl::Status ParseStandardLibraryConfig(Config& config, absl::string_view yaml, |
| 296 | const YAML::Node& root) { |
| 297 | const YAML::Node standard_library = root["stdlib"]; |
| 298 | if (!standard_library.IsDefined()) { |
| 299 | return absl::OkStatus(); |
| 300 | } |
| 301 | |
| 302 | if (!standard_library.IsMap()) { |
| 303 | return YamlError(yaml, standard_library, |
| 304 | "Standard library config ('stdlib') is not a map"); |
| 305 | } |
| 306 | |
| 307 | Config::StandardLibraryConfig standard_library_config; |
| 308 | |
| 309 | const YAML::Node disable = standard_library["disable"]; |
| 310 | if (disable.IsDefined()) { |
| 311 | if (!disable.IsScalar()) { |
| 312 | return YamlError(yaml, disable, "Node 'disable' is not a boolean"); |
| 313 | } |
| 314 | CEL_ASSIGN_OR_RETURN(standard_library_config.disable, |
| 315 | GetBool(yaml, "disable", disable)); |
| 316 | } |
| 317 | |
| 318 | const YAML::Node disable_macros = standard_library["disable_macros"]; |
| 319 | if (disable_macros.IsDefined()) { |
| 320 | if (!disable_macros.IsScalar()) { |
| 321 | return YamlError(yaml, disable_macros, |
| 322 | "Node 'disable_macros' is not a boolean"); |
| 323 | } |
| 324 | CEL_ASSIGN_OR_RETURN(standard_library_config.disable_macros, |
| 325 | GetBool(yaml, "disable_macros", disable_macros)); |
| 326 | } |
| 327 | |
| 328 | CEL_ASSIGN_OR_RETURN( |
| 329 | standard_library_config.included_macros, |
| 330 | ParseMacroList(yaml, standard_library, "include_macros")); |
| 331 | |
| 332 | CEL_ASSIGN_OR_RETURN( |
| 333 | standard_library_config.excluded_macros, |
| 334 | ParseMacroList(yaml, standard_library, "exclude_macros")); |
| 335 | |
| 336 | CEL_ASSIGN_OR_RETURN( |
| 337 | standard_library_config.included_functions, |
| 338 | ParseFunctionList(yaml, standard_library, "include_functions")); |
| 339 | |
| 340 | CEL_ASSIGN_OR_RETURN( |
| 341 | standard_library_config.excluded_functions, |
| 342 | ParseFunctionList(yaml, standard_library, "exclude_functions")); |
| 343 | |
| 344 | return config.SetStandardLibraryConfig(standard_library_config); |
| 345 | } |
| 346 | |
| 347 | absl::StatusOr<Config::TypeInfo> ParseTypeInfo(const YAML::Node& node, |
| 348 | absl::string_view yaml) { |
no test coverage detected