Skip to content
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

Preserve custom metadata when exporting config #679

Merged
merged 3 commits into from
Mar 10, 2025

Conversation

SteveL-MSFT
Copy link
Member

PR Summary

Previously, the metadata member of a configuration that was being deserialized only filled in the Microsoft.DSC member and unknown fields were not being preserved. Change is to use the flatten all unknown fields and copy them to the resulting exported configuration.

Also changed some places to use Map instead of HashMap as it preserves order.

PR Context

Fix #668

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This PR ensures that any custom metadata fields present in the configuration are preserved during export and updates several type definitions to use ordered maps (Map) instead of unordered HashMaps for consistent ordering. Key changes include:

  • Merging custom metadata from the original configuration with newly generated metadata in the export.
  • Updating metadata, variables, and references types in configuration and context modules to use Map instead of HashMap.
  • Adjusting error messages and metadata field constructions in several functions to reflect these changes.

Reviewed Changes

File Description
dsc_lib/src/configure/mod.rs Updated merge logic for metadata and added the new other field.
dsc_lib/src/configure/config_doc.rs Changed metadata, variables, and parameter types from HashMap to Map.
dsc_lib/src/configure/context.rs Updated references and variables types to use Map instead of HashMap.

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

Comments suppressed due to low confidence (1)

dsc_lib/src/configure/mod.rs:560

  • [nitpick] Consider adding an inline comment to explain the metadata merge logic in invoke_export, clarifying how custom metadata (the 'other' map) from the original configuration is preserved.
match conf.metadata {
@SteveL-MSFT SteveL-MSFT added this to the 3.1-Approved milestone Mar 7, 2025
@SteveL-MSFT SteveL-MSFT added this pull request to the merge queue Mar 10, 2025
Merged via the queue into PowerShell:main with commit c2a24c4 Mar 10, 2025
4 checks passed
@SteveL-MSFT SteveL-MSFT deleted the export-metadata branch March 10, 2025 22:35
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.

config export does not preserve incoming metadata
2 participants