Skip to content

Enable passing Bicep files directly to dsc #997

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

Merged
merged 13 commits into from
Jul 24, 2025

Conversation

SteveL-MSFT
Copy link
Member

@SteveL-MSFT SteveL-MSFT commented Jul 24, 2025

PR Summary

New import extension where the output to stdout needs to be a JSON string representing a valid DSC config file.
Bicep extension that implements this requiring the bicep exe to be in PATH to transpile the bicep file to JSON.
Still need to resolve with Bicep to not strictly validate the version to be in date format to allow semver or the word latest.

Some other changes:

  • reformatted/ordered some of the use statements to make it more organized
  • Discovery and DscManager new() no longer needs to return a DscError since no code is run for creation, so removed the ? operator in many places
  • Add new get_extensions() function to discovery which is used by dsc host since that is where file reading happens rather than in dsc_lib
  • since bicep takes a positional arg for the file path, the args specified in the manifest can be an empty string and no arg name is passed, just the arg value (file path)

Note that until DSC support in Bicep is out of Experimental status, you must have a bicepconfig.json that enables that feature:

{
  "experimentalFeaturesEnabled": {
    "desiredStateConfiguration": true
  }
}

Also made change to PSScript multi-warning test since traces are async, order is not guaranteed.

PR Context

Part of #976

Copy link
Contributor

@Copilot 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 Bicep extension for DSC that enables importing Bicep files directly by transpiling them to JSON using the bicep executable. The implementation includes a new import capability for extensions and refactors the DscManager initialization to remove unnecessary error handling.

  • Adds new import extension capability with support for file extension-based routing
  • Implements Bicep extension that transpiles .bicep files to JSON using the bicep CLI
  • Refactors DscManager and Discovery constructors to remove Result return types since no fallible operations occur during initialization

Reviewed Changes

Copilot reviewed 17 out of 20 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
extensions/bicep/bicep.dsc.extension.json Extension manifest defining Bicep import capability
extensions/bicep/bicep.tests.ps1 PowerShell tests for Bicep extension functionality
dsc_lib/src/extensions/import.rs New module defining import method structures and argument types
dsc_lib/src/extensions/dscextension.rs Adds import capability and file processing logic
dsc_lib/src/discovery/mod.rs Adds extension discovery and capability filtering
dsc/src/util.rs Integrates import extensions into file processing pipeline
dsc/examples/hello_world.dsc.bicep Example Bicep file for testing
Comments suppressed due to low confidence (1)

dsc_lib/src/discovery/mod.rs:77

  • [nitpick] The method name get_extensions is ambiguous as it could imply retrieving all extensions or extensions with specific capabilities. Consider renaming to get_extensions_by_capability for clarity.
    pub fn get_extensions(&mut self, capability: &Capability) -> Vec<DscExtension> {

@SteveL-MSFT SteveL-MSFT changed the title Bicep extension Enable passing Bicep files directly to dsc Jul 24, 2025
@SteveL-MSFT SteveL-MSFT added this pull request to the merge queue Jul 24, 2025
Merged via the queue into PowerShell:main with commit 493d75b Jul 24, 2025
4 checks passed
@SteveL-MSFT SteveL-MSFT deleted the bicep-extension branch July 24, 2025 21:19
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.

2 participants