diff --git a/internal/gatewayapi/helpers.go b/internal/gatewayapi/helpers.go index 6503d4f2f41..252056f2d7d 100644 --- a/internal/gatewayapi/helpers.go +++ b/internal/gatewayapi/helpers.go @@ -399,7 +399,7 @@ func irTLSCACertName(namespace, name string) string { return fmt.Sprintf("%s/%s/%s", namespace, name, caCertKey) } -func isMergeGatewaysEnabled(resources *Resources) bool { +func IsMergeGatewaysEnabled(resources *Resources) bool { return resources.EnvoyProxy != nil && resources.EnvoyProxy.Spec.MergeGateways != nil && *resources.EnvoyProxy.Spec.MergeGateways } diff --git a/internal/gatewayapi/runner/runner.go b/internal/gatewayapi/runner/runner.go index 4cb3d69d15f..abc1016aa83 100644 --- a/internal/gatewayapi/runner/runner.go +++ b/internal/gatewayapi/runner/runner.go @@ -84,6 +84,7 @@ func (r *Runner) subscribeAndTranslate(ctx context.Context) { GlobalRateLimitEnabled: r.EnvoyGateway.RateLimit != nil, EnvoyPatchPolicyEnabled: r.EnvoyGateway.ExtensionAPIs != nil && r.EnvoyGateway.ExtensionAPIs.EnableEnvoyPatchPolicy, Namespace: r.Namespace, + MergeGateways: gatewayapi.IsMergeGatewaysEnabled(resources), } // If an extension is loaded, pass its supported groups/kinds to the translator diff --git a/internal/gatewayapi/translator.go b/internal/gatewayapi/translator.go index 83a819fbd23..12a5cf81743 100644 --- a/internal/gatewayapi/translator.go +++ b/internal/gatewayapi/translator.go @@ -252,8 +252,7 @@ func (t *Translator) InitIRs(gateways []*GatewayContext, resources *Resources) ( annotations := infrastructureAnnotations(gateway.Gateway) gwInfraIR.Proxy.GetProxyMetadata().Annotations = annotations - if isMergeGatewaysEnabled(resources) { - t.MergeGateways = true + if t.MergeGateways { irKey = string(t.GatewayClassName) maps.Copy(labels, GatewayClassOwnerLabel(string(t.GatewayClassName))) diff --git a/internal/gatewayapi/translator_test.go b/internal/gatewayapi/translator_test.go index ffadaf8bcbf..a22b69b534f 100644 --- a/internal/gatewayapi/translator_test.go +++ b/internal/gatewayapi/translator_test.go @@ -78,6 +78,7 @@ func TestTranslate(t *testing.T) { GlobalRateLimitEnabled: true, EnvoyPatchPolicyEnabled: envoyPatchPolicyEnabled, Namespace: "envoy-gateway-system", + MergeGateways: IsMergeGatewaysEnabled(resources), } // Add common test fixtures @@ -270,6 +271,7 @@ func TestTranslateWithExtensionKinds(t *testing.T) { GatewayClassName: "envoy-gateway-class", GlobalRateLimitEnabled: true, ExtensionGroupKinds: []schema.GroupKind{{Group: "foo.example.io", Kind: "Foo"}}, + MergeGateways: IsMergeGatewaysEnabled(resources), } // Add common test fixtures