Skip to content

Commit b1e289d

Browse files
committed
MINOR: add deprecation warning for ingressclass annotation
1 parent f480af3 commit b1e289d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

pkg/ingress/ingress.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package ingress
1616

1717
import (
1818
"path/filepath"
19+
"sync"
1920

2021
"github.com/haproxytech/kubernetes-ingress/pkg/annotations"
2122
"github.com/haproxytech/kubernetes-ingress/pkg/haproxy"
@@ -24,8 +25,11 @@ import (
2425
"github.com/haproxytech/kubernetes-ingress/pkg/route"
2526
"github.com/haproxytech/kubernetes-ingress/pkg/service"
2627
"github.com/haproxytech/kubernetes-ingress/pkg/store"
28+
"github.com/haproxytech/kubernetes-ingress/pkg/utils"
2729
)
2830

31+
var ingressClassAnnotationDeprecationOnce sync.Once
32+
2933
type Ingress struct {
3034
annotations annotations.Annotations
3135
resource *store.Ingress
@@ -35,6 +39,12 @@ type Ingress struct {
3539
sslPassthrough bool
3640
}
3741

42+
func logIngressClassAnnotationDeprecationWarning() {
43+
ingressClassAnnotationDeprecationOnce.Do(func() {
44+
utils.GetLogger().Warningf("`ingress.class` annotation is deprecated, please use `spec.ingressClassName` instead. Support for `ingress.class` annotation will be removed.")
45+
})
46+
}
47+
3848
// New returns an Ingress instance to handle the k8s ingress resource given in params.
3949
// If the k8s ingress resource is not assigned to the controller (no matching IngressClass)
4050
// then New will return nil
@@ -55,6 +65,9 @@ func (i Ingress) Supported(k8s store.K8s, a annotations.Annotations) (supported
5565

5666
var igClassAnn, igClassSpec string
5767
igClassAnn = a.String("ingress.class", i.resource.Annotations)
68+
if igClassAnn != "" {
69+
logIngressClassAnnotationDeprecationWarning()
70+
}
5871
if igClassResource := k8s.IngressClasses[i.resource.Class]; igClassResource != nil {
5972
igClassSpec = igClassResource.Controller
6073
}

0 commit comments

Comments
 (0)