Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: dedup the route context code using reflection #1502

Merged
merged 9 commits into from
Jun 22, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ gateways:
- group: gateway.networking.k8s.io
kind: GRPCRoute
grpcRoutes:
- metadata:
- kind: GRPCRoute
metadata:
creationTimestamp: null
name: backend
namespace: default
Expand Down Expand Up @@ -253,7 +254,8 @@ grpcRoutes:
name: eg
sectionName: grpc
httpRoutes:
- metadata:
- kind: HTTPRoute
metadata:
creationTimestamp: null
name: backend
namespace: default
Expand Down Expand Up @@ -290,7 +292,8 @@ httpRoutes:
parentRef:
name: eg
tcpRoutes:
- metadata:
- kind: TCPRoute
metadata:
creationTimestamp: null
name: backend
namespace: default
Expand Down Expand Up @@ -323,7 +326,8 @@ tcpRoutes:
name: eg
sectionName: tcp
tlsRoutes:
- metadata:
- kind: TLSRoute
metadata:
creationTimestamp: null
name: backend
namespace: default
Expand Down Expand Up @@ -356,7 +360,8 @@ tlsRoutes:
name: eg
sectionName: tls-passthrough
udpRoutes:
- metadata:
- kind: UDPRoute
metadata:
creationTimestamp: null
name: backend
namespace: default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ gateways:
- group: gateway.networking.k8s.io
kind: GRPCRoute
httpRoutes:
- metadata:
- kind: HTTPRoute
metadata:
creationTimestamp: null
name: backend
namespace: envoy-gateway-system
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
],
"httpRoutes": [
{
"kind": "HTTPRoute",
"metadata": {
"name": "backend",
"namespace": "envoy-gateway-system",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ gateways:
- group: gateway.networking.k8s.io
kind: GRPCRoute
grpcRoutes:
- metadata:
- kind: GRPCRoute
metadata:
creationTimestamp: null
name: backend
namespace: default
Expand Down Expand Up @@ -193,7 +194,8 @@ grpcRoutes:
name: eg
sectionName: grpc
httpRoutes:
- metadata:
- kind: HTTPRoute
metadata:
creationTimestamp: null
name: backend
namespace: default
Expand Down Expand Up @@ -230,7 +232,8 @@ httpRoutes:
parentRef:
name: eg
tcpRoutes:
- metadata:
- kind: TCPRoute
metadata:
creationTimestamp: null
name: backend
namespace: default
Expand Down Expand Up @@ -263,7 +266,8 @@ tcpRoutes:
name: eg
sectionName: tcp
tlsRoutes:
- metadata:
- kind: TLSRoute
metadata:
creationTimestamp: null
name: backend
namespace: default
Expand Down Expand Up @@ -296,7 +300,8 @@ tlsRoutes:
name: eg
sectionName: tls-passthrough
udpRoutes:
- metadata:
- kind: UDPRoute
metadata:
creationTimestamp: null
name: backend
namespace: default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ gateways:
- group: gateway.networking.k8s.io
kind: TLSRoute
httpRoutes:
- metadata:
- kind: "HTTPRoute"
metadata:
creationTimestamp: null
name: backend
namespace: envoy-gateway-system
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ gateways:
- group: gateway.networking.k8s.io
kind: GRPCRoute
grpcRoutes:
- metadata:
- kind: GRPCRoute
metadata:
creationTimestamp: null
name: backend
namespace: default
Expand Down Expand Up @@ -188,7 +189,8 @@ grpcRoutes:
name: eg
sectionName: grpc
httpRoutes:
- metadata:
- kind: HTTPRoute
metadata:
creationTimestamp: null
name: backend
namespace: default
Expand Down Expand Up @@ -225,7 +227,8 @@ httpRoutes:
parentRef:
name: eg
tcpRoutes:
- metadata:
- kind: TCPRoute
metadata:
creationTimestamp: null
name: backend
namespace: default
Expand Down Expand Up @@ -258,7 +261,8 @@ tcpRoutes:
name: eg
sectionName: tcp
tlsRoutes:
- metadata:
- kind: TLSRoute
metadata:
creationTimestamp: null
name: backend
namespace: default
Expand Down Expand Up @@ -291,7 +295,8 @@ tlsRoutes:
name: eg
sectionName: tls-passthrough
udpRoutes:
- metadata:
- kind: UDPRoute
metadata:
creationTimestamp: null
name: backend
namespace: default
Expand Down
15 changes: 15 additions & 0 deletions internal/cmd/egctl/translate.go
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,9 @@ func kubernetesYAMLToResources(str string, addMissingResources bool) (*gatewayap
case gatewayapi.KindTCPRoute:
typedSpec := spec.Interface()
tcpRoute := &v1alpha2.TCPRoute{
TypeMeta: metav1.TypeMeta{
Kind: gatewayapi.KindTCPRoute,
},
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: namespace,
Expand All @@ -651,6 +654,9 @@ func kubernetesYAMLToResources(str string, addMissingResources bool) (*gatewayap
case gatewayapi.KindUDPRoute:
typedSpec := spec.Interface()
udpRoute := &v1alpha2.UDPRoute{
TypeMeta: metav1.TypeMeta{
Kind: gatewayapi.KindUDPRoute,
},
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: namespace,
Expand All @@ -661,6 +667,9 @@ func kubernetesYAMLToResources(str string, addMissingResources bool) (*gatewayap
case gatewayapi.KindTLSRoute:
typedSpec := spec.Interface()
tlsRoute := &v1alpha2.TLSRoute{
TypeMeta: metav1.TypeMeta{
Kind: gatewayapi.KindTLSRoute,
},
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: namespace,
Expand All @@ -671,6 +680,9 @@ func kubernetesYAMLToResources(str string, addMissingResources bool) (*gatewayap
case gatewayapi.KindHTTPRoute:
typedSpec := spec.Interface()
httpRoute := &v1beta1.HTTPRoute{
TypeMeta: metav1.TypeMeta{
Kind: gatewayapi.KindHTTPRoute,
},
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: namespace,
Expand All @@ -681,6 +693,9 @@ func kubernetesYAMLToResources(str string, addMissingResources bool) (*gatewayap
case gatewayapi.KindGRPCRoute:
typedSpec := spec.Interface()
grpcRoute := &v1alpha2.GRPCRoute{
TypeMeta: metav1.TypeMeta{
Kind: gatewayapi.KindGRPCRoute,
},
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: namespace,
Expand Down
Loading