| 606 | |
| 607 | |
| 608 | Option<Error> validateAndUpgradeResources(Offer::Operation* operation) |
| 609 | { |
| 610 | CHECK_NOTNULL(operation); |
| 611 | |
| 612 | switch (operation->type()) { |
| 613 | case Offer::Operation::RESERVE: { |
| 614 | // TODO(mpark): Once we perform a sanity check validation for |
| 615 | // offer operations as specified in MESOS-7760, this should no |
| 616 | // longer have to be handled in this function. |
| 617 | if (!operation->has_reserve()) { |
| 618 | return Error( |
| 619 | "A RESERVE offer operation must have" |
| 620 | " the Offer.Operation.reserve field set."); |
| 621 | } |
| 622 | |
| 623 | Option<Error> error = |
| 624 | Resources::validate(operation->reserve().resources()); |
| 625 | |
| 626 | if (error.isSome()) { |
| 627 | return error; |
| 628 | } |
| 629 | |
| 630 | error = Resources::validate(operation->reserve().source()); |
| 631 | |
| 632 | if (error.isSome()) { |
| 633 | return error; |
| 634 | } |
| 635 | |
| 636 | break; |
| 637 | } |
| 638 | case Offer::Operation::UNRESERVE: { |
| 639 | // TODO(mpark): Once we perform a sanity check validation for |
| 640 | // offer operations as specified in MESOS-7760, this should no |
| 641 | // longer have to be handled in this function. |
| 642 | if (!operation->has_unreserve()) { |
| 643 | return Error( |
| 644 | "An UNRESERVE offer operation must have" |
| 645 | " the Offer.Operation.unreserve field set."); |
| 646 | } |
| 647 | |
| 648 | Option<Error> error = |
| 649 | Resources::validate(operation->unreserve().resources()); |
| 650 | |
| 651 | if (error.isSome()) { |
| 652 | return error; |
| 653 | } |
| 654 | |
| 655 | break; |
| 656 | } |
| 657 | case Offer::Operation::CREATE: { |
| 658 | // TODO(mpark): Once we perform a sanity check validation for |
| 659 | // offer operations as specified in MESOS-7760, this should no |
| 660 | // longer have to be handled in this function. |
| 661 | if (!operation->has_create()) { |
| 662 | return Error( |
| 663 | "A CREATE offer operation must have" |
| 664 | " the Offer.Operation.create field set."); |
| 665 | } |
no test coverage detected