diff --git a/pkg/kube/gateway.go b/pkg/kube/gateway.go index 0a83924ca8..622d45f9af 100644 --- a/pkg/kube/gateway.go +++ b/pkg/kube/gateway.go @@ -25,35 +25,35 @@ import ( ) const ( - // IngressV1 represents the Ingress in networking/v1 group version. + // GatewayV1 represents the Gateway in networking/v1 group version. GatewayV1 = "gateway.networking.k8s.io/v1" - // IngressV1beta1 represents the Ingress in networking/v1beta1 group version. + // GatewayV1beta1 represents the Gateway in networking/v1beta1 group version. GatewayV1beta1 = "gateway.networking.k8s.io/v1beta1" ) -// IngressLister is an encapsulation for the lister of Kubernetes -// Ingress, it aims at to be compatible with different Ingress versions. +// GatewayLister is an encapsulation for the lister of Kubernetes +// Gateway, it aims at to be compatible with different Gateway versions. type GatewayLister interface { - // V1 gets the ingress in networking/v1. + // V1 gets the gateway in networking/v1. V1(string, string) (Gateway, error) - // V1beta1 gets the ingress in networking/v1beta1. + // V1beta1 gets the gateway in networking/v1beta1. V1beta1(string, string) (Gateway, error) } -// Ingress is an encapsulation for Kubernetes Ingress with different +// Gateway is an encapsulation for Kubernetes Gateway with different // versions, for now, they are networking/v1 and networking/v1beta1. type Gateway interface { // GroupVersion returns the api group version of the - // real ingress. + // real gateway. GroupVersion() string - // V1 returns the ingress in networking/v1, the real - // ingress must be in networking/v1, or V1() will panic. + // V1 returns the gateway in gateway/v1, the real + // gateway must be in gateway/v1, or V1() will panic. V1() *gatewayv1.Gateway - // V1beta1 returns the ingress in networking/v1beta1, the real - // ingress must be in networking/v1beta1, or V1beta1() will panic. + // V1beta1 returns the gateway in gateway/v1beta1, the real + // gateway must be in gateway/v1beta1, or V1beta1() will panic. V1beta1() *gatewayv1beta1.Gateway // ResourceVersion returns the the resource version field inside - // the real Ingress. + // the real Gateway. ResourceVersion() string metav1.Object @@ -65,33 +65,33 @@ type gateway struct { metav1.Object } -func (ing *gateway) V1() *gatewayv1.Gateway { - if ing.groupVersion != GatewayV1 { - panic("not a networking/v1 ingress") +func (gate *gateway) V1() *gatewayv1.Gateway { + if gate.groupVersion != GatewayV1 { + panic("not a networking/v1 gateway") } - return ing.v1 + return gate.v1 } -func (ing *gateway) V1beta1() *gatewayv1beta1.Gateway { - if ing.groupVersion != GatewayV1beta1 { - panic("not a networking/v1beta1 ingress") +func (gate *gateway) V1beta1() *gatewayv1beta1.Gateway { + if gate.groupVersion != GatewayV1beta1 { + panic("not a networking/v1beta1 gateway") } - fmt.Println("v1beta1 ", ing.v1beta1) - return ing.v1beta1 + fmt.Println("v1beta1 ", gate.v1beta1) + return gate.v1beta1 } -func (ing *gateway) GroupVersion() string { - return ing.groupVersion +func (gate *gateway) GroupVersion() string { + return gate.groupVersion } -func (ing *gateway) ResourceVersion() string { - if ing.GroupVersion() == GatewayV1beta1 { - return ing.V1beta1().ResourceVersion +func (gate *gateway) ResourceVersion() string { + if gate.GroupVersion() == GatewayV1beta1 { + return gate.V1beta1().ResourceVersion } - return ing.V1().ResourceVersion + return gate.V1().ResourceVersion } -// MustNewIngress creates a kube.Ingress object according to the +// MustNewGateway creates a kube.Gateway object according to the // type of obj. func MustNewGateway(obj interface{}) Gateway { switch gate := obj.(type) { @@ -113,7 +113,7 @@ func MustNewGateway(obj interface{}) Gateway { } } -// IngressEvents contains the ingress key (namespace/name) +// GatewayEvents contains the gateway key (namespace/name) // and the group version message. type GatewayEvent struct { Key string @@ -150,7 +150,7 @@ func (l *gatewayLister) V1beta1(namespace, name string) (Gateway, error) { }, nil } -// NewIngressLister creates an version-neutral Ingress lister. +// NewGatewayLister creates an version-neutral Gateway lister. func NewGatewayLister(v1 gatewayv1listers.GatewayLister, v1beta1 gatewayv1beta1listers.GatewayLister) GatewayLister { return &gatewayLister{ v1Lister: v1, diff --git a/pkg/providers/controller.go b/pkg/providers/controller.go index 99357d42e9..3402275058 100644 --- a/pkg/providers/controller.go +++ b/pkg/providers/controller.go @@ -363,7 +363,6 @@ func (c *Controller) initSharedInformers() *providertypes.ListerInformer { } ingressLister := kube.NewIngressLister(ingressListerV1, ingressListerV1beta1) - fmt.Println("gateway lister v1beta1 ", gatewayListerV1beta1, " and gateway lister v1 ", gatewayListerV1) gatewayLister := kube.NewGatewayLister(gatewayListerV1, gatewayListerV1beta1) listerInformer := &providertypes.ListerInformer{ ApisixFactory: apisixFactory, diff --git a/pkg/providers/gateway/gateway.go b/pkg/providers/gateway/gateway.go index 182bfd2e19..fcb2dff900 100644 --- a/pkg/providers/gateway/gateway.go +++ b/pkg/providers/gateway/gateway.go @@ -110,7 +110,6 @@ func (c *gatewayController) sync(ctx context.Context, ev *types.Event) error { return err } - fmt.Println("gateway returned by gatewaylister for v1beta1 ", gatev1beta) generation = gatev1beta.Generation }