Skip to content

Commit 46d0906

Browse files
committed
MINOR: add deprecation warning for ingressclass annotation
1 parent 0be557b commit 46d0906

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

pkg/ingress/ingress.go

+13
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"
@@ -25,9 +26,12 @@ import (
2526
"github.com/haproxytech/kubernetes-ingress/pkg/secret"
2627
"github.com/haproxytech/kubernetes-ingress/pkg/service"
2728
"github.com/haproxytech/kubernetes-ingress/pkg/store"
29+
"github.com/haproxytech/kubernetes-ingress/pkg/utils"
2830
"k8s.io/apimachinery/pkg/types"
2931
)
3032

33+
var ingressClassAnnotationDeprecationOnce sync.Once
34+
3135
type Ingress struct {
3236
annotations annotations.Annotations
3337
resource *store.Ingress
@@ -37,6 +41,12 @@ type Ingress struct {
3741
sslPassthrough bool
3842
}
3943

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

5868
var igClassAnn, igClassSpec string
5969
igClassAnn = a.String("ingress.class", i.resource.Annotations)
70+
if igClassAnn != "" {
71+
logIngressClassAnnotationDeprecationWarning()
72+
}
6073
if igClassResource := k8s.IngressClasses[i.resource.Class]; igClassResource != nil {
6174
igClassSpec = igClassResource.Controller
6275
}

0 commit comments

Comments
 (0)