From f3e62199ea766b2cc0539dc3b728c402a1faa6f2 Mon Sep 17 00:00:00 2001 From: Albin Kerouanton Date: Wed, 2 Aug 2023 11:47:00 +0200 Subject: [PATCH] daemon: Remove unneeded error wrapping in verifyNetworkingConfig This function is called by `daemon.containerCreate()` which is already wrapping errors coming from `verifyNetworkingConfig()` with `errdefs.InvalidParameter()`. So `verifyNetworkingConfig()` should only return standard errors. Signed-off-by: Albin Kerouanton --- daemon/create.go | 2 +- daemon/create_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/daemon/create.go b/daemon/create.go index 2ca004ab11..a8475d0be5 100644 --- a/daemon/create.go +++ b/daemon/create.go @@ -326,7 +326,7 @@ func verifyNetworkingConfig(nwConfig *networktypes.NetworkingConfig) error { for k, v := range nwConfig.EndpointsConfig { 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.IPv4Address != "" && net.ParseIP(v.IPAMConfig.IPv4Address).To4() == nil { diff --git a/daemon/create_test.go b/daemon/create_test.go index 5abe24d2cf..c5d116098b 100644 --- a/daemon/create_test.go +++ b/daemon/create_test.go @@ -4,8 +4,8 @@ import ( "testing" "github.com/docker/docker/api/types/network" - "github.com/docker/docker/errdefs" "gotest.tools/v3/assert" + is "gotest.tools/v3/assert/cmp" ) // Test case for 35752 @@ -17,5 +17,5 @@ func TestVerifyNetworkingConfig(t *testing.T) { EndpointsConfig: endpoints, } 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") }