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

Configuration history support #4552

Merged
merged 26 commits into from
Jun 21, 2024
Merged

Conversation

JohnMcPMS
Copy link
Member

@JohnMcPMS JohnMcPMS commented Jun 13, 2024

Change

This change adds basic configuration history support. This is stored in an SQLite database that is shared by all of the configuration code (so both winget.exe and PowerShell modules will use the same database).

The database currently holds a representation of every configuration set that has been applied (or at least attempted to be applied). Basic fields are stored directly, while more complex data is stored by serializing to YAML. While the database currently has only basic data, it will eventually contain status information for configuration units and other information used during synchronization of multiple configuration users.

Note

The dev build (based on AICLI_DISABLE_TEST_HOOKS) uses a different location for history to prevent local tests runs from adversely affecting the configuration usage experience for us.

winget.exe interface changes

A new command is added under the configure top level command, list. This shows details about items in the history.

> wingetdev configure list
Identifier                             Name      First Applied           Origin
----------------------------------------------------------------------------------
{9C8386B3-6C06-46D8-A0B1-83F3C73D86CE} Test Name 2024-06-13 11:43:20.000 Test Path
{F9DB9D25-92F3-4FBC-AD34-BEEEE53F08A0} Test Name 2024-06-13 11:43:21.000 Test Path
{49B3FDDA-9ABA-475C-A9FE-296CE3D7ED48} Test Name 2024-06-13 11:43:21.000 Test Path
{436B929A-E717-4F3B-B16E-BD268D5916D6} Test Name 2024-06-13 11:43:21.000 Test Path
> wingetdev configure list -h "{9C8386B3-6C06-46D8-A0B1-83F3C73D86CE}"
Field         Value
----------------------------------------------------
Identifier    {9C8386B3-6C06-46D8-A0B1-83F3C73D86CE}
Name          Test Name
First Applied 2024-06-13 11:43:20.000
Origin        Test Origin
Path          Test Path

In addition to listing everything, one can provide the listed name of the configuration or any unique starting sequence of the identifier to select a single item to view. The selection options apply to all other commands that take in the history item parameter, and completion has been added for the parameter so that substrings of either identifier or name can be expanded.

The configure, configure show, and configure test commands have all had the history parameter added so that one can operate directly against a historical set.

In addition to displaying information about history, the configure list command also allows for removing items from history with --remove and creating a YAML file for the set with --output.

PowerShell interface changes

The existing cmdlet Get-WinGetConfiguration was updated to include parameter set options -All to get all set from history and -InstanceIdentifier to get a single one (these are exclusive with -File and each other). Remove-WinGetConfigurationHistory was added to allow removing sets from history, and ConvertTo-WinGetConfigurationYaml was added to enable serializing a set to a string.

Validation

Many new tests are added for the interface implementations, as well as unit tests for the internals. The entire existing test base is also exercising writing to history.

Microsoft Reviewers: Open in CodeFlow

@JohnMcPMS JohnMcPMS requested a review from a team as a code owner June 13, 2024 18:59
@@ -54,7 +54,7 @@ namespace AppInstaller::CLI

namespace Configuration
{
void ValidateCommonArguments(Execution::Args& execArgs)
void ValidateCommonArguments(Execution::Args& execArgs, bool requireConfigurationSetChoice)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need requireConfigurationSetChoice? All the callers pass true.

Copy link
Member Author

Choose a reason for hiding this comment

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

Since I made it an optional parameter defaulting to false, I didn't need to update both ConfigureValidateCommand and ConfigureExportCommand, which still call it.

public string InstanceIdentifier { get; set; }

/// <summary>
/// Gets or sets the configuration history item identifier.
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't sound like All

@JohnMcPMS JohnMcPMS merged commit c074cbe into microsoft:master Jun 21, 2024
8 checks passed
@JohnMcPMS JohnMcPMS deleted the config-history branch June 21, 2024 17:18
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