Remove hard-coded annotation and don't use map pointers
This commit is contained in:
parent
c2550930b1
commit
5c30820d1f
43 changed files with 179 additions and 173 deletions
|
|
@ -26,6 +26,7 @@ import (
|
|||
appsv1 "k8s.io/api/apps/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"k8s.io/ingress-nginx/internal/ingress/annotations/class"
|
||||
"k8s.io/ingress-nginx/test/e2e/framework"
|
||||
)
|
||||
|
||||
|
|
@ -44,9 +45,9 @@ var _ = framework.IngressNginxDescribe("Ingress class", func() {
|
|||
It("should ignore Ingress with class", func() {
|
||||
invalidHost := "foo"
|
||||
annotations := map[string]string{
|
||||
"kubernetes.io/ingress.class": "testclass",
|
||||
class.IngressKey: "testclass",
|
||||
}
|
||||
ing := framework.NewSingleIngress(invalidHost, "/", invalidHost, f.Namespace, framework.EchoService, 80, &annotations)
|
||||
ing := framework.NewSingleIngress(invalidHost, "/", invalidHost, f.Namespace, framework.EchoService, 80, annotations)
|
||||
f.EnsureIngress(ing)
|
||||
|
||||
validHost := "bar"
|
||||
|
|
@ -76,7 +77,7 @@ var _ = framework.IngressNginxDescribe("Ingress class", func() {
|
|||
|
||||
Context("With a specific ingress-class", func() {
|
||||
BeforeEach(func() {
|
||||
framework.UpdateDeployment(f.KubeClientSet, f.Namespace, "nginx-ingress-controller", 1,
|
||||
err := framework.UpdateDeployment(f.KubeClientSet, f.Namespace, "nginx-ingress-controller", 1,
|
||||
func(deployment *appsv1.Deployment) error {
|
||||
args := deployment.Spec.Template.Spec.Containers[0].Args
|
||||
args = append(args, "--ingress-class=testclass")
|
||||
|
|
@ -85,6 +86,7 @@ var _ = framework.IngressNginxDescribe("Ingress class", func() {
|
|||
|
||||
return err
|
||||
})
|
||||
Expect(err).To(BeNil())
|
||||
})
|
||||
|
||||
It("should ignore Ingress with no class", func() {
|
||||
|
|
@ -95,9 +97,9 @@ var _ = framework.IngressNginxDescribe("Ingress class", func() {
|
|||
|
||||
validHost := "foo"
|
||||
annotations := map[string]string{
|
||||
"kubernetes.io/ingress.class": "testclass",
|
||||
class.IngressKey: "testclass",
|
||||
}
|
||||
ing = framework.NewSingleIngress(validHost, "/", validHost, f.Namespace, framework.EchoService, 80, &annotations)
|
||||
ing = framework.NewSingleIngress(validHost, "/", validHost, f.Namespace, framework.EchoService, 80, annotations)
|
||||
f.EnsureIngress(ing)
|
||||
|
||||
f.WaitForNginxServer(validHost, func(cfg string) bool {
|
||||
|
|
@ -126,10 +128,10 @@ var _ = framework.IngressNginxDescribe("Ingress class", func() {
|
|||
It("should delete Ingress when class is removed", func() {
|
||||
host := "foo"
|
||||
annotations := map[string]string{
|
||||
"kubernetes.io/ingress.class": "testclass",
|
||||
class.IngressKey: "testclass",
|
||||
}
|
||||
ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, &annotations)
|
||||
ing = f.EnsureIngress(ing)
|
||||
ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, annotations)
|
||||
f.EnsureIngress(ing)
|
||||
|
||||
f.WaitForNginxServer(host, func(cfg string) bool {
|
||||
return strings.Contains(cfg, "server_name foo")
|
||||
|
|
@ -145,8 +147,9 @@ var _ = framework.IngressNginxDescribe("Ingress class", func() {
|
|||
ing, err := f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Get(host, metav1.GetOptions{})
|
||||
Expect(err).To(BeNil())
|
||||
|
||||
delete(ing.Annotations, "kubernetes.io/ingress.class")
|
||||
f.EnsureIngress(ing)
|
||||
delete(ing.Annotations, class.IngressKey)
|
||||
_, err = f.KubeClientSet.NetworkingV1beta1().Ingresses(ing.Namespace).Update(ing)
|
||||
Expect(err).To(BeNil())
|
||||
|
||||
f.WaitForNginxConfiguration(func(cfg string) bool {
|
||||
return !strings.Contains(cfg, "server_name foo")
|
||||
|
|
@ -160,5 +163,4 @@ var _ = framework.IngressNginxDescribe("Ingress class", func() {
|
|||
Expect(resp.StatusCode).Should(Equal(http.StatusNotFound))
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue