Conversation
There was a problem hiding this comment.
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) todsc resource deleteand plumb it through toresource.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-ifreturns 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.
| 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); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
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).
| #[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, |
There was a problem hiding this comment.
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.
PR Summary
--what-ifarg todsc resource deletecommand