| 548 | } |
| 549 | |
| 550 | bool validate_str_arg(std::string_view value, |
| 551 | std::string_view type, |
| 552 | const arg_desc_t& desc, |
| 553 | std::ostream& os) |
| 554 | { |
| 555 | if (type == "CephIPAddr") { |
| 556 | entity_addr_t addr; |
| 557 | if (addr.parse(value)) { |
| 558 | return true; |
| 559 | } else { |
| 560 | os << "failed to parse addr '" << value << "', should be ip:[port]"; |
| 561 | return false; |
| 562 | } |
| 563 | } else if (type == "CephChoices") { |
| 564 | auto choices = desc.find("strings"); |
| 565 | ceph_assert(choices != end(desc)); |
| 566 | auto strings = choices->second; |
| 567 | if (find_first_in(strings, "|", [=](auto choice) { |
| 568 | return (value == choice); |
| 569 | })) { |
| 570 | return true; |
| 571 | } else { |
| 572 | os << "'" << value << "' not belong to '" << strings << "'"; |
| 573 | return false; |
| 574 | } |
| 575 | } else { |
| 576 | // CephString or other types like CephPgid |
| 577 | return true; |
| 578 | } |
| 579 | } |
| 580 | |
| 581 | bool validate_bool(const cmdmap_t& cmdmap, |
| 582 | const arg_desc_t& desc, |
no test coverage detected