Merge pull request #115447 from kidddddddddddddddddddddd/ingress

[ingress] Create with ingressClass annotation and IngressClassName both set
This commit is contained in:
Kubernetes Prow Robot
2023-03-15 02:02:16 -07:00
committed by GitHub
3 changed files with 25 additions and 5 deletions

View File

@@ -277,9 +277,9 @@ func ValidateIngressCreate(ingress *networking.Ingress) field.ErrorList {
}
allErrs = append(allErrs, validateIngress(ingress, opts)...)
annotationVal, annotationIsSet := ingress.Annotations[annotationIngressClass]
if annotationIsSet && ingress.Spec.IngressClassName != nil {
if annotationIsSet && ingress.Spec.IngressClassName != nil && annotationVal != *ingress.Spec.IngressClassName {
annotationPath := field.NewPath("annotations").Child(annotationIngressClass)
allErrs = append(allErrs, field.Invalid(annotationPath, annotationVal, "can not be set when the class field is also set"))
allErrs = append(allErrs, field.Invalid(annotationPath, annotationVal, "must match `ingressClassName` when both are specified"))
}
return allErrs
}