diff --git a/plugins/ipam/static/main.go b/plugins/ipam/static/main.go index ed75d1fe2..9156cad4a 100644 --- a/plugins/ipam/static/main.go +++ b/plugins/ipam/static/main.go @@ -161,7 +161,7 @@ func LoadIPAMConfig(bytes []byte, envArgs string) (*IPAMConfig, string, error) { ip, subnet, err := net.ParseCIDR(ipstr) if err != nil { - return nil, "", err + return nil, "", fmt.Errorf("the 'ip' field is expected to be in CIDR notation, got: '%s'", ipstr) } addr := Address{ @@ -213,7 +213,8 @@ func LoadIPAMConfig(bytes []byte, envArgs string) (*IPAMConfig, string, error) { for i := range n.IPAM.Addresses { ip, addr, err := net.ParseCIDR(n.IPAM.Addresses[i].AddressStr) if err != nil { - return nil, "", err + return nil, "", fmt.Errorf( + "the 'address' field is expected to be in CIDR notation, got: '%s'", n.IPAM.Addresses[i].AddressStr) } n.IPAM.Addresses[i].Address = *addr n.IPAM.Addresses[i].Address.IP = ip diff --git a/plugins/ipam/static/static_test.go b/plugins/ipam/static/static_test.go index 47a0078ae..5ce78096c 100644 --- a/plugins/ipam/static/static_test.go +++ b/plugins/ipam/static/static_test.go @@ -575,8 +575,8 @@ var _ = Describe("static Operations", func() { _, _, err := testutils.CmdAddWithArgs(args, func() error { return cmdAdd(args) }) - Expect(err).Should( - MatchError(fmt.Sprintf("invalid CIDR address: %s", ipStr))) + Expect(err).Should(MatchError( + fmt.Sprintf("the 'address' field is expected to be in CIDR notation, got: '%s'", ipStr))) }) } })