add WhatIfReturns field to resource manifest#1386
add WhatIfReturns field to resource manifest#1386tgauth wants to merge 5 commits intoPowerShell:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds support for specifying a different set return shape during what-if execution via a new whatIfReturns manifest field, and updates test/registry manifests and tests to exercise state-vs-stateAndDiff scenarios.
Changes:
- Add
whatIfReturnsto the resource manifestsetmethod and honor it duringinvoke_setwhenexecutionType=WhatIf. - Extend
dsctestwhat-if output to optionally emitstateAndDiff(two-line output) and add a new test manifest entry. - Update the Registry resource manifest to rely on
whatIfArg/whatIfReturnsinstead of a dedicatedwhatIfoperation, and add/adjust PowerShell tests.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/dsctest/src/whatif.rs | Adds fromResource field to dsctest what-if state payload. |
| tools/dsctest/src/main.rs | Adds --state-and-diff mode for dsctest what-if output (state + diff). |
| tools/dsctest/src/args.rs | Adds CLI flag to control stateAndDiff output. |
| tools/dsctest/dsctest.dsc.manifests.json | Adds Test/WhatIfReturnDiff resource manifest using whatIfReturns. |
| resources/registry/registry.dsc.resource.json | Migrates Registry manifest to whatIfArg/whatIfReturns and removes dedicated whatIf op. |
| lib/dsc-lib/src/dscresources/resource_manifest.rs | Introduces whatIfReturns on SetMethod. |
| lib/dsc-lib/src/dscresources/command_resource.rs | Uses whatIfReturns to select return parsing behavior for what-if set. |
| dsc/tests/dsc_whatif.tests.ps1 | Adds coverage for whatIfReturns=stateAndDiff behavior. |
| dsc/tests/dsc_resource_set.tests.ps1 | Adjusts assertion for changedProperties shape in what-if set test. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "jsonInputArg": "--input", | ||
| "mandatory": true | ||
| } | ||
| ] | ||
| }, | ||
| "whatIf": { | ||
| "executable": "registry", | ||
| "args": [ | ||
| "config", | ||
| "set", | ||
| "-w", | ||
| }, | ||
| { | ||
| "jsonInputArg": "--input", | ||
| "mandatory": true | ||
| "whatIfArg": "-w" | ||
| } |
There was a problem hiding this comment.
delete.args now includes a whatIfArg: "-w", but the registry config delete subcommand does not accept -w/--what-if (only registry config set defines that flag). In what-if mode this will cause the delete invocation to fail argument parsing. Remove the whatIfArg from the delete args (so DSC falls back to synthetic what-if delete), or add what-if support to the registry delete subcommand and ensure its stdout matches the expected DeleteResult JSON contract.
PR Summary
WhatIfReturnsfield to resource manifestWhatIfReturns(for StateAndDiff scenario)WhatIfArgandWhatIfReturns(for State scenario)PR Context
WhatIfArg, it became clear that there was no way to specify a different return between anActualand aWhatIfexecution forset