Skip to content

Add structured handling for settings - #1690

Open
Mikey Lombardi (He/Him) (michaeltlombardi) wants to merge 8 commits into
PowerShell:mainfrom
michaeltlombardi:gh-1081/main/settings-schematization
Open

Mikey Lombardi (He/Him) (michaeltlombardi) wants to merge 8 commits into
PowerShell:mainfrom
michaeltlombardi:gh-1081/main/settings-schematization

Conversation

@michaeltlombardi

@michaeltlombardi Mikey Lombardi (He/Him) (michaeltlombardi) commented Aug 24, 2026 •

Copy link
Copy Markdown
Collaborator

PR Summary

This PR defines the structure and handling for initializing settings from multiple scopes.

This implementation defines a model for DSC's settings to support defining settings in multiple scopes. Settings defined in higher priority scopes supercede those from lower scopes. The scopes are, in priority order from lowest to highest:

  1. Code defaults, defined in the library code.
  2. Machine, defined in a system-wide preference settings file.
  3. User, defined in a per-user account preference settings file.
  4. Workspace, defined in a preference settings file in the current folder.
  5. Environment, defined as environment variables.
  6. Command line, defined as arguments to the dsc root command.
  7. Policy, defined in a system-wide policy settings file.

The implementation supports the previously defined settings structure, loading settings from each scope, and resolving the settings to enable consistently accessing the DSC settings as needed.

This implementation does not wire the new settings structures through the library and CLI code, it only completes the definition work and provides unit/integration testing for the new code.

PR Context

Part of #1081 to enable better UX for defining and retrieving DSC settings and to support a more maintainable expansion of settings over time.

This comment was marked as resolved.

This comment was marked as resolved.

Prior to this change, DSC accepted settings from multiple sources and
scopes but retrieved those settings adhoc when needed. The settings
were not structured or consistently retrieved and resolved.

This change starts the work for PowerShell#1081 by:

- Adding a new `settings` module to `dsc-lib` to contain the structured
  cascading hierarchy of settings.
- Defining reusable patterns and guidance for maintaining and extending
  the settings that DSC recognizes.
- Providing stubs for writing rust tests where we need to define
  fixtures to replicate reading from files and environment variables.
This change adds the rust integration tests for the `settings` module.
It also introduces helper macros for validating DSC repo schemas and
updates the schema generation tests to cover the newly defined types.
Prior to this change, the implementation for `idiomaticize_string_enum`
incorrectly used the `enumMarkdownDescriptions` keyword instead of the
correct `markdownEnumDescriptions` keyword.

This change fixes the implementation and tests.
Prior to this change, the `schema_i18n` macro only supported
passing a single string literal as the input value. This made
it impossible to correctly construct calls to the macro when
needing to compose the dotpath through a macro or dynamic
lookup.

This change:

- Enables the macro to accept multiple string literals or
  an arbitrary expression.
- Adds documentation to the macro.
- Adds the missing header comments to the source file.
Prior to this change, the i18n tests would find any apparent
usage of the `t!` macro in a file. This unfortunately also
included documentation comments, which raised errors for
undefined translation strings that are not expected to be
defined.

This change strips lines that begin with a comment before
searching for the expected patterns.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants