Skip to content

Commit

Permalink
static ipam: stop wrapping net.ParseCIDR errors
Browse files Browse the repository at this point in the history
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
  • Loading branch information
maiqueb committed Jun 22, 2021
1 parent 3ca8a2c commit a819b97
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions plugins/ipam/static/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func LoadIPAMConfig(bytes []byte, envArgs string) (*IPAMConfig, string, error) {

ip, subnet, err := net.ParseCIDR(ipstr)
if err != nil {
return nil, "", fmt.Errorf("invalid CIDR %s: %s", ipstr, err)
return nil, "", err
}

addr := Address{
Expand Down Expand Up @@ -213,7 +213,7 @@ 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, "", fmt.Errorf("invalid CIDR %s: %s", n.IPAM.Addresses[i].AddressStr, err)
return nil, "", err
}
n.IPAM.Addresses[i].Address = *addr
n.IPAM.Addresses[i].Address.IP = ip
Expand Down
2 changes: 1 addition & 1 deletion plugins/ipam/static/static_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ var _ = Describe("static Operations", func() {
return cmdAdd(args)
})
Expect(err).Should(
MatchError(fmt.Sprintf("invalid CIDR %s: invalid CIDR address: %s", ipStr, ipStr)))
MatchError(fmt.Sprintf("invalid CIDR address: %s", ipStr)))
})

}
Expand Down

0 comments on commit a819b97

Please sign in to comment.