Merge pull request #46144 from akerouanton/verifyNetworkingConfig-unneeded-error-wrapping

daemon: Remove unneeded error wrapping in verifyNetworkingConfig
This commit is contained in:
Sebastiaan van Stijn 2023-08-03 12:54:39 +02:00 committed by GitHub
commit 01a9c5b70e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View file

@ -326,7 +326,7 @@ func verifyNetworkingConfig(nwConfig *networktypes.NetworkingConfig) error {
for k, v := range nwConfig.EndpointsConfig { for k, v := range nwConfig.EndpointsConfig {
if v == nil { if v == nil {
return errdefs.InvalidParameter(errors.Errorf("no EndpointSettings for %s", k)) return errors.Errorf("no EndpointSettings for %s", k)
} }
if v.IPAMConfig != nil { if v.IPAMConfig != nil {
if v.IPAMConfig.IPv4Address != "" && net.ParseIP(v.IPAMConfig.IPv4Address).To4() == nil { if v.IPAMConfig.IPv4Address != "" && net.ParseIP(v.IPAMConfig.IPv4Address).To4() == nil {

View file

@ -4,8 +4,8 @@ import (
"testing" "testing"
"github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/network"
"github.com/docker/docker/errdefs"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
// Test case for 35752 // Test case for 35752
@ -17,5 +17,5 @@ func TestVerifyNetworkingConfig(t *testing.T) {
EndpointsConfig: endpoints, EndpointsConfig: endpoints,
} }
err := verifyNetworkingConfig(nwConfig) err := verifyNetworkingConfig(nwConfig)
assert.Check(t, errdefs.IsInvalidParameter(err)) assert.Check(t, is.Error(err, "no EndpointSettings for mynet"), "should produce an error because no EndpointSettings were passed")
} }