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

Function delete

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

Source from the content-addressed store, hash-verified

259}
260
261pub fn delete(dsc: &mut DscManager, resource_type: &FullyQualifiedTypeName, version: Option<&ResourceVersionReq>, input: &str, format: Option<&OutputFormat>, what_if: bool) {
262 let Some(resource) = get_resource(dsc, resource_type, version) else {
263 error!("{}", DscError::ResourceNotFound(resource_type.to_string(), version.map_or(String::new(), |v| v.to_string())));
264 exit(EXIT_DSC_RESOURCE_NOT_FOUND);
265 };
266
267 debug!("{} {} {:?}", resource.type_name, t!("resource_command.implementedAs"), resource.implemented_as);
268 if resource.kind == Kind::Adapter {
269 error!("{}: {}", t!("resource_command.invalidOperationOnAdapter"), resource.type_name);
270 exit(EXIT_DSC_ERROR);
271 }
272
273 let execution_kind = if what_if { ExecutionKind::WhatIf } else { ExecutionKind::Actual };
274
275 match resource.delete(input, &execution_kind) {
276 Ok(result) => {
277 match result {
278 DeleteResultKind::ResourceActual => {
279 },
280 DeleteResultKind::ResourceWhatIf(delete_result) => {
281 match serde_json::to_string(&delete_result) {
282 Ok(json) => write_object(&json, format, false),
283 Err(err) => {
284 error!("JSON: {err}");
285 exit(EXIT_JSON_ERROR);
286 }
287 }
288 },
289 DeleteResultKind::SyntheticWhatIf(_) => {
290 info!("{} {}", resource.type_name, t!("resource_command.syntheticWhatIf"));
291 }
292 }
293 },
294 Err(err) => {
295 error!("{err}");
296 exit(EXIT_DSC_ERROR);
297 }
298 }
299}
300
301pub fn schema(dsc: &mut DscManager, resource_type: &FullyQualifiedTypeName, version: Option<&ResourceVersionReq>, format: Option<&OutputFormat>) {
302 let Some(resource) = get_resource(dsc, resource_type, version) else {

Callers 1

resourceFunction · 0.85

Calls 4

get_resourceFunction · 0.85
write_objectFunction · 0.85
to_stringFunction · 0.50
deleteMethod · 0.45

Tested by

no test coverage detected