Skip to content

Add Windows environment variable resource - #1675

Open
Steve Lee (SteveL-MSFT) wants to merge 3 commits into
mainfrom
stevel-msft-add-windows-environment-resource
Open

Add Windows environment variable resource#1675
Steve Lee (SteveL-MSFT) wants to merge 3 commits into
mainfrom
stevel-msft-add-windows-environment-resource

Conversation

@SteveL-MSFT

Copy link
Copy Markdown
Member

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 an environmentVariables list 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.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings August 13, 2026 20:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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_variable Rust 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/set behaviors 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 (POWERSHELL HE/HIM) (from Dev Box) and others added 2 commits August 13, 2026 14:05
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown

😲 Code Coverage Report

Changed Code Coverage

100% (100% coverage)

Metric Value
Changed lines analyzed 0
Lines covered by tests 0
Coverage percentage 100%

🔵 Full Codebase Coverage

82% (good)

Metric Value
Total executable lines 18748
Lines covered by tests 15431
Coverage percentage 82%

Changed code coverage measures only Rust lines added/modified in this PR.
Full codebase coverage measures all instrumented Rust lines across the project.

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