Skip to content

Commit

Permalink
chore: set mergedGateways in translator runner (envoyproxy#2971)
Browse files Browse the repository at this point in the history
* chore: set mergedGateways in translator runner

Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com>

* fix tests

Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com>

---------

Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com>
  • Loading branch information
cnvergence authored Mar 20, 2024
1 parent 6fa99be commit 655ee5d
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/gatewayapi/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
1 change: 1 addition & 0 deletions internal/gatewayapi/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions internal/gatewayapi/translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down
2 changes: 2 additions & 0 deletions internal/gatewayapi/translator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func TestTranslate(t *testing.T) {
GlobalRateLimitEnabled: true,
EnvoyPatchPolicyEnabled: envoyPatchPolicyEnabled,
Namespace: "envoy-gateway-system",
MergeGateways: IsMergeGatewaysEnabled(resources),
}

// Add common test fixtures
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 655ee5d

Please sign in to comment.