chore(deps): Bump Docker.DotNet from 3.131.1 to 4.0.2#1665
chore(deps): Bump Docker.DotNet from 3.131.1 to 4.0.2#1665HofmeisterAn merged 2 commits intodevelopfrom
Conversation
✅ Deploy Preview for testcontainers-dotnet ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
WalkthroughThis PR upgrades Docker.DotNet.Enhanced packages from 3.131.1 to 4.0.2 and refactors Docker client instantiation from GetDockerClientConfiguration/CreateClient to GetDockerClientBuilder/Build. It updates authentication types from Credentials to IAuthProvider, removes TlsCredentials method overrides, and modifies NPipe timeout configuration. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
📝 Coding Plan
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 Tip You can make CodeRabbit's review stricter and more nitpicky using the `assertive` profile, if that's what you prefer.Change the |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
tests/Testcontainers.Tests/Unit/Configurations/DockerEndpointAuthenticationProviderTest.cs (1)
42-45: Consider disposing the Docker client.The
dockerClientcreated viaBuild()implementsIDisposable. While the test scope is short, disposing it would be consistent with other test files and prevent potential resource leaks.Proposed fix
- var dockerClient = authConfig.GetDockerClientBuilder().Build(); + using var dockerClient = authConfig.GetDockerClientBuilder().Build(); Assert.Equal(dockerClientEndpoint, authConfig.Endpoint); Assert.Equal(dockerClientEndpoint, dockerClient.Options.Endpoint);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/Testcontainers.Tests/Unit/Configurations/DockerEndpointAuthenticationProviderTest.cs` around lines 42 - 45, The test creates a Docker client via authConfig.GetDockerClientBuilder().Build() and never disposes it; update the DockerEndpointAuthenticationProviderTest to dispose dockerClient (the variable created from Build())—either wrap the Build() call and assertions in a using/using var block or call dockerClient.Dispose() after the assertions so the IDisposible Docker client is properly cleaned up.src/Testcontainers/Configurations/AuthConfigs/DockerEndpointAuthenticationConfiguration.cs (1)
25-25: Derive the fallback timeout fromNPipeTransportOptionsinstead of hardcoding it.
NPipeTransportOptions.ConnectTimeoutalready defaults to 10 seconds. Duplicating that literal here means this fallback can silently drift from the transport's real default on the next Docker.DotNet upgrade. (github.com)♻️ Proposed refactor
- private static readonly TimeSpan NPipeConnectTimeout = EnvironmentConfiguration.Instance.GetNamedPipeConnectionTimeout() ?? PropertiesFileConfiguration.Instance.GetNamedPipeConnectionTimeout() ?? TimeSpan.FromSeconds(10); + private static readonly TimeSpan NPipeConnectTimeout = + EnvironmentConfiguration.Instance.GetNamedPipeConnectionTimeout() + ?? PropertiesFileConfiguration.Instance.GetNamedPipeConnectionTimeout() + ?? new NPipeTransportOptions().ConnectTimeout;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/Testcontainers/Configurations/AuthConfigs/DockerEndpointAuthenticationConfiguration.cs` at line 25, The hardcoded 10s fallback for NPipeConnectTimeout should be replaced with the transport's default; change the fallback expression so that when EnvironmentConfiguration.Instance.GetNamedPipeConnectionTimeout() and PropertiesFileConfiguration.Instance.GetNamedPipeConnectionTimeout() are null it uses new NPipeTransportOptions().ConnectTimeout (the default for NPipeTransportOptions) instead of TimeSpan.FromSeconds(10), so update the static initializer for NPipeConnectTimeout accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@src/Testcontainers/Configurations/AuthConfigs/DockerEndpointAuthenticationConfiguration.cs`:
- Around line 48-71: GetDockerClientBuilder in
DockerEndpointAuthenticationConfiguration dereferences the nullable Uri property
Endpoint (used in WithEndpoint(Endpoint) and Endpoint.Scheme) without guarding
against null; update the method to validate Endpoint before calling WithEndpoint
and before checking "npipe". Specifically, check if Endpoint is null (or
Uri.IsWellFormedUriString/valid) and either throw a descriptive
ArgumentNullException/InvalidOperationException or skip setting the
endpoint/transport options, and only evaluate Endpoint.Scheme when Endpoint !=
null; ensure the references to WithEndpoint and the npipe branch
(NPipeTransportOptions/NPipeConnectTimeout) are protected by this guard so
default struct instances no longer cause NullReferenceException.
---
Nitpick comments:
In
`@src/Testcontainers/Configurations/AuthConfigs/DockerEndpointAuthenticationConfiguration.cs`:
- Line 25: The hardcoded 10s fallback for NPipeConnectTimeout should be replaced
with the transport's default; change the fallback expression so that when
EnvironmentConfiguration.Instance.GetNamedPipeConnectionTimeout() and
PropertiesFileConfiguration.Instance.GetNamedPipeConnectionTimeout() are null it
uses new NPipeTransportOptions().ConnectTimeout (the default for
NPipeTransportOptions) instead of TimeSpan.FromSeconds(10), so update the static
initializer for NPipeConnectTimeout accordingly.
In
`@tests/Testcontainers.Tests/Unit/Configurations/DockerEndpointAuthenticationProviderTest.cs`:
- Around line 42-45: The test creates a Docker client via
authConfig.GetDockerClientBuilder().Build() and never disposes it; update the
DockerEndpointAuthenticationProviderTest to dispose dockerClient (the variable
created from Build())—either wrap the Build() call and assertions in a
using/using var block or call dockerClient.Dispose() after the assertions so the
IDisposible Docker client is properly cleaned up.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: f0fc8fef-a79a-4aa0-b10e-afbe2731a45c
📒 Files selected for processing (10)
Directory.Packages.propssrc/Testcontainers/Builders/DockerEndpointAuthenticationProvider.cssrc/Testcontainers/Builders/TlsCredentials.cssrc/Testcontainers/Clients/DockerApiClient.cssrc/Testcontainers/Configurations/AuthConfigs/DockerEndpointAuthenticationConfiguration.cssrc/Testcontainers/Configurations/AuthConfigs/IDockerEndpointAuthenticationConfiguration.cstests/Testcontainers.Platform.Linux.Tests/DependsOnTest.cstests/Testcontainers.Platform.Linux.Tests/ReusableResourceTest.cstests/Testcontainers.Tests/Unit/Configurations/DockerEndpointAuthenticationProviderTest.cstests/Testcontainers.Tests/Unit/Containers/Unix/ProtectDockerDaemonSocketTest.cs
💤 Files with no reviewable changes (1)
- src/Testcontainers/Builders/TlsCredentials.cs
What does this PR do?
This PR upgrades Docker.DotNet to the latest major version. The new release introduces a client builder API along with numerous internal improvements and fixes.
Due to changes in Docker.DotNet, the
IDockerEndpointAuthenticationConfigurationinterface has been updated to use the new types introduced by the library. This interface is publicly exposed viaWithDockerEndpoint(IDockerEndpointAuthenticationConfiguration), most users don't use this API.This breaking change is unlikely to affect users or developers. In most cases, the container runtime is resolved through the auto-discovery mechanism and/or configured via environment variables or the properties file (
~/.testcontainers.properties).Why is it important?
-
Related issues
-
Summary by CodeRabbit
Release Notes
Dependencies
Refactor