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
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user