Bläddra i källkod

libnet/d/bridge: Inline InvalidLinkIPAddrError

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
Albin Kerouanton 1 år sedan
förälder
incheckning
e2d400bea9
2 ändrade filer med 2 tillägg och 12 borttagningar
  1. 0 10
      libnetwork/drivers/bridge/errors.go
  2. 2 2
      libnetwork/drivers/bridge/link.go

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

@@ -251,13 +251,3 @@ type IPv6AddrNoMatchError net.IPNet
 func (ipv6 *IPv6AddrNoMatchError) Error() string {
 	return fmt.Sprintf("bridge IPv6 addresses do not match the expected bridge configuration %s", (*net.IPNet)(ipv6).String())
 }
-
-// InvalidLinkIPAddrError is returned when a link is configured to a container with an invalid ip address
-type InvalidLinkIPAddrError string
-
-func (address InvalidLinkIPAddrError) Error() string {
-	return fmt.Sprintf("Cannot link to a container with Invalid IP Address '%s'", string(address))
-}
-
-// BadRequest denotes the type of this error
-func (address InvalidLinkIPAddrError) BadRequest() {}

+ 2 - 2
libnetwork/drivers/bridge/link.go

@@ -68,11 +68,11 @@ func linkContainers(action, parentIP, childIP string, ports []types.TransportPor
 
 	ip1 := net.ParseIP(parentIP)
 	if ip1 == nil {
-		return InvalidLinkIPAddrError(parentIP)
+		return fmt.Errorf("cannot link to a container with an invalid parent IP address %q", parentIP)
 	}
 	ip2 := net.ParseIP(childIP)
 	if ip2 == nil {
-		return InvalidLinkIPAddrError(childIP)
+		return fmt.Errorf("cannot link to a container with an invalid child IP address %q", childIP)
 	}
 
 	chain := iptables.ChainInfo{Name: DockerChain}