Include the actual failing value in a validation error message
This commit is contained in:
@@ -1081,7 +1081,7 @@ func ValidateService(service *api.Service) errs.ValidationErrorList {
|
|||||||
if service.Spec.Type == api.ServiceTypeLoadBalancer {
|
if service.Spec.Type == api.ServiceTypeLoadBalancer {
|
||||||
for i := range service.Spec.Ports {
|
for i := range service.Spec.Ports {
|
||||||
if service.Spec.Ports[i].Protocol != api.ProtocolTCP {
|
if service.Spec.Ports[i].Protocol != api.ProtocolTCP {
|
||||||
allErrs = append(allErrs, errs.NewFieldInvalid(fmt.Sprintf("spec.ports[%d].protocol", i), service.Spec.Ports[i], "cannot create an external load balancer with non-TCP ports"))
|
allErrs = append(allErrs, errs.NewFieldInvalid(fmt.Sprintf("spec.ports[%d].protocol", i), service.Spec.Ports[i].Protocol, "cannot create an external load balancer with non-TCP ports"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1089,7 +1089,7 @@ func ValidateService(service *api.Service) errs.ValidationErrorList {
|
|||||||
if service.Spec.Type == api.ServiceTypeClusterIP {
|
if service.Spec.Type == api.ServiceTypeClusterIP {
|
||||||
for i := range service.Spec.Ports {
|
for i := range service.Spec.Ports {
|
||||||
if service.Spec.Ports[i].NodePort != 0 {
|
if service.Spec.Ports[i].NodePort != 0 {
|
||||||
allErrs = append(allErrs, errs.NewFieldInvalid(fmt.Sprintf("spec.ports[%d].nodePort", i), service.Spec.Ports[i], "cannot specify a node port with services of type ClusterIP"))
|
allErrs = append(allErrs, errs.NewFieldInvalid(fmt.Sprintf("spec.ports[%d].nodePort", i), service.Spec.Ports[i].NodePort, "cannot specify a node port with services of type ClusterIP"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1106,7 +1106,7 @@ func ValidateService(service *api.Service) errs.ValidationErrorList {
|
|||||||
key.NodePort = port.NodePort
|
key.NodePort = port.NodePort
|
||||||
_, found := nodePorts[key]
|
_, found := nodePorts[key]
|
||||||
if found {
|
if found {
|
||||||
allErrs = append(allErrs, errs.NewFieldInvalid(fmt.Sprintf("spec.ports[%d].nodePort", i), *port, "duplicate nodePort specified"))
|
allErrs = append(allErrs, errs.NewFieldInvalid(fmt.Sprintf("spec.ports[%d].nodePort", i), port.NodePort, "duplicate nodePort specified"))
|
||||||
}
|
}
|
||||||
nodePorts[key] = true
|
nodePorts[key] = true
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user