| 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 | } |
no test coverage detected