| 649 | } |
| 650 | |
| 651 | absl::Status Eval(const conformance::v1alpha1::EvalRequest& request, |
| 652 | conformance::v1alpha1::EvalResponse& response) override { |
| 653 | google::protobuf::Arena arena; |
| 654 | |
| 655 | auto runtime_status = Setup(request.container()); |
| 656 | if (!runtime_status.ok()) { |
| 657 | return absl::InternalError(runtime_status.status().ToString( |
| 658 | absl::StatusToStringMode::kWithEverything)); |
| 659 | } |
| 660 | std::unique_ptr<const cel::Runtime> runtime = |
| 661 | std::move(runtime_status).value(); |
| 662 | |
| 663 | auto program_status = Plan(*runtime, request); |
| 664 | if (!program_status.ok()) { |
| 665 | return absl::InternalError(program_status.status().ToString( |
| 666 | absl::StatusToStringMode::kWithEverything)); |
| 667 | } |
| 668 | std::unique_ptr<cel::TraceableProgram> program = |
| 669 | std::move(program_status).value(); |
| 670 | cel::Activation activation; |
| 671 | |
| 672 | for (const auto& pair : request.bindings()) { |
| 673 | cel::expr::Value import_value; |
| 674 | ABSL_CHECK(ConvertWireCompatProto(pair.second.value(), // Crash OK |
| 675 | &import_value)); |
| 676 | auto import_status = |
| 677 | FromExprValue(import_value, runtime->GetDescriptorPool(), |
| 678 | runtime->GetMessageFactory(), &arena); |
| 679 | if (!import_status.ok()) { |
| 680 | return absl::InternalError(import_status.status().ToString( |
| 681 | absl::StatusToStringMode::kWithEverything)); |
| 682 | } |
| 683 | |
| 684 | activation.InsertOrAssignValue(pair.first, |
| 685 | std::move(import_status).value()); |
| 686 | } |
| 687 | |
| 688 | auto eval_status = program->Evaluate(&arena, activation); |
| 689 | if (!eval_status.ok()) { |
| 690 | *response.mutable_result() |
| 691 | ->mutable_error() |
| 692 | ->add_errors() |
| 693 | ->mutable_message() = eval_status.status().ToString( |
| 694 | absl::StatusToStringMode::kWithEverything); |
| 695 | return absl::OkStatus(); |
| 696 | } |
| 697 | |
| 698 | cel::Value result = eval_status.value(); |
| 699 | if (result->Is<cel::ErrorValue>()) { |
| 700 | const absl::Status& error = result.GetError().NativeValue(); |
| 701 | *response.mutable_result() |
| 702 | ->mutable_error() |
| 703 | ->add_errors() |
| 704 | ->mutable_message() = std::string( |
| 705 | error.ToString(absl::StatusToStringMode::kWithEverything)); |
| 706 | } else { |
| 707 | auto export_status = ToExprValue(result, runtime->GetDescriptorPool(), |
| 708 | runtime->GetMessageFactory(), &arena); |
nothing calls this directly
no test coverage detected