feat: implement export filter functionality for resource exports#1621
feat: implement export filter functionality for resource exports#1621Gijsreyn wants to merge 16 commits into
Conversation
ba1baec to
664abad
Compare
There was a problem hiding this comment.
Pull request overview
Implements engine-side post-filtering for dsc config export results via a new exportFilter resource directive, enabling consistent wildcard/equality filtering even for resources that don’t implement native export filtering.
Changes:
- Adds
exportFilterto the configuration resource directives schema and applies it in the export pipeline afterresource.export(...). - Introduces
configure::export_filtermatching logic (case-insensitive*wildcard for strings; OR across filter objects, AND within each object) plus unit tests. - Adds Pester coverage for
exportFilterbehavior and updates thedsctestexport resource to emit anameproperty for filtering.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/dsctest/src/main.rs | Emits per-instance name values to enable filter-driven tests. |
| tools/dsctest/src/export.rs | Extends the test export payload schema with optional name. |
| lib/dsc-lib/src/dscresources/command_resource.rs | Adjusts when “export filtering not supported” is raised (only for non-empty input). |
| lib/dsc-lib/src/configure/mod.rs | Wires exportFilter from directives into the export pipeline. |
| lib/dsc-lib/src/configure/export_filter.rs | Adds the engine-side filtering implementation + Rust unit tests. |
| lib/dsc-lib/src/configure/config_doc.rs | Adds export_filter directive field to the config document model/schema. |
| lib/dsc-lib/locales/en-us.toml | Adds localized message for filter reduction logging. |
| dsc/tests/dsc_export.tests.ps1 | Adds integration tests validating exportFilter behavior across scenarios. |
| dsc/src/resource_command.rs | Updates call site for the changed export helper function signature. |
SteveL-MSFT
left a comment
There was a problem hiding this comment.
Changes look fine, but can you remove the wildcard filtering support in the service, firewall, and dism resources? I would expect all the tests to still pass (assuming they don't call the resource exe directly, if so, they would need to be udpated to go through dsc).
|
@SteveL-MSFT - good catch, but it had some caveats. I've replaced them with tests that append |
|
@Gijsreyn you have a test failure and can you see if you can improve the code coverage? |
|
@SteveL-MSFT - I'm a bit surprised by the coverage report. The previous run was 41%, and after adding more tests, it dropped to 21% in the latest one. |
|
@Gijsreyn let me look into the CC report, I think the problem is that deleted lines is being calculated wrong as not covered |
Files without LCOV data (e.g., platform-specific code behind #[cfg(windows)] when only Linux coverage is collected) were incorrectly counting ALL added lines as uncovered, including non-executable lines like comments and blanks. This caused coverage to drop significantly when Windows-only files were modified in a PR. Fix: skip files without LCOV data since coverage cannot be determined for uninstrumented code. Also handle the '\ No newline at end of file' diff marker which could cause off-by-one line number errors after deleted lines. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
@Gijsreyn as part of this PR https://github.com/PowerShell/DSC/pull/1566/changes#diff-3c6f13d4710c208b61e3b3b90dd39808010bd0ef8788005fd7ee23812fcb4e9dR1504, there is a new property in the resource manifest indicating it doesn't support filtering so it all gets handled by the engine. I would expect all the resources mentioned here would have that set and not do any comparisons within the resource and simply returns all instances. Be sure to pick up the last commit that fixes the codecoverage. |
PR Summary
Adds engine-side post-filtering for export via a new exportFilter resource directive.
PR Context
Fixes #1486.