Merge pull request #5508 from fgrzadkowski/validate_ips
Validate Service.Spec.publicIPs to be a valid IP that is not a localhost
This commit is contained in:
@@ -764,6 +764,14 @@ func ValidateService(service *api.Service) errs.ValidationErrorList {
|
||||
}
|
||||
}
|
||||
|
||||
for _, ip := range service.Spec.PublicIPs {
|
||||
if ip == "0.0.0.0" {
|
||||
allErrs = append(allErrs, errs.NewFieldInvalid("spec.publicIPs", ip, "is not an IP address"))
|
||||
} else if util.IsValidIP(ip) && net.ParseIP(ip).IsLoopback() {
|
||||
allErrs = append(allErrs, errs.NewFieldInvalid("spec.publicIPs", ip, "publicIP cannot be a loopback"))
|
||||
}
|
||||
}
|
||||
|
||||
return allErrs
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user