Skip to content

Complete resource delete plumbing#1407

Open
tgauth wants to merge 3 commits intoPowerShell:mainfrom
tgauth:complete-resource-delete-plumbing
Open

Complete resource delete plumbing#1407
tgauth wants to merge 3 commits intoPowerShell:mainfrom
tgauth:complete-resource-delete-plumbing

Conversation

@tgauth
Copy link
Collaborator

@tgauth tgauth commented Feb 26, 2026

PR Summary

  • add --what-if arg to dsc resource delete command

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds --what-if support to the dsc resource delete CLI flow, wiring the flag from argument parsing through subcommand dispatch into the resource invocation layer, and validating behavior with a new PowerShell test.

Changes:

  • Add --what-if (and -w) to dsc resource delete and plumb it through to resource.delete(..., ExecutionKind::WhatIf).
  • Add delete-command output formatting support and emit structured output for delete what-if results.
  • Add a Pester test asserting dsc resource delete --what-if returns delete what-if metadata.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
dsc/tests/dsc_whatif.tests.ps1 Adds a Pester test validating dsc resource delete --what-if output contains delete what-if messages.
dsc/src/args.rs Extends resource delete CLI args with --what-if and --output-format.
dsc/src/subcommand.rs Plumbs new delete args into the resource_command::delete call.
dsc/src/resource_command.rs Implements what-if execution kind for delete and prints structured output for what-if results.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +289 to +297
DeleteResultKind::SyntheticWhatIf(test_result) => {
match serde_json::to_string(&test_result) {
Ok(json) => write_object(&json, format, false),
Err(err) => {
error!("JSON: {err}");
exit(EXIT_JSON_ERROR);
}
}
}
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the SyntheticWhatIf case you're serializing a TestResult directly, while the native what-if path serializes DeleteResult (which includes the delete-specific _metadata.whatIf shape). This makes dsc resource delete --what-if output schema vary by resource capability, which is hard for callers to consume reliably. Consider always emitting a single delete output shape (e.g., wrap/convert the synthetic TestResult into a DeleteResult or add a discriminator/consistent envelope).

Copilot uses AI. Check for mistakes.
Comment on lines +267 to +270
#[clap(short = 'o', long, help = t!("args.outputFormat").to_string())]
output_format: Option<OutputFormat>,
#[clap(short = 'w', long, visible_aliases = ["dry-run", "noop"], help = t!("args.whatIf").to_string())]
what_if: bool,
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description says this change is only adding --what-if to dsc resource delete, but this hunk also introduces -o/--output-format for the delete subcommand. If this is intended, the PR description (and any CLI docs/changelog if applicable) should be updated to reflect the additional user-facing flag; otherwise consider removing the extra option to avoid an undocumented interface change.

Copilot uses AI. Check for mistakes.
@tgauth tgauth requested a review from SteveL-MSFT February 26, 2026 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants