Add Windows environment variable resource - #1675
Open
Steve Lee (SteveL-MSFT) wants to merge 3 commits into
Open
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new Windows-only DSC Rust resource (Microsoft.Windows/EnvironmentVariableList) to manage persistent user and machine environment variables via the registry, with support for scalar values and PATH-style list semantics.
Changes:
- Introduces the new
resources/environment_variableRust resource with input validation, registry read/write/remove behavior, and localized user-facing messages. - Adds the resource manifest + embedded schema and wires the new crate into the workspace build.
- Adds Pester coverage for
get/setbehaviors including path merge/dedup, defaults, deletion, and the non-elevated AllUsers error path.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| resources/environment_variable/src/main.rs | Resource entrypoint, CLI arg parsing, exit codes, JSON output/error formatting, and input validation plumbing. |
| resources/environment_variable/src/types.rs | Input/output types and validation rules (scope, value vs pathValue, duplicate identities, etc.). |
| resources/environment_variable/src/environment.rs | Windows registry implementation for get/set/remove and PATH merge/dedup behavior; elevation gating for AllUsers writes. |
| resources/environment_variable/locales/en-us.toml | i18n strings for validation and runtime errors. |
| resources/environment_variable/environment_variable.dsc.resource.json | Resource manifest and embedded JSON schema for environmentVariables list. |
| resources/environment_variable/Cargo.toml | New resource crate definition and Windows-only dependencies. |
| resources/environment_variable/.project.data.json | Build/packaging metadata for the resource binary and manifest. |
| resources/environment_variable/tests/environment_variable_get.tests.ps1 | Pester tests for get behavior (default scope, pathValue projection, missing vars, ordering). |
| resources/environment_variable/tests/environment_variable_set.tests.ps1 | Pester tests for set behavior (scalar, path actions, dedup, deletion, multi-set, invalid input, AllUsers elevation error). |
| Cargo.toml | Adds the new resource crate to workspace members/default-members/Windows set. |
| Cargo.lock | Locks the new environment_variable package into the workspace dependency graph. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Steve Lee (SteveL-MSFT)
requested review from
Mikey Lombardi (He/Him) (michaeltlombardi) and
Tess Gauthier (tgauth)
August 13, 2026 21:00
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
😲 Code Coverage ReportChanged Code Coverage100% (100% coverage)
🔵 Full Codebase Coverage82% (good)
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Windows DSC needs a native resource for managing persistent user and machine environment variables without requiring callers to manipulate registry paths and value formatting directly.
This adds
Microsoft.Windows/EnvironmentVariableList, a Windows-only Rust resource with anenvironmentVariableslist schema. It supports scalar values, path arrays with prepend/append/clobber behavior, case-insensitive path deduplication, scope and existence defaults, and deletion through_exist: false. Values are stored in the appropriate CurrentUser or AllUsers registry location, preserving expandable-string behavior when needed.AllUsers reads remain available without elevation, while AllUsers writes and removals fail before any mutation with a dedicated actionable elevation error. CurrentUser operations therefore do not unnecessarily require an elevated security context.
Pester coverage exercises get and set behavior, list ordering, defaults, all path actions, deduplication, deletion, invalid input, and the non-elevated AllUsers error path.