MCPcopy Create free account
hub / github.com/apache/mesos / validateOfferFilters

Function validateOfferFilters

src/common/validation.cpp:645–669  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

643
644
645Option<Error> validateOfferFilters(const OfferFilters& offerFilters)
646{
647 if (offerFilters.has_min_allocatable_resources()) {
648 foreach (
649 const OfferFilters::ResourceQuantities& quantities,
650 offerFilters.min_allocatable_resources().quantities()) {
651 if (quantities.quantities().empty()) {
652 return Error("Resource quantities must contain at least one quantity");
653 }
654
655 // Use `auto` instead of `protobuf::MapPair<string, Value::>` since
656 // `foreach` is a macro and does not allow angle brackets.
657 foreach (auto&& quantity, quantities.quantities()) {
658 Option<Error> error = validateInputScalarValue(quantity.second.value());
659 if (error.isSome()) {
660 return Error(
661 "Invalid resource quantity for '" + quantity.first + "': " +
662 error->message);
663 }
664 }
665 }
666 }
667
668 return None();
669}
670
671Option<Error> validateInputScalarValue(double value)
672{

Callers 1

TESTFunction · 0.50

Calls 1

NoneClass · 0.85

Tested by 1

TESTFunction · 0.40