feat: Add connect to network API#1672
Conversation
✅ Deploy Preview for testcontainers-dotnet ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughAdded ConnectAsync overloads to allow attaching an already-running container to an existing Docker network; implemented on interface and DockerContainer class with internal unsafe connect logic and state refresh; docs updated with guidance and a new Linux integration test verifies runtime network attachment. Changes
Sequence Diagram(s)mermaid Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Suggested labels
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/Testcontainers/Containers/IContainer.cs (1)
256-270: LGTM!The new
ConnectAsyncoverloads are well-documented and follow the established interface patterns. Both methods clearly describe their purpose of connecting a running container to an existing network.For consistency with other async methods like
StartAsyncandStopAsync, consider adding<exception>documentation tags forOperationCanceledExceptionandTaskCanceledException.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/Testcontainers/Containers/IContainer.cs` around lines 256 - 270, Add <exception> XML documentation entries to both ConnectAsync overloads to mirror StartAsync/StopAsync: document that the method may throw OperationCanceledException and TaskCanceledException when the provided CancellationToken is canceled; update the summaries for Task ConnectAsync(string network, CancellationToken ct = default) and Task ConnectAsync(INetwork network, CancellationToken ct = default) to include these <exception> tags so the interface's async method docs remain consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/Testcontainers/Containers/IContainer.cs`:
- Around line 256-270: Add <exception> XML documentation entries to both
ConnectAsync overloads to mirror StartAsync/StopAsync: document that the method
may throw OperationCanceledException and TaskCanceledException when the provided
CancellationToken is canceled; update the summaries for Task ConnectAsync(string
network, CancellationToken ct = default) and Task ConnectAsync(INetwork network,
CancellationToken ct = default) to include these <exception> tags so the
interface's async method docs remain consistent.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 0216f42f-38ef-44b8-affc-f5be30053477
📒 Files selected for processing (5)
docs/api/create_docker_network.mdsrc/Testcontainers/Containers/DockerContainer.cssrc/Testcontainers/Containers/IContainer.cssrc/Testcontainers/Images/MatchImage.cstests/Testcontainers.Platform.Linux.Tests/NetworkConnectTest.cs
What does this PR do?
This PR adds a new API to the
IContainerinterface that lets developers connect a container to existing networks. Some modules configure networks internally without exposing them publicly. This API allows containers to be connected to those networks after they start.Why is it important?
-
Related issues
IContainer#1614Summary by CodeRabbit
New Features
Documentation
Bug Fixes
Tests