diff --git a/pkg/ingress/ingress.go b/pkg/ingress/ingress.go index 386a0741..385fb667 100644 --- a/pkg/ingress/ingress.go +++ b/pkg/ingress/ingress.go @@ -16,6 +16,7 @@ package ingress import ( "path/filepath" + "sync" "github.com/haproxytech/kubernetes-ingress/pkg/annotations" "github.com/haproxytech/kubernetes-ingress/pkg/haproxy" @@ -24,8 +25,11 @@ import ( "github.com/haproxytech/kubernetes-ingress/pkg/route" "github.com/haproxytech/kubernetes-ingress/pkg/service" "github.com/haproxytech/kubernetes-ingress/pkg/store" + "github.com/haproxytech/kubernetes-ingress/pkg/utils" ) +var ingressClassAnnotationDeprecationOnce sync.Once + type Ingress struct { annotations annotations.Annotations resource *store.Ingress @@ -35,6 +39,12 @@ type Ingress struct { sslPassthrough bool } +func logIngressClassAnnotationDeprecationWarning() { + ingressClassAnnotationDeprecationOnce.Do(func() { + utils.GetLogger().Warningf("`ingress.class` annotation is deprecated, please use `spec.ingressClassName` instead. Support for `ingress.class` annotation will be removed.") + }) +} + // New returns an Ingress instance to handle the k8s ingress resource given in params. // If the k8s ingress resource is not assigned to the controller (no matching IngressClass) // then New will return nil @@ -55,6 +65,9 @@ func (i Ingress) Supported(k8s store.K8s, a annotations.Annotations) (supported var igClassAnn, igClassSpec string igClassAnn = a.String("ingress.class", i.resource.Annotations) + if igClassAnn != "" { + logIngressClassAnnotationDeprecationWarning() + } if igClassResource := k8s.IngressClasses[i.resource.Class]; igClassResource != nil { igClassSpec = igClassResource.Controller }