Add support for adapted resource manifests for PowerShell 7 adapter#1415
Open
SteveL-MSFT wants to merge 8 commits intoPowerShell:mainfrom
Open
Add support for adapted resource manifests for PowerShell 7 adapter#1415SteveL-MSFT wants to merge 8 commits intoPowerShell:mainfrom
SteveL-MSFT wants to merge 8 commits intoPowerShell:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds adapted resource manifest support for the PowerShell 7 adapter by allowing the engine to pass a resourcePath into the adapter, importing the module directly, and short-circuiting legacy discovery for faster adapted-manifest operations. This also wires resourcePathArg through the adapter manifests and adds test resources + Pester coverage for the new behavior (including the WinPS “not supported” path).
Changes:
- Add
-ResourcePathhandling to the PowerShell adapter entrypoint and pass it through adapter manifests. - Enhance module/resource discovery to consider already-imported modules and add a fast-path cache refresh for imported DSC modules.
- Add adapted-manifest test resources and Pester tests to validate list/get behavior and WinPS unsupported behavior.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| adapters/powershell/psDscAdapter/psDscAdapter.psm1 | Adds imported-module inclusion in discovery and a fast-path in Invoke-DscCacheRefresh; adjusts module import usage for type lookup. |
| adapters/powershell/psDscAdapter/powershell.resource.ps1 | Adds ResourcePath parameter, imports the specified module for adapted manifests, and throws on WinPS. |
| adapters/powershell/PowerShell_adapter.dsc.resource.json | Adds resourcePathArg wiring for get/set/test/export operations. |
| adapters/powershell/WindowsPowerShell_adapter.dsc.resource.json | Adds resourcePathArg wiring so WinPS adapter can detect adapted manifests and throw. |
| adapters/powershell/Tests/PSAdaptedTestClassResource.psm1 | New class-based DSC test resources for adapted manifests. |
| adapters/powershell/Tests/PSAdaptedTestClassResource.psd1 | New test module manifest exporting DSC resources and capabilities. |
| adapters/powershell/Tests/PSAdaptedTestClassResource.dsc.adaptedResource.json | New adapted resource manifest for PS7 adapter scenario. |
| adapters/powershell/Tests/WinPSAdaptedTestClassResource.dsc.adaptedResource.json | New adapted resource manifest targeting WinPS adapter (unsupported). |
| adapters/powershell/Tests/PSAdapted.tests.ps1 | New Pester tests validating adapted-manifest discovery and operations. |
| adapters/powershell/Tests/.project.data.json | Ensures test artifacts are copied into the test environment. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary
Add support for PowerShell 7 adapted resource manifests.
Note that WindowsPowerShell isn't supported because it relies on PSDSC module using
Get-DscResourcewhich only supports finding resources installed for the system.Also some general fixes found during debugging where splitting
$env:PSModulePathcould have empty segments which broke the code since it was now passing$nullto a cmdlet.To keep the existing code working, the main change in the adapter is when
resourcePathis supplied to import that module and then subsequent code that creates internal structure with the DSC resource tries to use the loaded module first before falling back to existing discovery code. This also means that for an adapted resource manifest, it entirely skips the legacy discovery path so it's much faster.While testing the change, I noticed that currently there is no way to pass the resource version if specified to the adapter in single mode, created #1414 to handle later, but not blocking.
PR Context
Fix #1412