Format object labels as a comma-separated key=value string. Labels are sorted by key for deterministic output. Returns an empty string if the map is empty. Values are sanitized to prevent terminal escape sequences.
(labels: &HashMap<String, String>)
| 677 | /// Labels are sorted by key for deterministic output. Returns an empty string |
| 678 | /// if the map is empty. Values are sanitized to prevent terminal escape sequences. |
| 679 | pub fn format_labels(labels: &HashMap<String, String>) -> String { |
| 680 | if labels.is_empty() { |
| 681 | return String::new(); |
| 682 | } |
| 683 | let mut sorted: Vec<_> = labels.iter().collect(); |
| 684 | sorted.sort_by_key(|(k, _)| *k); |
| 685 | sorted |
| 686 | .iter() |
| 687 | .map(|(k, v)| format!("{}={}", sanitize_for_display(k), sanitize_for_display(v))) |
| 688 | .collect::<Vec<_>>() |
| 689 | .join(",") |
| 690 | } |
| 691 | |
| 692 | pub fn provider_name(provider: &openshell_core::proto::Provider) -> &str { |
| 693 | provider |