(provider: &openshell_core::proto::Provider)
| 760 | } |
| 761 | |
| 762 | fn provider_to_redacted_yaml(provider: &openshell_core::proto::Provider) -> String { |
| 763 | let mut out = String::new(); |
| 764 | out.push_str("name: "); |
| 765 | out.push_str(&yaml_scalar(provider_name(provider))); |
| 766 | out.push('\n'); |
| 767 | out.push_str("type: "); |
| 768 | out.push_str(&yaml_scalar(&provider.r#type)); |
| 769 | out.push('\n'); |
| 770 | |
| 771 | out.push_str("credentials:"); |
| 772 | if provider.credentials.is_empty() { |
| 773 | out.push_str(" {}\n"); |
| 774 | } else { |
| 775 | out.push('\n'); |
| 776 | let mut keys = provider.credentials.keys().collect::<Vec<_>>(); |
| 777 | keys.sort(); |
| 778 | for key in keys { |
| 779 | out.push_str(" "); |
| 780 | out.push_str(key); |
| 781 | out.push_str(": \"<redacted>\"\n"); |
| 782 | } |
| 783 | } |
| 784 | |
| 785 | out.push_str("config:"); |
| 786 | if provider.config.is_empty() { |
| 787 | out.push_str(" {}\n"); |
| 788 | } else { |
| 789 | out.push('\n'); |
| 790 | let mut entries = provider.config.iter().collect::<Vec<_>>(); |
| 791 | entries.sort_by_key(|(key, _)| *key); |
| 792 | for (key, value) in entries { |
| 793 | out.push_str(" "); |
| 794 | out.push_str(key); |
| 795 | out.push_str(": "); |
| 796 | out.push_str(&yaml_scalar(value)); |
| 797 | out.push('\n'); |
| 798 | } |
| 799 | } |
| 800 | |
| 801 | if !provider.credential_expires_at_ms.is_empty() { |
| 802 | out.push_str("credential_expires_at_ms:\n"); |
| 803 | let mut entries = provider.credential_expires_at_ms.iter().collect::<Vec<_>>(); |
| 804 | entries.sort_by_key(|(key, _)| *key); |
| 805 | for (key, value) in entries { |
| 806 | out.push_str(" "); |
| 807 | out.push_str(key); |
| 808 | out.push_str(": "); |
| 809 | out.push_str(&value.to_string()); |
| 810 | out.push('\n'); |
| 811 | } |
| 812 | } |
| 813 | |
| 814 | if let Some(metadata) = &provider.metadata { |
| 815 | out.push_str("metadata:\n"); |
| 816 | out.push_str(" id: "); |
| 817 | out.push_str(&yaml_scalar(&metadata.id)); |
| 818 | out.push('\n'); |
| 819 | out.push_str(" resource_version: "); |
no test coverage detected