(registry_dir: &Path)
| 321 | } |
| 322 | |
| 323 | fn load_api_registries_from_dir(registry_dir: &Path) -> Result<HashMap<String, ApiCapability>> { |
| 324 | let mut api_registries = HashMap::new(); |
| 325 | let apis_dir = registry_dir.join("apis"); |
| 326 | if apis_dir.is_dir() { |
| 327 | let entries = std::fs::read_dir(&apis_dir) |
| 328 | .into_diagnostic() |
| 329 | .wrap_err_with(|| format!("reading directory {}", apis_dir.display()))?; |
| 330 | for entry in entries { |
| 331 | let entry = entry.into_diagnostic()?; |
| 332 | let path = entry.path(); |
| 333 | if path.extension().is_some_and(|ext| ext == "yaml") { |
| 334 | let contents = std::fs::read_to_string(&path) |
| 335 | .into_diagnostic() |
| 336 | .wrap_err_with(|| format!("reading {}", path.display()))?; |
| 337 | let api = parse_api_registry(&contents, &path.display().to_string())?; |
| 338 | api_registries.insert(api.api.clone(), api); |
| 339 | } |
| 340 | } |
| 341 | } |
| 342 | Ok(api_registries) |
| 343 | } |
| 344 | |
| 345 | /// Load credentials with API registries from the embedded registry. |
| 346 | pub fn load_credential_set_embedded(credentials_path: &Path) -> Result<CredentialSet> { |
no test coverage detected