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

Function validateCommandLineResources

src/v1/resources.cpp:570–601  ·  view source on GitHub ↗

* Checks that a Resources object is valid for command line specification. * * Checks that the given Resources object is appropriate for specification at * the command line. Resources are appropriate if they do not have two resources * with the same name but different types, and do not attempt to specify * persistent volumes, revocable resources, or dynamic reservations. * * @param resources

Source from the content-addressed store, hash-verified

568 * Error otherwise.
569 */
570static Option<Error> validateCommandLineResources(const Resources& resources)
571{
572 hashmap<string, Value::Type> nameTypes;
573
574 foreach (const Resource& resource, resources) {
575 // These fields should only be provided programmatically,
576 // not at the command line.
577 if (Resources::isPersistentVolume(resource)) {
578 return Error(
579 "Persistent volumes cannot be specified at the command line");
580 } else if (Resources::isRevocable(resource)) {
581 return Error(
582 "Revocable resources cannot be specified at the command line; do"
583 " not include a 'revocable' key in the resources JSON");
584 } else if (Resources::isDynamicallyReserved(resource)) {
585 return Error(
586 "Dynamic reservations cannot be specified at the command line; do"
587 " not include a reservation with DYNAMIC type in the resources JSON");
588 }
589
590 if (nameTypes.contains(resource.name()) &&
591 nameTypes[resource.name()] != resource.type()) {
592 return Error(
593 "Resources with the same name ('" + resource.name() + "') but"
594 " different types are not allowed");
595 } else if (!nameTypes.contains(resource.name())) {
596 nameTypes[resource.name()] = resource.type();
597 }
598 }
599
600 return None();
601}
602
603} // namespace internal {
604

Callers 1

parseMethod · 0.70

Calls 1

NoneClass · 0.85

Tested by

no test coverage detected