Skip to content

Commit

Permalink
ipam: fix gateway being required for IPAddress
Browse files Browse the repository at this point in the history
  • Loading branch information
schrej committed Apr 11, 2023
1 parent 701b97b commit f5e6246
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions exp/ipam/internal/webhooks/ipaddress.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,16 @@ func (webhook *IPAddress) validate(ctx context.Context, ip *ipamv1.IPAddress) er
))
}

_, err = netip.ParseAddr(ip.Spec.Gateway)
if err != nil {
allErrs = append(allErrs,
field.Invalid(
specPath.Child("gateway"),
ip.Spec.Gateway,
"not a valid IP address",
))
if ip.Spec.Gateway != "" {
_, err = netip.ParseAddr(ip.Spec.Gateway)
if err != nil {
allErrs = append(allErrs,
field.Invalid(
specPath.Child("gateway"),
ip.Spec.Gateway,
"not a valid IP address",
))
}
}

if ip.Spec.PoolRef.APIGroup == nil {
Expand Down

0 comments on commit f5e6246

Please sign in to comment.