diff --git a/internal/cmd/egctl/translate.go b/internal/cmd/egctl/translate.go index 7b45c55c1c2c..3f7dea32ee9b 100644 --- a/internal/cmd/egctl/translate.go +++ b/internal/cmd/egctl/translate.go @@ -262,9 +262,10 @@ func translateGatewayAPIToGatewayAPI(resources *gatewayapi.Resources) (gatewayap // Translate from Gateway API to Xds IR gTranslator := &gatewayapi.Translator{ - GatewayControllerName: egv1alpha1.GatewayControllerName, - GatewayClassName: v1beta1.ObjectName(resources.GatewayClass.Name), - GlobalRateLimitEnabled: true, + GatewayControllerName: egv1alpha1.GatewayControllerName, + GatewayClassName: v1beta1.ObjectName(resources.GatewayClass.Name), + GlobalRateLimitEnabled: true, + EndpointRoutingDisabled: true, } gRes := gTranslator.Translate(resources) // Update the status of the GatewayClass based on EnvoyProxy validation @@ -292,9 +293,10 @@ func translateGatewayAPIToXds(dnsDomain string, resourceType string, resources * // Translate from Gateway API to Xds IR gTranslator := &gatewayapi.Translator{ - GatewayControllerName: egv1alpha1.GatewayControllerName, - GatewayClassName: v1beta1.ObjectName(resources.GatewayClass.Name), - GlobalRateLimitEnabled: true, + GatewayControllerName: egv1alpha1.GatewayControllerName, + GatewayClassName: v1beta1.ObjectName(resources.GatewayClass.Name), + GlobalRateLimitEnabled: true, + EndpointRoutingDisabled: true, } gRes := gTranslator.Translate(resources) diff --git a/internal/gatewayapi/helpers.go b/internal/gatewayapi/helpers.go index 238ba727d31a..d5426610905e 100644 --- a/internal/gatewayapi/helpers.go +++ b/internal/gatewayapi/helpers.go @@ -57,22 +57,6 @@ func SectionNamePtr(name string) *v1beta1.SectionName { return §ionName } -func TLSModeTypePtr(mode v1beta1.TLSModeType) *v1beta1.TLSModeType { - return &mode -} - -func BoolPtr(val bool) *bool { - return &val -} - -func StringPtr(val string) *string { - return &val -} - -func Int32Ptr(val int32) *int32 { - return &val -} - func PortNumPtr(val int32) *v1beta1.PortNumber { portNum := v1beta1.PortNumber(val) return &portNum @@ -83,18 +67,6 @@ func ObjectNamePtr(val string) *v1alpha2.ObjectName { return &objectName } -func PathMatchTypePtr(pType v1beta1.PathMatchType) *v1beta1.PathMatchType { - return &pType -} - -func GatewayAddressTypePtr(addr v1beta1.AddressType) *v1beta1.AddressType { - return &addr -} - -func ProtocolPtr(val v1.Protocol) *v1.Protocol { - return &val -} - func PathMatchTypeDerefOr(matchType *v1beta1.PathMatchType, defaultType v1beta1.PathMatchType) v1beta1.PathMatchType { if matchType != nil { return *matchType diff --git a/internal/gatewayapi/route.go b/internal/gatewayapi/route.go index c31cdb64dbcd..e1ee972548e9 100644 --- a/internal/gatewayapi/route.go +++ b/internal/gatewayapi/route.go @@ -15,6 +15,7 @@ import ( "sigs.k8s.io/gateway-api/apis/v1beta1" "github.com/envoyproxy/gateway/internal/ir" + "github.com/envoyproxy/gateway/internal/utils/ptr" ) var ( @@ -227,12 +228,12 @@ func (t *Translator) processHTTPRouteRule(httpRoute *HTTPRouteContext, ruleIdx i case v1beta1.HeaderMatchExact: irRoute.HeaderMatches = append(irRoute.HeaderMatches, &ir.StringMatch{ Name: string(headerMatch.Name), - Exact: StringPtr(headerMatch.Value), + Exact: ptr.To(headerMatch.Value), }) case v1beta1.HeaderMatchRegularExpression: irRoute.HeaderMatches = append(irRoute.HeaderMatches, &ir.StringMatch{ Name: string(headerMatch.Name), - SafeRegex: StringPtr(headerMatch.Value), + SafeRegex: ptr.To(headerMatch.Value), }) } } @@ -241,12 +242,12 @@ func (t *Translator) processHTTPRouteRule(httpRoute *HTTPRouteContext, ruleIdx i case v1beta1.QueryParamMatchExact: irRoute.QueryParamMatches = append(irRoute.QueryParamMatches, &ir.StringMatch{ Name: string(queryParamMatch.Name), - Exact: StringPtr(queryParamMatch.Value), + Exact: ptr.To(queryParamMatch.Value), }) case v1beta1.QueryParamMatchRegularExpression: irRoute.QueryParamMatches = append(irRoute.QueryParamMatches, &ir.StringMatch{ Name: string(queryParamMatch.Name), - SafeRegex: StringPtr(queryParamMatch.Value), + SafeRegex: ptr.To(queryParamMatch.Value), }) } } @@ -254,7 +255,7 @@ func (t *Translator) processHTTPRouteRule(httpRoute *HTTPRouteContext, ruleIdx i if match.Method != nil { irRoute.HeaderMatches = append(irRoute.HeaderMatches, &ir.StringMatch{ Name: ":method", - Exact: StringPtr(string(*match.Method)), + Exact: ptr.To(string(*match.Method)), }) } applyHTTPFiltersContextToIRRoute(httpFiltersContext, irRoute) @@ -425,12 +426,12 @@ func (t *Translator) processGRPCRouteRule(grpcRoute *GRPCRouteContext, ruleIdx i case v1beta1.HeaderMatchExact: irRoute.HeaderMatches = append(irRoute.HeaderMatches, &ir.StringMatch{ Name: string(headerMatch.Name), - Exact: StringPtr(headerMatch.Value), + Exact: ptr.To(headerMatch.Value), }) case v1beta1.HeaderMatchRegularExpression: irRoute.HeaderMatches = append(irRoute.HeaderMatches, &ir.StringMatch{ Name: string(headerMatch.Name), - SafeRegex: StringPtr(headerMatch.Value), + SafeRegex: ptr.To(headerMatch.Value), }) } } @@ -455,17 +456,17 @@ func (t *Translator) processGRPCRouteMethodExact(method *v1alpha2.GRPCMethodMatc switch { case method.Service != nil && method.Method != nil: irRoute.PathMatch = &ir.StringMatch{ - Exact: StringPtr(fmt.Sprintf("/%s/%s", *method.Service, *method.Method)), + Exact: ptr.To(fmt.Sprintf("/%s/%s", *method.Service, *method.Method)), } case method.Method != nil: // Use a header match since the PathMatch doesn't support Suffix matching irRoute.HeaderMatches = append(irRoute.HeaderMatches, &ir.StringMatch{ Name: ":path", - Suffix: StringPtr(fmt.Sprintf("/%s", *method.Method)), + Suffix: ptr.To(fmt.Sprintf("/%s", *method.Method)), }) case method.Service != nil: irRoute.PathMatch = &ir.StringMatch{ - Prefix: StringPtr(fmt.Sprintf("/%s", *method.Service)), + Prefix: ptr.To(fmt.Sprintf("/%s", *method.Service)), } } } @@ -474,15 +475,15 @@ func (t *Translator) processGRPCRouteMethodRegularExpression(method *v1alpha2.GR switch { case method.Service != nil && method.Method != nil: irRoute.PathMatch = &ir.StringMatch{ - SafeRegex: StringPtr(fmt.Sprintf("/%s/%s", *method.Service, *method.Method)), + SafeRegex: ptr.To(fmt.Sprintf("/%s/%s", *method.Service, *method.Method)), } case method.Method != nil: irRoute.PathMatch = &ir.StringMatch{ - SafeRegex: StringPtr(fmt.Sprintf("/%s/%s", validServiceName, *method.Method)), + SafeRegex: ptr.To(fmt.Sprintf("/%s/%s", validServiceName, *method.Method)), } case method.Service != nil: irRoute.PathMatch = &ir.StringMatch{ - SafeRegex: StringPtr(fmt.Sprintf("/%s/%s", *method.Service, validMethodName)), + SafeRegex: ptr.To(fmt.Sprintf("/%s/%s", *method.Service, validMethodName)), } } } @@ -1000,7 +1001,6 @@ func (t *Translator) processDestEndpoints(backendRef v1beta1.BackendRef, } endpoints = append(endpoints, ep) } - return endpoints, weight case KindService: service := resources.GetService(backendNamespace, string(backendRef.Name)) var servicePort corev1.ServicePort @@ -1011,40 +1011,56 @@ func (t *Translator) processDestEndpoints(backendRef v1beta1.BackendRef, } } - endpointSlices := resources.GetEndpointSlicesForService(backendNamespace, string(backendRef.Name)) - - for _, endpointSlice := range endpointSlices { - for _, endpoint := range endpointSlice.Endpoints { - for _, endpointPort := range endpointSlice.Ports { - // Check if the endpoint port matches the service port - // and if endpoint is Ready - if *endpointPort.Port == servicePort.Port && - *endpointPort.Protocol == servicePort.Protocol && - *endpoint.Conditions.Ready { - for _, address := range endpoint.Addresses { - var ep *ir.DestinationEndpoint - // Weights are not relevant for TCP and UDP Routes - if routeType == KindTCPRoute || - routeType == KindUDPRoute { - ep = ir.NewDestEndpoint( - address, - uint32(servicePort.TargetPort.IntVal)) - } else { - ep = ir.NewDestEndpointWithWeight( - address, - uint32(servicePort.TargetPort.IntVal), - weight) + // Route to endpoints by default + if !t.EndpointRoutingDisabled { + endpointSlices := resources.GetEndpointSlicesForService(backendNamespace, string(backendRef.Name)) + + for _, endpointSlice := range endpointSlices { + for _, endpoint := range endpointSlice.Endpoints { + for _, endpointPort := range endpointSlice.Ports { + // Check if the endpoint port matches the service port + // and if endpoint is Ready + if *endpointPort.Port == servicePort.Port && + *endpointPort.Protocol == servicePort.Protocol && + *endpoint.Conditions.Ready { + for _, address := range endpoint.Addresses { + var ep *ir.DestinationEndpoint + // Weights are not relevant for TCP and UDP Routes + if routeType == KindTCPRoute || + routeType == KindUDPRoute { + ep = ir.NewDestEndpoint( + address, + uint32(servicePort.TargetPort.IntVal)) + } else { + ep = ir.NewDestEndpointWithWeight( + address, + uint32(servicePort.TargetPort.IntVal), + weight) + } + endpoints = append(endpoints, ep) } - endpoints = append(endpoints, ep) } } } } + } else { + // Fall back to Service CluserIP routing + var ep *ir.DestinationEndpoint + if routeType == KindTCPRoute || + routeType == KindUDPRoute { + ep = ir.NewDestEndpoint( + service.Spec.ClusterIP, + uint32(*backendRef.Port)) + } else { + ep = ir.NewDestEndpointWithWeight( + service.Spec.ClusterIP, + uint32(*backendRef.Port), + weight) + } + endpoints = append(endpoints, ep) } - return endpoints, weight } - - return nil, 0 // shouldnt reach here + return endpoints, weight } // processAllowedListenersForParentRefs finds out if the route attaches to one of our diff --git a/internal/gatewayapi/testdata/gateway-allows-same-namespace-with-allowed-httproute.in.yaml b/internal/gatewayapi/testdata/gateway-allows-same-namespace-with-allowed-httproute.in.yaml index 83dc293c44e5..9b4fd822ece4 100644 --- a/internal/gatewayapi/testdata/gateway-allows-same-namespace-with-allowed-httproute.in.yaml +++ b/internal/gatewayapi/testdata/gateway-allows-same-namespace-with-allowed-httproute.in.yaml @@ -47,9 +47,9 @@ endpointSlices: kind: EndpointSlice metadata: name: endpointslice-service-1 - namespace: envoy-gateway + namespace: envoy-gateway labels: - kubernetes.io/service-name: service-1 + kubernetes.io/service-name: service-1 addressType: IPv4 ports: - name: http @@ -59,4 +59,4 @@ endpointSlices: - addresses: - "7.7.7.7" conditions: - ready: true + ready: true diff --git a/internal/gatewayapi/testdata/httproute-with-backendref-in-other-namespace-allowed-by-refgrant.in.yaml b/internal/gatewayapi/testdata/httproute-with-backendref-in-other-namespace-allowed-by-refgrant.in.yaml index e635fc2fd62f..efe86e4c7f74 100644 --- a/internal/gatewayapi/testdata/httproute-with-backendref-in-other-namespace-allowed-by-refgrant.in.yaml +++ b/internal/gatewayapi/testdata/httproute-with-backendref-in-other-namespace-allowed-by-refgrant.in.yaml @@ -49,9 +49,9 @@ endpointSlices: kind: EndpointSlice metadata: name: endpointslice-service-1 - namespace: backends + namespace: backends labels: - kubernetes.io/service-name: service-1 + kubernetes.io/service-name: service-1 addressType: IPv4 ports: - name: http diff --git a/internal/gatewayapi/testdata/httproutes-with-multiple-matches.in.yaml b/internal/gatewayapi/testdata/httproutes-with-multiple-matches.in.yaml index 6e280eb5ed4a..ed07c485c66d 100644 --- a/internal/gatewayapi/testdata/httproutes-with-multiple-matches.in.yaml +++ b/internal/gatewayapi/testdata/httproutes-with-multiple-matches.in.yaml @@ -145,7 +145,7 @@ services: namespace: envoy-gateway name: service-2 spec: - clusterIP: 2.2.2.2 + clusterIP: 2.2.2.2 ports: - port: 8080 protocol: TCP @@ -155,9 +155,9 @@ endpointSlices: kind: EndpointSlice metadata: name: endpointslice-service-1 - namespace: envoy-gateway + namespace: envoy-gateway labels: - kubernetes.io/service-name: service-1 + kubernetes.io/service-name: service-1 addressType: IPv4 ports: - name: http @@ -172,7 +172,7 @@ endpointSlices: kind: EndpointSlice metadata: name: endpointslice-service-2 - namespace: envoy-gateway + namespace: envoy-gateway labels: kubernetes.io/service-name: service-2 addressType: IPv4 @@ -184,4 +184,4 @@ endpointSlices: - addresses: - "8.8.8.8" conditions: - ready: true + ready: true diff --git a/internal/gatewayapi/testdata/tlsroute-with-backendref-in-other-namespace-allowed-by-refgrant.in.yaml b/internal/gatewayapi/testdata/tlsroute-with-backendref-in-other-namespace-allowed-by-refgrant.in.yaml index 006fbf337039..d9a616bdb32f 100644 --- a/internal/gatewayapi/testdata/tlsroute-with-backendref-in-other-namespace-allowed-by-refgrant.in.yaml +++ b/internal/gatewayapi/testdata/tlsroute-with-backendref-in-other-namespace-allowed-by-refgrant.in.yaml @@ -50,7 +50,7 @@ endpointSlices: name: endpointslice-service-1 namespace: test-service-namespace labels: - kubernetes.io/service-name: service-1 + kubernetes.io/service-name: service-1 addressType: IPv4 ports: - name: http diff --git a/internal/gatewayapi/translator.go b/internal/gatewayapi/translator.go index c12da5eb2704..db47e460a969 100644 --- a/internal/gatewayapi/translator.go +++ b/internal/gatewayapi/translator.go @@ -66,6 +66,11 @@ type Translator struct { // ratelimiting has been configured by the admin. GlobalRateLimitEnabled bool + // EndpointRoutingDisabled can be set to true to use + // the Service Cluser IP for routing to the backend + // instead. + EndpointRoutingDisabled bool + // ExtensionGroupKinds stores the group/kind for all resources // introduced by an Extension so that the translator can // store referenced resources in the IR for later use. diff --git a/internal/gatewayapi/translator_test.go b/internal/gatewayapi/translator_test.go index faadc60ee79d..faf4c69c2546 100644 --- a/internal/gatewayapi/translator_test.go +++ b/internal/gatewayapi/translator_test.go @@ -31,6 +31,7 @@ import ( egv1alpha1 "github.com/envoyproxy/gateway/api/config/v1alpha1" "github.com/envoyproxy/gateway/internal/utils/field" "github.com/envoyproxy/gateway/internal/utils/file" + "github.com/envoyproxy/gateway/internal/utils/ptr" ) var ( @@ -109,24 +110,24 @@ func TestTranslate(t *testing.T) { AddressType: discoveryv1.AddressTypeIPv4, Ports: []discoveryv1.EndpointPort{ { - Name: StringPtr("http"), - Port: Int32Ptr(8080), - Protocol: ProtocolPtr(corev1.ProtocolTCP), + Name: ptr.To("http"), + Port: ptr.To(int32(8080)), + Protocol: ptr.To(corev1.ProtocolTCP), }, { - Name: StringPtr("https"), - Port: Int32Ptr(8443), - Protocol: ProtocolPtr(corev1.ProtocolTCP), + Name: ptr.To("https"), + Port: ptr.To(int32(8443)), + Protocol: ptr.To(corev1.ProtocolTCP), }, { - Name: StringPtr("tcp"), - Port: Int32Ptr(8163), - Protocol: ProtocolPtr(corev1.ProtocolTCP), + Name: ptr.To("tcp"), + Port: ptr.To(int32(8163)), + Protocol: ptr.To(corev1.ProtocolTCP), }, { - Name: StringPtr("udp"), - Port: Int32Ptr(8162), - Protocol: ProtocolPtr(corev1.ProtocolUDP), + Name: ptr.To("udp"), + Port: ptr.To(int32(8162)), + Protocol: ptr.To(corev1.ProtocolUDP), }, }, Endpoints: []discoveryv1.Endpoint{ @@ -135,7 +136,7 @@ func TestTranslate(t *testing.T) { "7.7.7.7", }, Conditions: discoveryv1.EndpointConditions{ - Ready: BoolPtr(true), + Ready: ptr.To(true), }, }, }, @@ -173,9 +174,9 @@ func TestTranslate(t *testing.T) { AddressType: discoveryv1.AddressTypeIPv4, Ports: []discoveryv1.EndpointPort{ { - Name: StringPtr("http"), - Port: Int32Ptr(8080), - Protocol: ProtocolPtr(corev1.ProtocolTCP), + Name: ptr.To("http"), + Port: ptr.To(int32(8080)), + Protocol: ptr.To(corev1.ProtocolTCP), }, }, Endpoints: []discoveryv1.Endpoint{ @@ -184,7 +185,7 @@ func TestTranslate(t *testing.T) { "7.6.5.4", }, Conditions: discoveryv1.EndpointConditions{ - Ready: BoolPtr(true), + Ready: ptr.To(true), }, }, }, @@ -292,24 +293,24 @@ func TestTranslateWithExtensionKinds(t *testing.T) { AddressType: discoveryv1.AddressTypeIPv4, Ports: []discoveryv1.EndpointPort{ { - Name: StringPtr("http"), - Port: Int32Ptr(8080), - Protocol: ProtocolPtr(corev1.ProtocolTCP), + Name: ptr.To("http"), + Port: ptr.To(int32(8080)), + Protocol: ptr.To(corev1.ProtocolTCP), }, { - Name: StringPtr("https"), - Port: Int32Ptr(8443), - Protocol: ProtocolPtr(corev1.ProtocolTCP), + Name: ptr.To("https"), + Port: ptr.To(int32(8443)), + Protocol: ptr.To(corev1.ProtocolTCP), }, { - Name: StringPtr("tcp"), - Port: Int32Ptr(8163), - Protocol: ProtocolPtr(corev1.ProtocolTCP), + Name: ptr.To("tcp"), + Port: ptr.To(int32(8163)), + Protocol: ptr.To(corev1.ProtocolTCP), }, { - Name: StringPtr("udp"), - Port: Int32Ptr(8162), - Protocol: ProtocolPtr(corev1.ProtocolUDP), + Name: ptr.To("udp"), + Port: ptr.To(int32(8162)), + Protocol: ptr.To(corev1.ProtocolUDP), }, }, Endpoints: []discoveryv1.Endpoint{ @@ -318,7 +319,7 @@ func TestTranslateWithExtensionKinds(t *testing.T) { "7.7.7.7", }, Conditions: discoveryv1.EndpointConditions{ - Ready: BoolPtr(true), + Ready: ptr.To(true), }, }, }, @@ -356,9 +357,9 @@ func TestTranslateWithExtensionKinds(t *testing.T) { AddressType: discoveryv1.AddressTypeIPv4, Ports: []discoveryv1.EndpointPort{ { - Name: StringPtr("http"), - Port: Int32Ptr(8080), - Protocol: ProtocolPtr(corev1.ProtocolTCP), + Name: ptr.To("http"), + Port: ptr.To(int32(8080)), + Protocol: ptr.To(corev1.ProtocolTCP), }, }, Endpoints: []discoveryv1.Endpoint{ @@ -367,7 +368,7 @@ func TestTranslateWithExtensionKinds(t *testing.T) { "7.6.5.4", }, Conditions: discoveryv1.EndpointConditions{ - Ready: BoolPtr(true), + Ready: ptr.To(true), }, }, }, diff --git a/internal/provider/kubernetes/routes_test.go b/internal/provider/kubernetes/routes_test.go index 1baf56acd819..efe6084f40e9 100644 --- a/internal/provider/kubernetes/routes_test.go +++ b/internal/provider/kubernetes/routes_test.go @@ -27,6 +27,7 @@ import ( "github.com/envoyproxy/gateway/internal/gatewayapi" "github.com/envoyproxy/gateway/internal/logging" "github.com/envoyproxy/gateway/internal/provider/utils" + "github.com/envoyproxy/gateway/internal/utils/ptr" ) func TestProcessHTTPRoutes(t *testing.T) { @@ -90,8 +91,8 @@ func TestProcessHTTPRoutes(t *testing.T) { Matches: []gwapiv1b1.HTTPRouteMatch{ { Path: &gwapiv1b1.HTTPPathMatch{ - Type: gatewayapi.PathMatchTypePtr(gwapiv1b1.PathMatchPathPrefix), - Value: gatewayapi.StringPtr("/"), + Type: ptr.To(gwapiv1b1.PathMatchPathPrefix), + Value: ptr.To("/"), }, }, }, @@ -134,8 +135,8 @@ func TestProcessHTTPRoutes(t *testing.T) { Matches: []gwapiv1b1.HTTPRouteMatch{ { Path: &gwapiv1b1.HTTPPathMatch{ - Type: gatewayapi.PathMatchTypePtr(gwapiv1b1.PathMatchPathPrefix), - Value: gatewayapi.StringPtr("/"), + Type: ptr.To(gwapiv1b1.PathMatchPathPrefix), + Value: ptr.To("/"), }, }, }, @@ -213,8 +214,8 @@ func TestProcessHTTPRoutes(t *testing.T) { Matches: []gwapiv1b1.HTTPRouteMatch{ { Path: &gwapiv1b1.HTTPPathMatch{ - Type: gatewayapi.PathMatchTypePtr(gwapiv1b1.PathMatchPathPrefix), - Value: gatewayapi.StringPtr("/"), + Type: ptr.To(gwapiv1b1.PathMatchPathPrefix), + Value: ptr.To("/"), }, }, }, @@ -264,7 +265,7 @@ func TestProcessHTTPRoutes(t *testing.T) { Headers: []egv1a1.HeaderMatch{ { Name: "x-user-id", - Value: gatewayapi.StringPtr("one"), + Value: ptr.To("one"), }, }, }, @@ -302,8 +303,8 @@ func TestProcessHTTPRoutes(t *testing.T) { Matches: []gwapiv1b1.HTTPRouteMatch{ { Path: &gwapiv1b1.HTTPPathMatch{ - Type: gatewayapi.PathMatchTypePtr(gwapiv1b1.PathMatchPathPrefix), - Value: gatewayapi.StringPtr("/"), + Type: ptr.To(gwapiv1b1.PathMatchPathPrefix), + Value: ptr.To("/"), }, }, }, @@ -378,7 +379,7 @@ func TestProcessHTTPRoutes(t *testing.T) { Headers: []egv1a1.HeaderMatch{ { Name: "x-user-id", - Value: gatewayapi.StringPtr("one"), + Value: ptr.To("one"), }, }, }, @@ -416,8 +417,8 @@ func TestProcessHTTPRoutes(t *testing.T) { Matches: []gwapiv1b1.HTTPRouteMatch{ { Path: &gwapiv1b1.HTTPPathMatch{ - Type: gatewayapi.PathMatchTypePtr(gwapiv1b1.PathMatchPathPrefix), - Value: gatewayapi.StringPtr("/"), + Type: ptr.To(gwapiv1b1.PathMatchPathPrefix), + Value: ptr.To("/"), }, }, }, @@ -612,7 +613,7 @@ func TestProcessGRPCRoutes(t *testing.T) { Matches: []gwapiv1a2.GRPCRouteMatch{ { Method: &gwapiv1a2.GRPCMethodMatch{ - Method: gatewayapi.StringPtr("Ping"), + Method: ptr.To("Ping"), }, }, }, @@ -655,7 +656,7 @@ func TestProcessGRPCRoutes(t *testing.T) { Matches: []gwapiv1a2.GRPCRouteMatch{ { Method: &gwapiv1a2.GRPCMethodMatch{ - Method: gatewayapi.StringPtr("Ping"), + Method: ptr.To("Ping"), }, }, }, @@ -733,7 +734,7 @@ func TestProcessGRPCRoutes(t *testing.T) { Matches: []gwapiv1a2.GRPCRouteMatch{ { Method: &gwapiv1a2.GRPCMethodMatch{ - Method: gatewayapi.StringPtr("Ping"), + Method: ptr.To("Ping"), }, }, }, @@ -783,7 +784,7 @@ func TestProcessGRPCRoutes(t *testing.T) { Headers: []egv1a1.HeaderMatch{ { Name: "x-user-id", - Value: gatewayapi.StringPtr("one"), + Value: ptr.To("one"), }, }, }, diff --git a/internal/provider/kubernetes/test/utils.go b/internal/provider/kubernetes/test/utils.go index af83b9e3c3b5..d5d65f48b7a1 100644 --- a/internal/provider/kubernetes/test/utils.go +++ b/internal/provider/kubernetes/test/utils.go @@ -16,7 +16,7 @@ import ( egcfgv1a1 "github.com/envoyproxy/gateway/api/config/v1alpha1" egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" - "github.com/envoyproxy/gateway/internal/gatewayapi" + "github.com/envoyproxy/gateway/internal/utils/ptr" ) type ObjectKindNamespacedName struct { @@ -71,7 +71,7 @@ func GetGateway(nsname types.NamespacedName, gwclass string) *gwapiv1b1.Gateway func GetSecureGateway(nsname types.NamespacedName, gwclass string, secretKindNSName ObjectKindNamespacedName) *gwapiv1b1.Gateway { secureGateway := GetGateway(nsname, gwclass) secureGateway.Spec.Listeners[0].TLS = &gwapiv1b1.GatewayTLSConfig{ - Mode: gatewayapi.TLSModeTypePtr(gwapiv1b1.TLSModeTerminate), + Mode: ptr.To(gwapiv1b1.TLSModeTerminate), CertificateRefs: []gwapiv1b1.SecretObjectReference{{ Kind: (*gwapiv1b1.Kind)(&secretKindNSName.Kind), Namespace: (*gwapiv1b1.Namespace)(&secretKindNSName.Namespace), @@ -374,7 +374,7 @@ func GetRateLimitGlobalRule(val string) egv1a1.RateLimitRule { Headers: []egv1a1.HeaderMatch{ { Name: "x-user-id", - Value: gatewayapi.StringPtr(val), + Value: ptr.To(val), }, }, },