-
Notifications
You must be signed in to change notification settings - Fork 79
Make darc add-subscription work with the new config repo
#5627
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
base: main
Are you sure you want to change the base?
Conversation
darc add-subscriptiojn work with the new config repo
There was a problem hiding this 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 implements the initial infrastructure for managing subscriptions via a configuration repository rather than through the database. It introduces a new ConfigurationManagementOperation base class that enables DARC commands to read from and commit to a Git-based configuration repository, with support for both local and remote repositories (GitHub and Azure DevOps).
Key changes:
- New
ConfigurationManagementOperationbase class provides common functionality for managing YAML configuration files in a Git repository - Extended Git clients to support direct API commits without cloning (GitHub and Azure DevOps)
- Added
IsEquivalentTomethod toSubscriptionYamlfor duplicate detection - Updated subscription operations to inherit from
ConfigurationManagementOperation
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Microsoft.DotNet.Darc/DarcLib/RemoteRepoBase.cs | Removed obsolete logger parameter from documentation |
| src/Microsoft.DotNet.Darc/DarcLib/Remote.cs | Added wrapper method for no-cloning commit functionality |
| src/Microsoft.DotNet.Darc/DarcLib/Models/Yaml/SubscriptionYaml.cs | Implemented equivalence checking for subscription deduplication |
| src/Microsoft.DotNet.Darc/DarcLib/LocalLibGit2Client.cs | Added repository existence check method |
| src/Microsoft.DotNet.Darc/DarcLib/LocalGitClient.cs | Added branch existence check and branch creation from base |
| src/Microsoft.DotNet.Darc/DarcLib/IRemoteGitRepo.cs | Moved common methods to IGitRepo and added CommitFilesWithNoCloningAsync |
| src/Microsoft.DotNet.Darc/DarcLib/IRemote.cs | Added interface method for no-cloning commits |
| src/Microsoft.DotNet.Darc/DarcLib/IGitRepo.cs | Moved branch and repository management methods from IRemoteGitRepo |
| src/Microsoft.DotNet.Darc/DarcLib/GitHubClient.cs | Implemented direct API-based commit functionality using GitHub Git Data API |
| src/Microsoft.DotNet.Darc/DarcLib/AzureDevOpsClient.cs | Implemented direct API-based commit functionality using Azure DevOps pushes API |
| src/Microsoft.DotNet.Darc/Darc/Options/SubscriptionCommandLineOptions.cs | Changed base class to ConfigurationManagementCommandLineOptions |
| src/Microsoft.DotNet.Darc/Darc/Options/ConfigurationManagementCommandLineOptions.cs | New options class for configuration repository management |
| src/Microsoft.DotNet.Darc/Darc/Options/CommandLineOptions.cs | Registered LocalGitRepoFactory and LocalGitClient in DI container |
| src/Microsoft.DotNet.Darc/Darc/Operations/UpdateSubscriptionOperation.cs | Updated constructor to use ConfigurationManagementOperation base |
| src/Microsoft.DotNet.Darc/Darc/Operations/SubscriptionOperationBase.cs | Changed base class to ConfigurationManagementOperation |
| src/Microsoft.DotNet.Darc/Darc/Operations/ConfigurationManagementOperation.cs | New base class providing configuration repository management functionality |
| src/Microsoft.DotNet.Darc/Darc/Operations/AddSubscriptionOperation.cs | Added configuration repository support with duplicate detection |
| src/Microsoft.DotNet.Darc/Darc/Microsoft.DotNet.Darc.csproj | Added dependency on Microsoft.DotNet.MaestroConfiguration.Client |
| eng/Version.Details.xml | Updated MaestroConfiguration.Client package version |
| eng/Version.Details.props | Updated MaestroConfiguration.Client package version |
src/Microsoft.DotNet.Darc/Darc/Operations/AddSubscriptionOperation.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Darc/Darc/Operations/ConfigurationManagementOperation.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Darc/Darc/Operations/ConfigurationManagementOperation.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Darc/Darc/Operations/ConfigurationManagementOperation.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Darc/Darc/Operations/ConfigurationManagementOperation.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Darc/Darc/Operations/ConfigurationManagementOperation.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Darc/Darc/Operations/ConfigurationManagementOperation.cs
Outdated
Show resolved
Hide resolved
darc add-subscriptiojn work with the new config repodarc add-subscription work with the new config repo
src/Microsoft.DotNet.Darc/Darc/Options/ConfigurationManagementCommandLineOptions.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Darc/Darc/Options/ConfigurationManagementCommandLineOptions.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Darc/Darc/Options/ConfigurationManagementCommandLineOptions.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Darc/Darc/Options/ConfigurationManagementCommandLineOptions.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Darc/Darc/Options/ConfigurationManagementCommandLineOptions.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Darc/Darc/Options/ConfigurationManagementCommandLineOptions.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Darc/Darc/Operations/ConfigurationManagementOperation.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Darc/Darc/Operations/ConfigurationManagementOperation.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Darc/Darc/Operations/ConfigurationManagementOperation.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Darc/Darc/Operations/ConfigurationManagementOperation.cs
Outdated
Show resolved
Hide resolved
…CommandLineOptions.cs Co-authored-by: Přemek Vysoký <[email protected]>
…CommandLineOptions.cs Co-authored-by: Přemek Vysoký <[email protected]>
…CommandLineOptions.cs Co-authored-by: Přemek Vysoký <[email protected]>
|
@dkurepa do you have a task for updating of Ideally we'd maybe scrap the whole file as the whole format is just useless and we'd:
|
It's under the Fully transition issue currently #5537, will probably end up splitting that one into multiple |
|
@dkurepa if you're going to spin up the AI tasks for other commands then don't. Matt has a request which might mean a change to the code here that the AI will be reusing |
src/Microsoft.DotNet.Darc/Darc/Operations/AddSubscriptionOperation.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Darc/Darc/Operations/AddSubscriptionOperation.cs
Outdated
Show resolved
Hide resolved
| } | ||
|
|
||
| subscriptionsInFile.Add(subscriptionYaml); | ||
| await WriteConfigurationDataAsync( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| await WriteConfigurationDataAsync( | |
| await CommitConfigurationChangesAsync( |
src/Microsoft.DotNet.Darc/Darc/Operations/ConfigurationManagementOperation.cs
Outdated
Show resolved
Hide resolved
|
|
||
| if (!await _configurationRepo.Value.DoesBranchExistAsync(_options.ConfigurationRepository, _options.ConfigurationBaseBranch)) | ||
| { | ||
| throw new ArgumentException($"The configuration base branch '{_options.ConfigurationBaseBranch}' does not exist in the repository '{_options.ConfigurationRepository}'."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that error message is only true if the repo is remote. With a local one, it could just be that the branch (eg, "prod") hasn't been fetched?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean it still doesn't exist on your repo locally, it's up to the user to figure it out at that point
| { | ||
| if (!await _configurationRepo.Value.RepoExistsAsync(_options.ConfigurationRepository)) | ||
| { | ||
| throw new ArgumentException($"The configuration repository '{_options.ConfigurationRepository}' is not a valid git repository."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| throw new ArgumentException($"The configuration repository '{_options.ConfigurationRepository}' is not a valid git repository."); | |
| throw new ArgumentException($"ConfigurationRepository must be a valid URI to a remote git repository, or a path to a git repository on disk."); |
| sourceEnabled: subscriptionYaml.SourceEnabled, | ||
| sourceDirectory: subscriptionYaml.SourceDirectory, | ||
| targetDirectory: subscriptionYaml.TargetDirectory)) | ||
| .FirstOrDefault(s => s.TargetBranch == subscriptionYaml.TargetBranch); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: targetBranch could be added to the optional params that GetSubscriptionsAsync accepts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah you mean expand the method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at it, I wouldn't want to add it as a last argument, but adding it somewhere in the middle would make it so I'd have to check a lot of places, which I wouldn't want to do in this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dkurepa not saying you should add it but in case you are doing such a change in future, VS allows you to add a new param in the "Change signature" modal dialog and you can set what value you want to insert in all calling places. So you'd put something like TODO and it will make sure it's everywhere and you don't break stuff
src/Microsoft.DotNet.Darc/Darc/Operations/AddSubscriptionOperation.cs
Outdated
Show resolved
Hide resolved
| if (!_options.NoPr) | ||
| { | ||
| await CreatePullRequest( | ||
| $"Add new subscription ({subscriptionYaml.Channel}) {subscriptionYaml.SourceRepository} => {subscriptionYaml.TargetRepository} ({subscriptionYaml.TargetBranch})"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The title could be generated by SubscriptionDescriptionHelper
…RepositoryManager
src/Microsoft.DotNet.Darc/Darc/Operations/AddSubscriptionOperation.cs
Outdated
Show resolved
Hide resolved
| namespace Microsoft.DotNet.DarcLib.ConfigurationRepository; | ||
|
|
||
| // this is just a temporary thing, till we add it in the configuration repo | ||
| public class ConfigurationRepositoryOperationParameters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't merged the PR in the config repo yet, so yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we just merge it and tomorrow morning we can use the real interfaces?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this PR looks good to you, could we merge it first, and merge the config repo one tomorrow?
#5502