From 513357e5f93fcbe378db7a92af637375b89d1d75 Mon Sep 17 00:00:00 2001 From: Roberto Jimenez Sanchez Date: Tue, 2 Dec 2025 19:36:43 +0100 Subject: [PATCH] fix(provisioning): clarify that versionClients map is shared via closure - The versionClients map is captured in the shim closure - When the shim is reused, the same map is shared across all dashboard conversion calls - This ensures client caching works correctly when exporting multiple dashboards - Add clarifying comments to document the sharing behavior --- pkg/registry/apis/provisioning/jobs/export/resources.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/registry/apis/provisioning/jobs/export/resources.go b/pkg/registry/apis/provisioning/jobs/export/resources.go index 32508d4b488..1a186e5ec46 100644 --- a/pkg/registry/apis/provisioning/jobs/export/resources.go +++ b/pkg/registry/apis/provisioning/jobs/export/resources.go @@ -138,9 +138,8 @@ func ExportSpecificResources(ctx context.Context, options provisioning.ExportJob } // Create a shared dashboard conversion shim and cache for all dashboard resources - // The versionClients map will be shared across all dashboard conversion calls + // The versionClients map is captured in the shim closure and shared across all calls var dashboardShim conversionShim - var versionClients map[string]dynamic.ResourceInterface for _, resourceRef := range options.Resources { result := jobs.JobResourceResult{ @@ -235,9 +234,10 @@ func ExportSpecificResources(ctx context.Context, options provisioning.ExportJob // Handle dashboard version conversion using the shared shim logic if gvr.GroupResource() == resources.DashboardResource.GroupResource() { // Create or reuse the dashboard shim (shared across all dashboard resources) - // The versionClients map is shared across all calls to preserve client caching + // The versionClients map is captured in the shim closure and shared across all calls + // This ensures client caching works correctly when exporting multiple dashboards if dashboardShim == nil { - dashboardShim, versionClients = createDashboardConversionShim(ctx, clients, gvr) + dashboardShim, _ = createDashboardConversionShim(ctx, clients, gvr) } item, err = dashboardShim(ctx, item)