libnet/d/bridge: Inline InvalidLinkIPAddrError

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
This commit is contained in:
Albin Kerouanton
2023-07-31 21:27:32 +02:00
parent 6df4a00bb9
commit e2d400bea9
2 changed files with 2 additions and 12 deletions

View File

@@ -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() {}

View File

@@ -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}