Skip to content

Enable resources to return metadata #947

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

Merged
merged 7 commits into from
Jul 9, 2025

Conversation

SteveL-MSFT
Copy link
Member

@SteveL-MSFT SteveL-MSFT commented Jul 8, 2025

PR Summary

Enable resources to return _metadata object that gets populated into the resource metadata field. Reserved Microsoft.DSC property is ignored, but a warning message is emitted. Works for all operations.

Also some reordering of existing code to keep it in proper order.

PR Context

Fix #467

@SteveL-MSFT SteveL-MSFT requested a review from tgauth July 8, 2025 04:32
@SteveL-MSFT SteveL-MSFT marked this pull request as ready for review July 8, 2025 04:32
@SteveL-MSFT SteveL-MSFT requested a review from Copilot July 8, 2025 15:40
Copy link
Contributor

@Copilot 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

Enable resources to return a _metadata object that’s merged into the resource’s metadata field, ignoring any Microsoft.DSC entries (with a warning), and applied consistently across all operations.

  • Add Metadata struct and CLI support in dsctest for emitting metadata
  • Enhance configurator to extract _metadata into Resource*Result.metadata and emit warnings for reserved keys
  • Introduce manifest, locale strings, and end-to-end tests for the new Test/Metadata resource

Reviewed Changes

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

Show a summary per file
File Description
tools/dsctest/src/metadata.rs Define Metadata struct for CLI
tools/dsctest/src/main.rs Register metadata subcommand and serialize metadata outputs
tools/dsctest/src/args.rs Add Metadata variant to CLI args
tools/dsctest/metadata.dsc.resource.json Add manifest for Test/Metadata resource
dsc_lib/src/configure/mod.rs Extract _metadata and integrate into resource metadata
dsc_lib/locales/en-us.toml Add messages for ignored Microsoft.DSC and invalid metadata
dsc/tests/dsc_metadata.tests.ps1 Add tests verifying metadata extraction and warning emission
Comments suppressed due to low confidence (2)

dsc/tests/dsc_metadata.tests.ps1:27

  • [nitpick] Consider adding an assertion for metadata.count to ensure the count property is populated correctly as part of the metadata object.
        $out.results[0].metadata.myNumber | Should -Be 42

tools/dsctest/src/main.rs:134

  • [nitpick] The loop variable i is ambiguous; consider renaming it (e.g., index) for better readability.
            for i in 0..count {

@SteveL-MSFT SteveL-MSFT added this pull request to the merge queue Jul 9, 2025
Merged via the queue into PowerShell:main with commit beb05fb Jul 9, 2025
4 checks passed
@SteveL-MSFT SteveL-MSFT deleted the resource-metadata branch July 9, 2025 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow resources to return metadata
2 participants