KEMBAR78
Add `context()` function and refactor osinfo by SteveL-MSFT · Pull Request #1103 · PowerShell/DSC · GitHub
Skip to content

Conversation

@SteveL-MSFT
Copy link
Member

PR Summary

Add a new context() function that returns an object that contains both os info and security context. This can be used for condition: execution.

This involved refactoring osinfo where the main part is now a lib used by the function and the OSInfo resource. Updated OSinfo resource to version 1.0.0 as there's now a breaking change. Bitness is no longer a string, but instead is a number or not returned if it cannot be determined.

PR Context

Fix #1012

@SteveL-MSFT SteveL-MSFT requested a review from Copilot September 13, 2025 19:59
@SteveL-MSFT SteveL-MSFT added Doc-Impact Schema-Impact Change requires updating a canonical schema for configs or manifests labels Sep 13, 2025
@SteveL-MSFT SteveL-MSFT requested a review from tgauth September 13, 2025 19:59
Copy link
Contributor

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

This PR introduces a new context() function that provides both OS information and security context for conditional execution. It also refactors the osinfo module by extracting shared functionality into a library.

  • Creates a new context() function returning OS info and security context in a single object
  • Refactors osinfo to use a shared library (osinfo_lib) for code reuse
  • Updates OSInfo to version 1.0.0 with breaking changes to the bitness field format

Reviewed Changes

Copilot reviewed 9 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
osinfo/src/main.rs Refactored to use the new osinfo_lib library instead of local config module
osinfo/Cargo.toml Updated version to 1.0.0 and replaced direct dependencies with osinfo_lib
lib/osinfo_lib/src/lib.rs New library with refactored OsInfo struct, removing $id field and changing bitness to Option
lib/osinfo_lib/cargo.toml New cargo configuration for the osinfo library
dsc_lib/src/functions/mod.rs Added the new context function to the function dispatcher
dsc_lib/src/functions/context.rs New context function implementation
dsc_lib/Cargo.toml Added osinfo_lib dependency
dsc/tests/dsc_functions.tests.ps1 Added test coverage for the new context function
build.ps1 Updated build script to include the new osinfo_lib

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@SteveL-MSFT SteveL-MSFT added this pull request to the merge queue Sep 15, 2025
Merged via the queue into PowerShell:main with commit 9c9bd9d Sep 15, 2025
4 checks passed
@SteveL-MSFT SteveL-MSFT deleted the context-function branch September 15, 2025 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Doc-Impact Schema-Impact Change requires updating a canonical schema for configs or manifests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Condition-based elevation resource execution

2 participants