From 9e04dd6a3cca9c7ded649458d7c620891df66559 Mon Sep 17 00:00:00 2001 From: Romain Date: Fri, 7 Nov 2025 15:56:04 +0100 Subject: [PATCH] Make the aggregator compute provider namespace for router's parentRefs Co-authored-by: Kevin Pollet --- integration/fixtures/routing/multi_layer_auth.toml | 4 ++-- pkg/server/aggregator.go | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/integration/fixtures/routing/multi_layer_auth.toml b/integration/fixtures/routing/multi_layer_auth.toml index 4de17abe6..59d91c90f 100644 --- a/integration/fixtures/routing/multi_layer_auth.toml +++ b/integration/fixtures/routing/multi_layer_auth.toml @@ -42,10 +42,10 @@ [http.routers.admin-router] rule = "Header(`X-User-Role`, `admin`)" service = "admin-service" - parentRefs = ["parent-router@file"] + parentRefs = ["parent-router"] # Child router for developer role [http.routers.developer-router] rule = "Header(`X-User-Role`, `developer`)" service = "developer-service" - parentRefs = ["parent-router@file"] \ No newline at end of file + parentRefs = ["parent-router"] diff --git a/pkg/server/aggregator.go b/pkg/server/aggregator.go index 94006244b..49f311a84 100644 --- a/pkg/server/aggregator.go +++ b/pkg/server/aggregator.go @@ -65,6 +65,16 @@ func mergeConfiguration(configurations dynamic.Configurations, defaultEntryPoint Msg("Router's `ruleSyntax` option is deprecated, please remove any usage of this option.") } + var qualifiedParentRefs []string + for _, parentRef := range router.ParentRefs { + if parts := strings.Split(parentRef, "@"); len(parts) == 1 { + parentRef = provider.MakeQualifiedName(pvd, parentRef) + } + + qualifiedParentRefs = append(qualifiedParentRefs, parentRef) + } + router.ParentRefs = qualifiedParentRefs + conf.HTTP.Routers[provider.MakeQualifiedName(pvd, routerName)] = router } for middlewareName, middleware := range configuration.HTTP.Middlewares {