QueryService: Add feature toggles to better support testing (#86493)

This commit is contained in:
Ryan McKinley
2024-04-19 12:26:21 +03:00
committed by GitHub
parent 8a5c0cfdc0
commit 5a8384a245
14 changed files with 191 additions and 42 deletions

View File

@ -9,7 +9,6 @@ import (
"k8s.io/apiserver/pkg/registry/rest"
common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1"
example "github.com/grafana/grafana/pkg/apis/example/v0alpha1"
query "github.com/grafana/grafana/pkg/apis/query/v0alpha1"
)
@ -24,6 +23,9 @@ type pluginsStorage struct {
resourceInfo *common.ResourceInfo
tableConverter rest.TableConvertor
registry query.DataSourceApiServerRegistry
// Always return an empty list regardless what we think exists
returnEmptyList bool
}
func newPluginsStorage(reg query.DataSourceApiServerRegistry) *pluginsStorage {
@ -46,7 +48,7 @@ func (s *pluginsStorage) NamespaceScoped() bool {
}
func (s *pluginsStorage) GetSingularName() string {
return example.DummyResourceInfo.GetSingularName()
return s.resourceInfo.GetSingularName()
}
func (s *pluginsStorage) NewList() runtime.Object {
@ -58,5 +60,8 @@ func (s *pluginsStorage) ConvertToTable(ctx context.Context, object runtime.Obje
}
func (s *pluginsStorage) List(ctx context.Context, options *internalversion.ListOptions) (runtime.Object, error) {
if s.returnEmptyList {
return s.NewList(), nil
}
return s.registry.GetDatasourceApiServers(ctx)
}