mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 02:41:25 +00:00
update description
This commit is contained in:
parent
113355a5a2
commit
488d7650f4
@ -278,7 +278,7 @@ func ValidateIngressCreate(ingress *networking.Ingress) field.ErrorList {
|
|||||||
annotationVal, annotationIsSet := ingress.Annotations[annotationIngressClass]
|
annotationVal, annotationIsSet := ingress.Annotations[annotationIngressClass]
|
||||||
if annotationIsSet && ingress.Spec.IngressClassName != nil && annotationVal != *ingress.Spec.IngressClassName {
|
if annotationIsSet && ingress.Spec.IngressClassName != nil && annotationVal != *ingress.Spec.IngressClassName {
|
||||||
annotationPath := field.NewPath("annotations").Child(annotationIngressClass)
|
annotationPath := field.NewPath("annotations").Child(annotationIngressClass)
|
||||||
allErrs = append(allErrs, field.Invalid(annotationPath, annotationVal, "ingressClass annotation and IngressClassName should have the same value"))
|
allErrs = append(allErrs, field.Invalid(annotationPath, annotationVal, "must match `ingressClassName` when both are specified"))
|
||||||
}
|
}
|
||||||
return allErrs
|
return allErrs
|
||||||
}
|
}
|
||||||
|
@ -1005,7 +1005,7 @@ func TestValidateIngressCreate(t *testing.T) {
|
|||||||
ingress.Spec.IngressClassName = utilpointer.String("bar")
|
ingress.Spec.IngressClassName = utilpointer.String("bar")
|
||||||
ingress.Annotations = map[string]string{annotationIngressClass: "foo"}
|
ingress.Annotations = map[string]string{annotationIngressClass: "foo"}
|
||||||
},
|
},
|
||||||
expectedErrs: field.ErrorList{field.Invalid(field.NewPath("annotations").Child(annotationIngressClass), "foo", "ingressClass annotation and IngressClassName should have the same value")},
|
expectedErrs: field.ErrorList{field.Invalid(field.NewPath("annotations").Child(annotationIngressClass), "foo", "must match `ingressClassName` when both are specified")},
|
||||||
},
|
},
|
||||||
"valid regex path": {
|
"valid regex path": {
|
||||||
tweakIngress: func(ingress *networking.Ingress) {
|
tweakIngress: func(ingress *networking.Ingress) {
|
||||||
|
@ -18,6 +18,7 @@ package ingress
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
@ -101,8 +102,8 @@ func (ingressStrategy) WarningsOnCreate(ctx context.Context, obj runtime.Object)
|
|||||||
var warnings []string
|
var warnings []string
|
||||||
ingress := obj.(*networking.Ingress)
|
ingress := obj.(*networking.Ingress)
|
||||||
_, annotationIsSet := ingress.Annotations[annotationIngressClass]
|
_, annotationIsSet := ingress.Annotations[annotationIngressClass]
|
||||||
if annotationIsSet && ingress.Spec.IngressClassName != nil {
|
if annotationIsSet && ingress.Spec.IngressClassName == nil {
|
||||||
warnings = append(warnings, "ingressClass annotation and IngressClassName should not be set at the same time")
|
warnings = append(warnings, fmt.Sprintf("annotation %q is deprecated, please use 'spec.ingressClassName' instead", annotationIngressClass))
|
||||||
}
|
}
|
||||||
return warnings
|
return warnings
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package ingress
|
package ingress
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/google/go-cmp/cmp"
|
"github.com/google/go-cmp/cmp"
|
||||||
@ -175,17 +176,11 @@ func TestWarningsOnCreate(t *testing.T) {
|
|||||||
tweakIngress func(ingress *networking.Ingress)
|
tweakIngress func(ingress *networking.Ingress)
|
||||||
expectedWarnings []string
|
expectedWarnings []string
|
||||||
}{
|
}{
|
||||||
"ingressClass annotation and IngressClassName set": {
|
"ingressClass annotation set, IngressClassName not set": {
|
||||||
tweakIngress: func(ingress *networking.Ingress) {
|
|
||||||
ingress.Spec.IngressClassName = utilpointer.String("foo")
|
|
||||||
ingress.Annotations = map[string]string{annotationIngressClass: "foo"}
|
|
||||||
},
|
|
||||||
expectedWarnings: []string{"ingressClass annotation and IngressClassName should not be set at the same time"},
|
|
||||||
},
|
|
||||||
"ingressClass annotation set": {
|
|
||||||
tweakIngress: func(ingress *networking.Ingress) {
|
tweakIngress: func(ingress *networking.Ingress) {
|
||||||
ingress.Annotations = map[string]string{annotationIngressClass: "foo"}
|
ingress.Annotations = map[string]string{annotationIngressClass: "foo"}
|
||||||
},
|
},
|
||||||
|
expectedWarnings: []string{fmt.Sprintf("annotation %q is deprecated, please use 'spec.ingressClassName' instead", annotationIngressClass)},
|
||||||
},
|
},
|
||||||
"IngressClassName set": {
|
"IngressClassName set": {
|
||||||
tweakIngress: func(ingress *networking.Ingress) {
|
tweakIngress: func(ingress *networking.Ingress) {
|
||||||
|
Loading…
Reference in New Issue
Block a user