MCPcopy Index your code
hub / github.com/PowerShell/DSC / export

Function export

dsc/src/resource_command.rs:330–355  ·  view source on GitHub ↗
(dsc: &mut DscManager, resource_type: &FullyQualifiedTypeName, version: Option<&ResourceVersionReq>, input: &str, format: Option<&OutputFormat>)

Source from the content-addressed store, hash-verified

328}
329
330pub 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]
358pub fn get_resource<'a>(dsc: &'a mut DscManager, resource: &FullyQualifiedTypeName, version: Option<&ResourceVersionReq>) -> Option<&'a DscResource> {

Callers 1

resourceFunction · 0.85

Calls 5

get_resourceFunction · 0.85
write_objectFunction · 0.85
newFunction · 0.50
to_stringFunction · 0.50

Tested by

no test coverage detected