K8s: Folders: Fix legacy search (#100393)

This commit is contained in:
Stephanie Hingtgen
2025-02-11 13:14:25 -06:00
committed by GitHub
parent ab74852fc9
commit df84d928e2
25 changed files with 415 additions and 660 deletions
@@ -1,20 +1,22 @@
package resource
import (
"context"
"github.com/grafana/grafana/pkg/apiserver/rest"
"github.com/grafana/grafana/pkg/setting"
)
func NewSearchClient(cfg *setting.Cfg, unifiedStorageConfigKey string, unifiedClient ResourceIndexClient, legacyClient ResourceIndexClient) ResourceIndexClient {
func NewSearchClient(cfg *setting.Cfg, unifiedStorageConfigKey string, unifiedClient func(context.Context) ResourceClient, legacyClient ResourceIndexClient) func(context.Context) ResourceIndexClient {
config, ok := cfg.UnifiedStorage[unifiedStorageConfigKey]
if !ok {
return legacyClient
return func(ctx context.Context) ResourceIndexClient { return legacyClient }
}
switch config.DualWriterMode {
case rest.Mode0, rest.Mode1, rest.Mode2:
return legacyClient
return func(ctx context.Context) ResourceIndexClient { return legacyClient }
default:
return unifiedClient
return func(ctx context.Context) ResourceIndexClient { return unifiedClient(ctx) }
}
}