mirror of
https://github.com/grafana/grafana.git
synced 2025-08-02 08:32:10 +08:00
QueryService: Add feature toggles to better support testing (#86493)
This commit is contained in:
@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user