-
Notifications
You must be signed in to change notification settings - Fork 79
Add configuration repository support to darc add-default-channel
#5684
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
Co-authored-by: dkurepa <91743470+dkurepa@users.noreply.github.com>
darc add-default-channel
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 extends the darc add-default-channel command to support writing default channel configurations directly to the maestro-configuration repository, enabling a dual-mode operation during the transition from API-based to file-based configuration management. The implementation follows the established pattern from add-subscription and is controlled by the DARC_USE_CONFIGURATION_REPOSITORY environment variable.
Key Changes
- Added configuration repository support to
darc add-default-channelwith dual-mode operation (API vs. config repo) - Implemented BAR validation before writing to config repo to prevent duplicates across both systems
- Comprehensive test suite covering file creation, appending, and duplicate detection scenarios
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
src/Microsoft.DotNet.Darc/Darc/Options/AddDefaultChannelCommandLineOptions.cs |
Changed base class to ConfigurationManagementCommandLineOptions to inherit configuration repository flags |
src/Microsoft.DotNet.Darc/Darc/Operations/AddDefaultChannelOperation.cs |
Added dual-mode operation routing, BAR validation, and config repo integration for default channel management |
src/MaestroConfiguration/src/Microsoft.DotNet.MaestroConfiguration.Client/IConfigurationRepositoryManager.cs |
Added AddDefaultChannelAsync method signature to the interface |
src/MaestroConfiguration/src/Microsoft.DotNet.MaestroConfiguration.Client/ConfigurationRepositoryManager.cs |
Implemented AddDefaultChannelAsync with duplicate detection and proper file path resolution |
test/Microsoft.DotNet.Darc.Tests/Operations/AddDefaultChannelOperationConfigRepoTests.cs |
Added comprehensive test suite covering file creation, appending to existing files, and duplicate detection in YAML files |
| Enabled = true | ||
| }; | ||
|
|
||
| await ValidateNoEquivalentDefaultChannel(defaultChannelYaml); |
Copilot
AI
Dec 25, 2025
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 ValidateNoEquivalentDefaultChannel method is called before AddDefaultChannelAsync, but AddDefaultChannelAsync also performs its own duplicate detection in the ConfigurationRepositoryManager. This means duplicate default channels in YAML files will be caught twice - once by the BAR validation here and again by the YAML file check in ConfigurationRepositoryManager. However, if a default channel exists only in BAR but not in the YAML file being written to, the BAR validation will catch it correctly. If a default channel exists in the YAML file but not in BAR, only the ConfigurationRepositoryManager validation will catch it. This dual-layer validation is inconsistent with the AddSubscriptionOperation pattern, where ValidateNoEquivalentSubscription only checks BAR, and the ConfigurationRepositoryManager handles YAML duplicates separately. Consider whether the BAR validation should remain or be removed for consistency with the subscription pattern.
| } | ||
|
|
||
| /// <summary> | ||
| /// Validates that no equivalent default channel already exists in BAR or YAML files. |
Copilot
AI
Dec 25, 2025
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 comment states "Validates that no equivalent default channel already exists in BAR or YAML files" but the implementation only checks BAR via _barClient.GetDefaultChannelsAsync. The YAML file validation is performed separately by ConfigurationRepositoryManager.AddDefaultChannelAsync. Update the comment to accurately reflect that this method only validates against BAR entries.
| /// Validates that no equivalent default channel already exists in BAR or YAML files. | |
| /// Validates that no equivalent default channel already exists in BAR. |
| var content = await File.ReadAllTextAsync(filePath); | ||
| return YamlDeserializer.Deserialize<List<DefaultChannelYaml>>(content) ?? []; | ||
| } | ||
| } |
Copilot
AI
Dec 25, 2025
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 test suite is missing a test case for when ValidateNoEquivalentDefaultChannel fails because a default channel already exists in BAR. This is an important scenario to test since it validates the BAR-level duplicate detection logic. Consider adding a test that mocks _barClient.GetDefaultChannelsAsync to return an existing default channel, then verifies that ExecuteAsync returns Constants.ErrorCode and logs the appropriate error message.
| [SetUp] | ||
| public override async Task SetupAsync() | ||
| { | ||
| await base.SetupAsync(); |
Copilot
AI
Dec 25, 2025
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 ConfigurationManagementTestBase does not set up a mock for GetDefaultChannelsAsync, which is called by ValidateNoEquivalentDefaultChannel in AddDefaultChannelOperation. Without this mock setup, the tests will fail when ExecuteAsync tries to validate against BAR. You need to add a mock setup in either ConfigurationManagementTestBase.SetupBarClientMock or in the test class's SetUp method to return an empty list for GetDefaultChannelsAsync, similar to how GetSubscriptionsAsync is already mocked in the base class.
| await base.SetupAsync(); | |
| await base.SetupAsync(); | |
| // Ensure BAR client returns no default channels so validation passes without querying real BAR. | |
| BarClientMock | |
| .Setup(client => client.GetDefaultChannelsAsync( | |
| It.IsAny<string?>(), | |
| It.IsAny<string?>(), | |
| It.IsAny<string?>(), | |
| It.IsAny<string?>(), | |
| It.IsAny<bool?>(), | |
| It.IsAny<bool?>(), | |
| It.IsAny<int?>(), | |
| It.IsAny<int?>())) | |
| .ReturnsAsync(new List<DefaultChannel>()); |
| { | ||
| _logger.LogError("A default channel with the same repository, branch, and channel already exists (ID: {id})", | ||
| existingDefaultChannel.Id); | ||
| throw new ArgumentException($"A default channel with the repository {existingDefaultChannel.Repository}, branch {existingDefaultChannel.Branch} and channel {existingDefaultChannel.Channel} already exists"); |
Copilot
AI
Dec 25, 2025
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.
Default 'ToString()': Channel inherits 'ToString()' from 'Object', and so is not suitable for printing.
| throw new ArgumentException($"A default channel with the repository {existingDefaultChannel.Repository}, branch {existingDefaultChannel.Branch} and channel {existingDefaultChannel.Channel} already exists"); | |
| throw new ArgumentException($"A default channel with the repository {existingDefaultChannel.Repository}, branch {existingDefaultChannel.Branch} and channel {existingDefaultChannel.Channel.Name} already exists"); |
Description
Extends
darc add-default-channelto modify the configuration repository directly, following the pattern established byadd-subscription. This enables the transition from API-based to file-based default channel management.Changes
AddDefaultChannelAsyncmethod that writesDefaultChannelYamlobjects to repo-specific files (e.g.,configuration/default-channels/dotnet-runtime.yml)ConfigurationManagementCommandLineOptionsto inherit config repo flags (--configuration-repository,--configuration-branch,--configuration-base-branch,--configuration-file,--no-pr)DARC_USE_CONFIGURATION_REPOSITORYenvironment variable; validates against existing BAR entries before writing to config repoAddDefaultChannelOperationConfigRepoTestscovering file creation, appending, duplicate detection, and YAML validationUsage
Without the environment variable, existing API-based behavior is unchanged.
Original prompt
darc add-default-channelwork with the Configuration Repo #5501✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.