-
Notifications
You must be signed in to change notification settings - Fork 55
Enable support for adapted resource manifests #1375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Enable support for adapted resource manifests #1375
Conversation
There was a problem hiding this 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 enables support for adapted resource manifests, allowing resources to pre-define a simpler manifest pointing to an adapter without requiring the adapter to perform discovery. The implementation includes schema changes to DscResource, new discovery logic for adapted resources, and a new resourcePathArg argument kind to pass resolved paths to adapters.
Changes:
- Added support for adapted resource manifests with a new
adaptedResourcesarray in manifest lists and standalone.dsc.adaptedresource.*files - Refactored
DscResourcestruct to makepathanddirectoryprivate with accessor methods, and changed several fields toOption<>types for flexibility - Added
CommandResourceInfostruct andresourcePathArgto pass resource paths to adapters without requiring discovery
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/test_group_resource/src/main.rs | Updated test resource to use new DscResource::new() pattern and set fields individually |
| tools/dsctest/src/main.rs | Added resource_path parameter to adapter command |
| tools/dsctest/src/args.rs | Added resource_path optional argument to adapter subcommand |
| tools/dsctest/src/adapter.rs | Enhanced adapter to handle resource_path and added support for Adapted/Three resource type |
| tools/dsctest/dsctest.dsc.manifests.json | Added adaptedResources array with test resources and resourcePathArg to adapter manifest |
| tools/dsctest/adaptedTest.dsc.adaptedResource.json | New standalone adapted resource manifest for testing |
| tools/dsctest/.project.data.json | Added adapted resource file to copy list |
| lib/dsc-lib/src/extensions/discover.rs | Updated to use CommandResourceInfo for argument processing |
| lib/dsc-lib/src/dscresources/resource_manifest.rs | Added ResourcePath arg kind and removed import_manifest function |
| lib/dsc-lib/src/dscresources/dscresource.rs | Major refactoring of DscResource struct with private path/directory fields, accessor methods, and changed field types to Option<> |
| lib/dsc-lib/src/dscresources/command_resource.rs | Added CommandResourceInfo struct and updated all invoke functions to accept &DscResource instead of &ResourceManifest |
| lib/dsc-lib/src/dscerror.rs | Added new error types for missing path and directory |
| lib/dsc-lib/src/discovery/command_discovery.rs | Added logic to discover adapted resources from manifests and manifest lists with condition evaluation |
| lib/dsc-lib/locales/en-us.toml | Added new localized strings for adapted resources |
| dsc/tests/dsc_adapter.tests.ps1 | Added comprehensive test cases for adapted resource manifests |
| dsc/src/subcommand.rs | Updated to work with new DscResource structure and removed import_manifest usage |
| build.data.json | Added adapted resource file to build configuration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
The |
PR Summary
Enable support for adapted resource manifests. This allows adapted resources to pre-define a simpler resource manifest pointing to an adapter without requiring the adapter to perform discovery. The schema is what adapters are expected to return for resources via the
listoperation. Thepathfield is required and must point to an existing file. The adapted manifest also supports an optionalconditionfield that ignores the resource if it evaluates tofalse.For manifest lists, there is a new
adaptedResourcesarray property.Much of the changes is that instead of passing the resource type name across the internal APIs, it passes a
DscResourceinstance instead. Because thepathanddirectoryfields ofDscResourceare private, some code was changed to use::new()to construct and populate the public fields whileset_path()andset_directory()are needed to set them.get_path()andget_directory()will return an error if either are not populated (this shouldn't happen unless there's a bug in the engine). Because theDscResourcestruct is being reused as the adapted resource manifest schema, several fields needed to be changed toOption<>.To enable future additions, a new
CommandResourceInfostruct is used to pass the resource type name and optionally the path. The path is needed with a new arg kindresourcePathArgwhich will pass the fully resolved path to the adapter so it doesn't need to perform discovery (update to PSAdapter will come separately).The
Test/Adapterresource was enhanced to cover the new test cases.It appears that resource output validation against its schema wasn't enforced and this PR fixes that so some resources/tests needed to be udpated.
PR Context
Thought I had opened an issue for this, but can't find it