Use validation.IsValidIP in a few more places

Rather than using netutils.ParseIPSloppy directly.

Also fix the field paths in the errors for pod.spec.hostAliases to
include the array index.
This commit is contained in:
Dan Winship
2023-12-26 19:26:24 -05:00
parent 519dd6887d
commit 1d59d6b6c6
2 changed files with 7 additions and 15 deletions

View File

@@ -354,9 +354,7 @@ func ValidateIngressLoadBalancerStatus(status *networking.IngressLoadBalancerSta
for i, ingress := range status.Ingress {
idxPath := fldPath.Child("ingress").Index(i)
if len(ingress.IP) > 0 {
if isIP := (netutils.ParseIPSloppy(ingress.IP) != nil); !isIP {
allErrs = append(allErrs, field.Invalid(idxPath.Child("ip"), ingress.IP, "must be a valid IP address"))
}
allErrs = append(allErrs, validation.IsValidIP(idxPath.Child("ip"), ingress.IP)...)
}
if len(ingress.Hostname) > 0 {
for _, msg := range validation.IsDNS1123Subdomain(ingress.Hostname) {