From 59c2d2a4b35b0546e849319c27275aed7e2e9161 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 28 Jan 2025 12:42:32 +0100 Subject: [PATCH] libnetwork/drivers/bridge: remove ErrInvalidDriverConfig It's a generic error, doesn't implement an errdefs type, is poorly formatted, and not used as sentinel error anywhere. Let's remove it, and update the error produced to be slightly more informative (include the invalid type). Worth noting that there's no need to include the name of the driver in the error, because the only uses of the error (in `registerNetworkDrivers`) already decorates it; https://github.com/moby/moby/blob/5fd7ed2937a2308681e9e8c4b049231a84b3ca88/libnetwork/drivers_linux.go#L34-L36 Signed-off-by: Sebastiaan van Stijn --- libnetwork/drivers/bridge/bridge_linux.go | 2 +- libnetwork/drivers/bridge/errors.go | 7 ------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/libnetwork/drivers/bridge/bridge_linux.go b/libnetwork/drivers/bridge/bridge_linux.go index 183d5bd08e..df4eaeca70 100644 --- a/libnetwork/drivers/bridge/bridge_linux.go +++ b/libnetwork/drivers/bridge/bridge_linux.go @@ -499,7 +499,7 @@ func (d *driver) configure(option map[string]interface{}) error { case nil: // No GenericData option set. Use defaults. default: - return &ErrInvalidDriverConfig{} + return errdefs.InvalidParameter(fmt.Errorf("invalid configuration type (%T) passed", opt)) } if config.EnableIPTables { diff --git a/libnetwork/drivers/bridge/errors.go b/libnetwork/drivers/bridge/errors.go index 20aacc797e..e738fca325 100644 --- a/libnetwork/drivers/bridge/errors.go +++ b/libnetwork/drivers/bridge/errors.go @@ -17,13 +17,6 @@ func (ece *ErrConfigExists) Error() string { // Forbidden denotes the type of this error func (ece *ErrConfigExists) Forbidden() {} -// ErrInvalidDriverConfig error is returned when Bridge Driver is passed an invalid config -type ErrInvalidDriverConfig struct{} - -func (eidc *ErrInvalidDriverConfig) Error() string { - return "Invalid configuration passed to Bridge Driver" -} - // ErrInvalidNetworkConfig error is returned when a network is created on a driver without valid config. type ErrInvalidNetworkConfig struct{}