Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 16, 2025

Implements configuration repository mode for darc add-channel to add channels via git repository instead of API calls, mirroring the existing add-subscription implementation.

Changes

Command Interface

  • AddChannelCommandLineOptions now inherits ConfigurationManagementCommandLineOptions, exposing:
    • --configuration-repository - Target repo URI
    • --configuration-branch - Working branch (auto-generated if unspecified)
    • --configuration-base-branch - Base for PR creation
    • --configuration-file - Override default file path
    • --no-pr - Skip PR creation (commit only)
  • Mode controlled by DARC_USE_CONFIGURATION_REPOSITORY environment variable

Core Implementation

  • AddChannelOperation checks for existing channels in API before committing (prevents duplicates during transition)
  • ConfigurationRepositoryManager.AddChannelAsync handles:
    • Branch preparation and validation
    • YAML file fetch/parse/update with ChannelYamlComparer ordering
    • Duplicate detection in target file
    • Commit and PR creation

Testing

  • AddChannelOperationConfigRepoTests validates file creation, append behavior, duplicate detection (API and YAML), and YAML format
  • Uses ConfigurationManagementTestBase with real git repo (not mocked)

Usage

export DARC_USE_CONFIGURATION_REPOSITORY=true
darc add-channel --name ".NET 11" --classification "product"

# To specific branch without PR
darc add-channel --name ".NET 11" --classification "product" \
  --configuration-branch "existing-branch" --no-pr

API mode remains default (backward compatible). Configuration mode creates/updates files at configuration/channels/{normalized-name}.yml.

Original prompt

This section details on the original issue you should resolve

<issue_title>Make darc add-channel work with the new configuration repo</issue_title>
<issue_description>Depends on #5480

Context

With the channel configuration moving to the configuration repo, we should make it so darc add-channel can modifies the repo config. During the transition period, this should be behind a flag in the command.

Goal

Modify the existing darc add-channel command so it adds the channel by modifying the configuration repo in whichever structure we agree on, using the available yaml models. We'll need to add a few flags to the command:

  • Flag to target the repo instead of the API
  • Flag to specify configuration repository
  • Flag to specify which branch to commit the config changes to (if we already have a PR, or for scenario tests)
  • Flag to specify which base branch to use for the PR creation
  • Flag to specify we don't want to open a PR (for scenario tests)
  • Flag to overwrite default file for the channel, and put the new channel in the provided file

This should be written so it makes it easy to remove the API part, and use the configuration repo as one and only way to modify the configuration
</issue_description>

<agent_instructions>Look at the implementation for AddSubscriptionOperation. Also it's part in the ConfigurationRepository Manager, they should look quite similar</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@dkurepa The implementation for this operation should look similar to the AddSubscriptionAsync one in the ConfigurationRepositoryManager.

We should be able to reuse most of the methods for fetching the file, commiting it, etc..</comment_new>


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@dkurepa
Copy link
Member

dkurepa commented Dec 16, 2025

@copilot also make sure to add tests like we have for AddSubscriptionOperation

Copilot AI changed the title [WIP] Modify darc add-channel to work with new configuration repo Add configuration repository support to darc add-channel Dec 16, 2025
Copilot AI requested a review from dkurepa December 16, 2025 17:11
Copy link
Contributor Author

Copilot AI commented Dec 16, 2025

@copilot also make sure to add tests like we have for AddSubscriptionOperation

Tests have been added following the same pattern as AddSubscriptionOperationConfigRepoTests. All 5 tests are passing:

  • AddChannelOperation_WithConfigRepo_CreatesChannelFile
  • AddChannelOperation_WithConfigRepo_AppendsToExistingFile
  • AddChannelOperation_WithConfigRepo_FailsWhenChannelAlreadyExistsInApi
  • AddChannelOperation_WithConfigRepo_FailsWhenChannelAlreadyExistsInYamlFile
  • AddChannelOperation_WithConfigRepo_FileContentIsValidYaml

Commit: c178bc0

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.

Make darc add-channel work with the new configuration repo

2 participants