Skip to content

Commit

Permalink
remove comments and logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Revolyssup committed Jan 31, 2024
1 parent 0cea53e commit 40f70f9
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 33 deletions.
62 changes: 31 additions & 31 deletions pkg/kube/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion pkg/providers/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion pkg/providers/gateway/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 40f70f9

Please sign in to comment.