(dsc: &mut DscManager, resource_type: &FullyQualifiedTypeName, version: Option<&ResourceVersionReq>, input: &str, format: Option<&OutputFormat>)
| 328 | } |
| 329 | |
| 330 | pub fn export(dsc: &mut DscManager, resource_type: &FullyQualifiedTypeName, version: Option<&ResourceVersionReq>, input: &str, format: Option<&OutputFormat>) { |
| 331 | let Some(dsc_resource) = get_resource(dsc, resource_type, version) else { |
| 332 | error!("{}", DscError::ResourceNotFound(resource_type.to_string(), version.map_or(String::new(), |v| v.to_string())).to_string()); |
| 333 | exit(EXIT_DSC_RESOURCE_NOT_FOUND); |
| 334 | }; |
| 335 | |
| 336 | if dsc_resource.kind == Kind::Adapter { |
| 337 | error!("{}: {}", t!("resource_command.invalidOperationOnAdapter"), dsc_resource.type_name); |
| 338 | exit(EXIT_DSC_ERROR); |
| 339 | } |
| 340 | |
| 341 | let mut conf = Configuration::new(); |
| 342 | if let Err(err) = add_resource_export_results_to_configuration(dsc_resource, &mut conf, input) { |
| 343 | error!("{err}"); |
| 344 | exit(EXIT_DSC_ERROR); |
| 345 | } |
| 346 | |
| 347 | let json = match serde_json::to_string(&conf) { |
| 348 | Ok(json) => json, |
| 349 | Err(err) => { |
| 350 | error!("JSON: {err}"); |
| 351 | exit(EXIT_JSON_ERROR); |
| 352 | } |
| 353 | }; |
| 354 | write_object(&json, format, false); |
| 355 | } |
| 356 | |
| 357 | #[must_use] |
| 358 | pub fn get_resource<'a>(dsc: &'a mut DscManager, resource: &FullyQualifiedTypeName, version: Option<&ResourceVersionReq>) -> Option<&'a DscResource> { |
no test coverage detected