Skip to content

Commit

Permalink
feat: update GRPCRoute client to stable
Browse files Browse the repository at this point in the history
  • Loading branch information
thameezb authored and oferzern committed Jul 14, 2024
1 parent 8728b25 commit 8f50848
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
11 changes: 5 additions & 6 deletions source/gateway_grpcroute.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,18 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
v1 "sigs.k8s.io/gateway-api/apis/v1"
"sigs.k8s.io/gateway-api/apis/v1alpha2"
informers "sigs.k8s.io/gateway-api/pkg/client/informers/externalversions"
informers_v1a2 "sigs.k8s.io/gateway-api/pkg/client/informers/externalversions/apis/v1alpha2"
informers_v1 "sigs.k8s.io/gateway-api/pkg/client/informers/externalversions/apis/v1"
)

// NewGatewayGRPCRouteSource creates a new Gateway GRPCRoute source with the given config.
func NewGatewayGRPCRouteSource(clients ClientGenerator, config *Config) (Source, error) {
return newGatewayRouteSource(clients, config, "GRPCRoute", func(factory informers.SharedInformerFactory) gatewayRouteInformer {
return &gatewayGRPCRouteInformer{factory.Gateway().V1alpha2().GRPCRoutes()}
return &gatewayGRPCRouteInformer{factory.Gateway().V1().GRPCRoutes()}
})
}

type gatewayGRPCRoute struct{ route v1alpha2.GRPCRoute } // NOTE: Must update TypeMeta in List when changing the APIVersion.
type gatewayGRPCRoute struct{ route v1.GRPCRoute } // NOTE: Must update TypeMeta in List when changing the APIVersion.

func (rt *gatewayGRPCRoute) Object() kubeObject { return &rt.route }
func (rt *gatewayGRPCRoute) Metadata() *metav1.ObjectMeta { return &rt.route.ObjectMeta }
Expand All @@ -41,7 +40,7 @@ func (rt *gatewayGRPCRoute) Protocol() v1.ProtocolType { return v1.HTTPSProto
func (rt *gatewayGRPCRoute) RouteStatus() v1.RouteStatus { return rt.route.Status.RouteStatus }

type gatewayGRPCRouteInformer struct {
informers_v1a2.GRPCRouteInformer
informers_v1.GRPCRouteInformer
}

func (inf gatewayGRPCRouteInformer) List(namespace string, selector labels.Selector) ([]gatewayRoute, error) {
Expand All @@ -55,7 +54,7 @@ func (inf gatewayGRPCRouteInformer) List(namespace string, selector labels.Selec
// We make a shallow copy since we're only interested in setting the TypeMeta.
clone := *rt
clone.TypeMeta = metav1.TypeMeta{
APIVersion: v1alpha2.GroupVersion.String(),
APIVersion: v1.GroupVersion.String(),
Kind: "GRPCRoute",
}
routes[i] = &gatewayGRPCRoute{clone}
Expand Down
5 changes: 2 additions & 3 deletions source/gateway_grpcroute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
kubefake "k8s.io/client-go/kubernetes/fake"
"sigs.k8s.io/external-dns/endpoint"
v1 "sigs.k8s.io/gateway-api/apis/v1"
"sigs.k8s.io/gateway-api/apis/v1alpha2"
gatewayfake "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned/fake"
)

Expand Down Expand Up @@ -64,7 +63,7 @@ func TestGatewayGRPCRouteSourceEndpoints(t *testing.T) {
_, err = gwClient.GatewayV1().Gateways(gw.Namespace).Create(ctx, gw, metav1.CreateOptions{})
require.NoError(t, err, "failed to create Gateway")

rt := &v1alpha2.GRPCRoute{
rt := &v1.GRPCRoute{
ObjectMeta: metav1.ObjectMeta{
Name: "api",
Namespace: "default",
Expand All @@ -79,7 +78,7 @@ func TestGatewayGRPCRouteSourceEndpoints(t *testing.T) {
RouteStatus: gwRouteStatus(gwParentRef("default", "internal")),
},
}
_, err = gwClient.GatewayV1alpha2().GRPCRoutes(rt.Namespace).Create(ctx, rt, metav1.CreateOptions{})
_, err = gwClient.GatewayV1().GRPCRoutes(rt.Namespace).Create(ctx, rt, metav1.CreateOptions{})
require.NoError(t, err, "failed to create GRPCRoute")

src, err := NewGatewayGRPCRouteSource(clients, &Config{
Expand Down

0 comments on commit 8f50848

Please sign in to comment.