Skip to content
This repository has been archived by the owner on Jan 17, 2025. It is now read-only.

Commit

Permalink
Relax validateCIDRAddress
Browse files Browse the repository at this point in the history
We only want to check that the value is a valid CIDR. Proper validation
happens upstream.

Signed-off-by: Dimitrios Karagiannis <dhkarag@gmail.com>
  • Loading branch information
alkar committed Jan 17, 2020
1 parent 566592c commit 243f199
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions megaport/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ func resourceMegaportVxcEndElem() *schema.Resource {
}

func validateCIDRAddress(v interface{}, k string) (warns []string, errs []error) {
vv := v.(string)
_, ipnet, err := net.ParseCIDR(vv)
if err != nil {
errs = append(errs, fmt.Errorf("%q is not a valid CIDR: %s", k, err))
vv, ok := v.(string)
if !ok {
errs = append(errs, fmt.Errorf("expected type of %s to be string", k))
return
}
if ipnet == nil || vv != ipnet.String() {
errs = append(errs, fmt.Errorf("%q is not a valid CIDR", k))
_, _, err := net.ParseCIDR(vv)
if err != nil {
errs = append(errs, fmt.Errorf("expected %q to be a valid IPv4 CIDR, got %v: %v", k, vv, err))
}
return
}
Expand Down

0 comments on commit 243f199

Please sign in to comment.