Conversation
Co-authored-by: conniey <10136526+conniey@users.noreply.github.com>
Co-authored-by: conniey <10136526+conniey@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Refactors the AKS tool commands to use constructor injection for IAksService instead of resolving it from CommandContext during ExecuteAsync, aligning with the repo-wide DI refactor effort (#158) and improving testability.
Changes:
- Inject
IAksServicevia primary constructors inClusterGetCommandandNodepoolGetCommand, removingcontext.GetService<IAksService>()usage. - Update unit tests to pass the
IAksServicemock directly to command constructors (no longer registering it in theServiceCollection). - Add an Azure MCP Server changelog entry for the AKS DI refactor.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tools/Azure.Mcp.Tools.Aks/src/Commands/Cluster/ClusterGetCommand.cs | Switches to constructor-injected IAksService and uses the injected field in ExecuteAsync. |
| tools/Azure.Mcp.Tools.Aks/src/Commands/Nodepool/NodepoolGetCommand.cs | Switches to constructor-injected IAksService and uses the injected field in ExecuteAsync. |
| tools/Azure.Mcp.Tools.Aks/tests/Azure.Mcp.Tools.Aks.UnitTests/Cluster/ClusterGetCommandTests.cs | Updates test setup to pass _aksService directly into the command constructor. |
| tools/Azure.Mcp.Tools.Aks/tests/Azure.Mcp.Tools.Aks.UnitTests/Nodepool/NodepoolGetCommandTests.cs | Updates test setup to pass _aksService directly into the command constructor. |
| servers/Azure.Mcp.Server/changelog-entries/1772226177387.yaml | Adds a changelog entry documenting the AKS DI refactor. |
|
@copilot Azure.Mcp.Core unit tests are failing. For example: |
… failures Co-authored-by: conniey <10136526+conniey@users.noreply.github.com>
Fixed in a06d7f6. Moving |
* Initial plan * refactor: DI injection for Azure.Mcp.Tools.Aks commands Co-authored-by: conniey <10136526+conniey@users.noreply.github.com> * fix: correct PR number in changelog entry Co-authored-by: conniey <10136526+conniey@users.noreply.github.com> * fix: register ICacheService mock in CommandFactoryHelpers to fix test failures Co-authored-by: conniey <10136526+conniey@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: conniey <10136526+conniey@users.noreply.github.com>
ClusterGetCommandto acceptIAksServicevia constructor injectionNodepoolGetCommandto acceptIAksServicevia constructor injectionClusterGetCommandTeststo pass_aksServicein constructor, remove from ServiceCollectionNodepoolGetCommandTeststo pass_aksServicein constructor, remove from ServiceCollectionCommandFactoryHelpers.SetupCommonServices()to registerICacheServicemock soAksServicecan be resolved in core unit testsToolsListCommandTests(22/22 tests pass)Invoking Livetests
Copilot submitted PRs are not trustworthy by default. Users with
writeaccess to the repo need to validate the contents of this PR before leaving a comment with the text/azp run mcp - pullrequest - live. This will trigger the necessary livetest workflows to complete required validation.Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.