Skip to content

Commit

Permalink
MINOR: add deprecation warning for ingressclass annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
hdurand0710 committed Feb 6, 2025
1 parent 0be557b commit 46d0906
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkg/ingress/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package ingress

import (
"path/filepath"
"sync"

"github.com/haproxytech/kubernetes-ingress/pkg/annotations"
"github.com/haproxytech/kubernetes-ingress/pkg/haproxy"
Expand All @@ -25,9 +26,12 @@ import (
"github.com/haproxytech/kubernetes-ingress/pkg/secret"
"github.com/haproxytech/kubernetes-ingress/pkg/service"
"github.com/haproxytech/kubernetes-ingress/pkg/store"
"github.com/haproxytech/kubernetes-ingress/pkg/utils"
"k8s.io/apimachinery/pkg/types"
)

var ingressClassAnnotationDeprecationOnce sync.Once

type Ingress struct {
annotations annotations.Annotations
resource *store.Ingress
Expand All @@ -37,6 +41,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
Expand All @@ -57,6 +67,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
}
Expand Down

0 comments on commit 46d0906

Please sign in to comment.