浏览代码

libnet/d/bridge: Inline IPTableCfgError

This error is only used in defensive checks whereas the precondition is
already checked by caller. If we reach it, we messed something else. So
it's definitely not a BadRequest. Also, it's not type asserted anywhere,
so just inline it.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
Albin Kerouanton 1 年之前
父节点
当前提交
d8f42ee21a
共有 2 个文件被更改,包括 7 次插入13 次删除
  1. 0 10
      libnetwork/drivers/bridge/errors.go
  2. 7 3
      libnetwork/drivers/bridge/setup_firewalld.go

+ 0 - 10
libnetwork/drivers/bridge/errors.go

@@ -209,16 +209,6 @@ func (fcv6 *FixedCIDRv6Error) Error() string {
 // InternalError denotes the type of this error
 func (fcv6 *FixedCIDRv6Error) InternalError() {}
 
-// IPTableCfgError is returned when an unexpected ip tables configuration is entered
-type IPTableCfgError string
-
-func (name IPTableCfgError) Error() string {
-	return fmt.Sprintf("unexpected request to set IP tables for interface: %s", string(name))
-}
-
-// BadRequest denotes the type of this error
-func (name IPTableCfgError) BadRequest() {}
-
 // InvalidIPTablesCfgError is returned when an invalid ip tables configuration is entered
 type InvalidIPTablesCfgError string
 

+ 7 - 3
libnetwork/drivers/bridge/setup_firewalld.go

@@ -2,7 +2,11 @@
 
 package bridge
 
-import "github.com/docker/docker/libnetwork/iptables"
+import (
+	"errors"
+
+	"github.com/docker/docker/libnetwork/iptables"
+)
 
 func (n *bridgeNetwork) setupFirewalld(config *networkConfiguration, i *bridgeInterface) error {
 	d := n.driver
@@ -12,7 +16,7 @@ func (n *bridgeNetwork) setupFirewalld(config *networkConfiguration, i *bridgeIn
 
 	// Sanity check.
 	if !driverConfig.EnableIPTables {
-		return IPTableCfgError(config.BridgeName)
+		return errors.New("no need to register firewalld hooks, iptables is disabled")
 	}
 
 	iptables.OnReloaded(func() { n.setupIP4Tables(config, i) })
@@ -28,7 +32,7 @@ func (n *bridgeNetwork) setupFirewalld6(config *networkConfiguration, i *bridgeI
 
 	// Sanity check.
 	if !driverConfig.EnableIP6Tables {
-		return IPTableCfgError(config.BridgeName)
+		return errors.New("no need to register firewalld hooks, ip6tables is disabled")
 	}
 
 	iptables.OnReloaded(func() { n.setupIP6Tables(config, i) })