Fix some macvlan error types for the API

Signed-off-by: Rob Murray <rob.murray@docker.com>
This commit is contained in:
Rob Murray
2024-07-12 17:25:04 +01:00
parent a7a5de676d
commit f57e0dc2ff
2 changed files with 4 additions and 3 deletions

View File

@@ -7,6 +7,7 @@ import (
"fmt"
"github.com/containerd/log"
"github.com/docker/docker/errdefs"
"github.com/docker/docker/libnetwork/driverapi"
"github.com/docker/docker/libnetwork/netlabel"
"github.com/docker/docker/libnetwork/netutils"
@@ -21,7 +22,7 @@ func (d *driver) CreateEndpoint(ctx context.Context, nid, eid string, ifInfo dri
}
n, err := d.getNetwork(nid)
if err != nil {
return fmt.Errorf("network id %q not found", nid)
return errdefs.System(fmt.Errorf("network id %q not found", nid))
}
ep := &endpoint{
id: eid,
@@ -31,7 +32,7 @@ func (d *driver) CreateEndpoint(ctx context.Context, nid, eid string, ifInfo dri
mac: ifInfo.MacAddress(),
}
if ep.addr == nil && ep.addrv6 == nil {
return fmt.Errorf("create endpoint was not passed an IP address")
return errdefs.InvalidParameter(fmt.Errorf("create endpoint was not passed an IP address"))
}
if ep.mac == nil {
if ep.addr != nil {

View File

@@ -20,7 +20,7 @@ func (d *driver) CreateNetwork(nid string, option map[string]interface{}, nInfo
// reject a null v4 network if ipv4 is required
if v, ok := option[netlabel.EnableIPv4]; ok && v.(bool) {
if len(ipV4Data) == 0 || ipV4Data[0].Pool.String() == "0.0.0.0/0" {
return fmt.Errorf("ipv4 pool is empty")
return errdefs.InvalidParameter(fmt.Errorf("ipv4 pool is empty"))
}
}
// reject a null v6 network if ipv6 is required