Skip to content

Fix adding what-if capability to resources#1502

Open
SteveL-MSFT wants to merge 3 commits intoPowerShell:mainfrom
SteveL-MSFT:whatif-cap
Open

Fix adding what-if capability to resources#1502
SteveL-MSFT wants to merge 3 commits intoPowerShell:mainfrom
SteveL-MSFT:whatif-cap

Conversation

@SteveL-MSFT
Copy link
Copy Markdown
Member

PR Summary

There's 2 ways to detect if a resource supports what-if:

  1. set or delete has the whatIfArg arg
  2. resource has the old whatIf operation

Changed the code from using a Vec to using a HashSet to avoid having to check if what-if was already added to capabiltiies.

PR Context

Fix #1501

Copy link
Copy Markdown
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

This PR fixes resource capability detection so dsc resource list correctly reports the whatIf capability when a resource supports what-if mode via either the newer whatIfArg mechanism on set/delete or the legacy whatIf operation.

Changes:

  • Detect whatIf capability from set.args / delete.args containing whatIfArg, and from the legacy whatIf operation in the manifest.
  • Switch capability accumulation in discovery from Vec to HashSet to avoid duplicates.
  • Add/extend tests and update the table capability legend to include w for what-if.

Reviewed changes

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

File Description
lib/dsc-lib/src/dscresources/dscresource.rs Makes Capability hashable/equatable to support set-based capability accumulation.
lib/dsc-lib/src/discovery/command_discovery.rs Implements the updated what-if capability detection logic while parsing manifests.
dsc/tests/dsc_resource_list.tests.ps1 Adds a Pester test intended to validate what-if capability reporting in dsc resource list.
dsc/src/subcommand.rs Updates table capability display mapping to include WhatIf as w.

Comment thread lib/dsc-lib/src/discovery/command_discovery.rs
Comment thread lib/dsc-lib/src/discovery/command_discovery.rs Outdated
Comment thread dsc/tests/dsc_resource_list.tests.ps1
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.

DSC doesn't populate the whatIf capability for resources

2 participants