| 579 | hashmap<string, Value::Type> nameTypes; |
| 580 | |
| 581 | foreach (const Resource& resource, resources) { |
| 582 | // These fields should only be provided programmatically, |
| 583 | // not at the command line. |
| 584 | if (Resources::isPersistentVolume(resource)) { |
| 585 | return Error( |
| 586 | "Persistent volumes cannot be specified at the command line"); |
| 587 | } else if (Resources::isRevocable(resource)) { |
| 588 | return Error( |
| 589 | "Revocable resources cannot be specified at the command line; do" |
| 590 | " not include a 'revocable' key in the resources JSON"); |
| 591 | } else if (Resources::isDynamicallyReserved(resource)) { |
| 592 | return Error( |
| 593 | "Dynamic reservations cannot be specified at the command line; do" |
| 594 | " not include a reservation with DYNAMIC type in the resources JSON"); |
| 595 | } |
| 596 | |
| 597 | if (nameTypes.contains(resource.name()) && |
| 598 | nameTypes[resource.name()] != resource.type()) { |
| 599 | return Error( |
| 600 | "Resources with the same name ('" + resource.name() + "') but" |
| 601 | " different types are not allowed"); |
| 602 | } else if (!nameTypes.contains(resource.name())) { |
| 603 | nameTypes[resource.name()] = resource.type(); |
| 604 | } |
| 605 | } |
| 606 | |
| 607 | return None(); |
| 608 | } |
no test coverage detected