(
path: &Path,
)
| 5496 | } |
| 5497 | |
| 5498 | fn load_profile_import_item( |
| 5499 | path: &Path, |
| 5500 | ) -> Result<ProviderProfileImportItem, ProviderProfileDiagnostic> { |
| 5501 | let source = path.display().to_string(); |
| 5502 | let input = std::fs::read_to_string(path).map_err(|err| { |
| 5503 | profile_file_diagnostic( |
| 5504 | &source, |
| 5505 | format!("failed to read provider profile file: {err}"), |
| 5506 | ) |
| 5507 | })?; |
| 5508 | let profile = match path.extension().and_then(|ext| ext.to_str()) { |
| 5509 | Some("yaml" | "yml") => parse_profile_yaml(&input), |
| 5510 | Some("json") => parse_profile_json(&input), |
| 5511 | _ => { |
| 5512 | return Err(profile_file_diagnostic( |
| 5513 | &source, |
| 5514 | "unsupported provider profile file format".to_string(), |
| 5515 | )); |
| 5516 | } |
| 5517 | } |
| 5518 | .map_err(|err| profile_file_diagnostic(&source, err.to_string()))?; |
| 5519 | |
| 5520 | Ok(ProviderProfileImportItem { |
| 5521 | profile: Some(profile.to_proto()), |
| 5522 | source, |
| 5523 | }) |
| 5524 | } |
| 5525 | |
| 5526 | fn profile_file_diagnostic(source: &str, message: String) -> ProviderProfileDiagnostic { |
| 5527 | ProviderProfileDiagnostic { |
no test coverage detected