Load credential descriptors from a YAML file.
(path: &Path)
| 252 | |
| 253 | /// Load credential descriptors from a YAML file. |
| 254 | pub fn load_credentials(path: &Path) -> Result<Vec<Credential>> { |
| 255 | let contents = std::fs::read_to_string(path) |
| 256 | .into_diagnostic() |
| 257 | .wrap_err_with(|| format!("reading credentials file {}", path.display()))?; |
| 258 | let raw: CredentialsFile = serde_yml::from_str(&contents) |
| 259 | .into_diagnostic() |
| 260 | .wrap_err("parsing credentials YAML")?; |
| 261 | |
| 262 | Ok(raw |
| 263 | .credentials |
| 264 | .into_iter() |
| 265 | .map(|c| Credential { |
| 266 | name: c.name, |
| 267 | cred_type: c.cred_type, |
| 268 | scopes: c.scopes, |
| 269 | injected_via: c.injected_via, |
| 270 | target_hosts: c.target_hosts, |
| 271 | }) |
| 272 | .collect()) |
| 273 | } |
| 274 | |
| 275 | fn parse_api_registry(contents: &str, source: &str) -> Result<ApiCapability> { |
| 276 | let raw: ApiRegistryDef = serde_yml::from_str(contents) |
no outgoing calls
no test coverage detected