Migrate ingress.class annotation to new IngressClassName field
This commit is contained in:
parent
461aa93d13
commit
04ef782c57
7 changed files with 46 additions and 27 deletions
|
|
@ -190,7 +190,8 @@ func TestCheckIngress(t *testing.T) {
|
|||
}
|
||||
|
||||
t.Run("When the ingress class differs from nginx", func(t *testing.T) {
|
||||
ing.ObjectMeta.Annotations["kubernetes.io/ingress.class"] = "different"
|
||||
class := "different"
|
||||
ing.Spec.IngressClassName = &class
|
||||
nginx.command = testNginxTestCommand{
|
||||
t: t,
|
||||
err: fmt.Errorf("test error"),
|
||||
|
|
@ -201,7 +202,8 @@ func TestCheckIngress(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("when the class is the nginx one", func(t *testing.T) {
|
||||
ing.ObjectMeta.Annotations["kubernetes.io/ingress.class"] = "nginx"
|
||||
class := "nginx"
|
||||
ing.Spec.IngressClassName = &class
|
||||
nginx.command = testNginxTestCommand{
|
||||
t: t,
|
||||
err: nil,
|
||||
|
|
|
|||
|
|
@ -949,12 +949,22 @@ func toIngress(obj interface{}) (*networkingv1beta1.Ingress, bool) {
|
|||
return nil, false
|
||||
}
|
||||
|
||||
ing.Spec.IngressClassName = extractClassName(ing)
|
||||
return ing, true
|
||||
}
|
||||
|
||||
if ing, ok := obj.(*networkingv1beta1.Ingress); ok {
|
||||
ing.Spec.IngressClassName = extractClassName(ing)
|
||||
return ing, true
|
||||
}
|
||||
|
||||
return nil, false
|
||||
}
|
||||
|
||||
func extractClassName(ing *networkingv1beta1.Ingress) *string {
|
||||
if c, ok := ing.Annotations[class.IngressKey]; ok {
|
||||
return &c
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue