Skip to content
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

Initial implementation of Microsoft.WinGet.Configuration cmdlets. #3204

Merged
merged 7 commits into from
May 2, 2023

Conversation

msftrubengu
Copy link
Contributor

@msftrubengu msftrubengu commented May 1, 2023

This PR adds 5 cmdlets

  • Get-WinGetConfiguration: creates a configuration set given a file path.
  • Get-WinGetConfigurationDetails: gets the details from a set.
  • Invoke-WinGetConfiguration: applies the configuration and waits for completion.
  • Start-WinGetConfiguration: starts applying the configuration asynchronously. Returns PSConfigurationTask.
  • Complete-WinGetConfiguration: waits for the PSConfigurationTask to be completed.

For now, a call the Get-WinGetConfiguration is required to start. It returns a PSConfigurationSet which can be pass to the other cmdlets.

If Invoke-WinGetConfiguration or Start-WinGetConfiguration get called before Get-WinGetConfigurationDetails, they will retrieve the details.

There is no output in PowerShell except for debug messages and the objects. Future PRs will provide a better user experience similar to what winget configure does.

By default, Start-WinGetConfiguration won't write anything to the stream buffers (except the returned object).because it needs to be executed in the main thread. When Complete-WinGetConfiguration gets called, writting to the streams gets enabled. For now, all the messages before Complete gets lost but in the future, we can store them and show them (similar to what Start-Job/Receive-Job does).

This PR also adds a new ConfigurationProcessorPolicy enum for creating a ConfigurationSetProcessor and can be added via IConfigurationProcessorFactoryProperties. The enum is a mirror of the PowerShell Execution Policies. By default, winget uses Unrestricted (we should change in the near future) and the module uses the same as the current PowerShell session.

I couldn't get the execution policy at the time of creating the set processor because it is not possible to create a runspace based on the current session. At that point, we are already running in another thread so the runspace can't be found. This means that the two types of runspaces are always "hosted" which just means that there's a new runspace created from them.

When we enable variables in configuration, there needs to be something that makes them visible from the current PowerShell session to our runspace (maybe using synchronized hashtable).

Microsoft Reviewers: Open in CodeFlow

@github-actions

This comment has been minimized.

@msftrubengu msftrubengu marked this pull request as ready for review May 2, 2023 17:29
@msftrubengu msftrubengu requested a review from a team as a code owner May 2, 2023 17:29
@msftrubengu msftrubengu merged commit c344db7 into microsoft:master May 2, 2023
@msftrubengu msftrubengu deleted the defaultprocessor branch August 14, 2023 22:26
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