This commit is contained in:
Ryan McKinley
2025-08-26 12:21:54 +03:00
parent a4adcf8896
commit e96dd1b12a
4 changed files with 14 additions and 13 deletions
+1 -1
View File
@@ -138,7 +138,7 @@ func (b *DataSourceAPIBuilder) PostProcessOpenAPI(oas *spec3.OpenAPI) (*spec3.Op
op.Tags = append(op.Tags, "Route") // Custom resource?
}
}
oas.Paths.Paths[prefix+k] = v // TODO add namespace + name parameters
oas.Paths.Paths[prefix+k] = v
}
}
return oas, err
@@ -4,7 +4,6 @@ import (
"context"
"fmt"
"github.com/grafana/authlib/types"
"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana/pkg/apimachinery/identity"
datasourceV0 "github.com/grafana/grafana/pkg/apis/datasource/v0alpha1"
@@ -12,6 +11,7 @@ import (
"github.com/grafana/grafana/pkg/services/apiserver/endpoints/request"
"github.com/grafana/grafana/pkg/services/datasources"
"github.com/grafana/grafana/pkg/services/pluginsintegration/plugincontext"
"github.com/grafana/grafana/pkg/setting"
)
// This provides access to settings saved in the database.
@@ -50,13 +50,15 @@ type PluginContextWrapper interface {
func ProvideDefaultPluginConfigs(
dsService datasources.DataSourceService,
dsCache datasources.CacheService,
contextProvider *plugincontext.Provider) ScopedPluginDatasourceProvider {
contextProvider *plugincontext.Provider,
cfg *setting.Cfg,
) ScopedPluginDatasourceProvider {
return &cachingDatasourceProvider{
dsService: dsService,
dsCache: dsCache,
contextProvider: contextProvider,
converter: &converter{
mapper: types.OrgNamespaceFormatter, // TODO -- from cfg!!!
mapper: request.GetNamespaceMapper(cfg),
},
}
}
+6 -7
View File
@@ -22,7 +22,6 @@ import (
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/plugins"
"github.com/grafana/grafana/pkg/promlib/models"
"github.com/grafana/grafana/pkg/registry/apis/datasource/hardcoded"
"github.com/grafana/grafana/pkg/registry/apis/query/queryschema"
"github.com/grafana/grafana/pkg/services/accesscontrol"
"github.com/grafana/grafana/pkg/services/apiserver/builder"
@@ -42,11 +41,11 @@ type DataSourceAPIBuilder struct {
datasourceResourceInfo utils.ResourceInfo
pluginJSON plugins.JSONData
client PluginClient // will only ever be called with the same pluginid!
client PluginClient // will only ever be called with the same plugin id!
datasources PluginDatasourceProvider
contextProvider PluginContextWrapper
accessControl accesscontrol.AccessControl
schemaProvider func() (*datasourceV0.DataSourceOpenAPIExtension, error) // TODO? include query types
schemaProvider func() (*datasourceV0.DataSourceOpenAPIExtension, error)
queryTypes *queryV0.QueryTypeDefinitionList
log log.Logger
}
@@ -98,10 +97,10 @@ func RegisterAPIService(
return nil, err
}
// HARDCODE schema access
if ds.ID == "grafana-testdata-datasource" {
builder.schemaProvider = hardcoded.TestdataOpenAPIExtension
}
// TODO: load the schema provider from a static manifest
// if ds.ID == "grafana-testdata-datasource" {
// builder.schemaProvider = hardcoded.TestdataOpenAPIExtension
// }
apiRegistrar.RegisterAPI(builder)
}
+2 -2
View File
@@ -730,7 +730,7 @@ func Initialize(ctx context.Context, cfg *setting.Cfg, opts Options, apiOpts api
if err != nil {
return nil, err
}
scopedPluginDatasourceProvider := datasource.ProvideDefaultPluginConfigs(service15, cacheServiceImpl, plugincontextProvider)
scopedPluginDatasourceProvider := datasource.ProvideDefaultPluginConfigs(service15, cacheServiceImpl, plugincontextProvider, cfg)
v := builder.ProvideDefaultBuildHandlerChainFuncFromBuilders()
aggregatorRunner := aggregatorrunner.ProvideNoopAggregatorConfigurator()
playlistAppInstaller, err := playlist.RegisterAppInstaller(playlistService, cfg, featureToggles)
@@ -1306,7 +1306,7 @@ func InitializeForTest(ctx context.Context, t sqlutil.ITestDB, testingT interfac
if err != nil {
return nil, err
}
scopedPluginDatasourceProvider := datasource.ProvideDefaultPluginConfigs(service15, cacheServiceImpl, plugincontextProvider)
scopedPluginDatasourceProvider := datasource.ProvideDefaultPluginConfigs(service15, cacheServiceImpl, plugincontextProvider, cfg)
v := builder.ProvideDefaultBuildHandlerChainFuncFromBuilders()
aggregatorRunner := aggregatorrunner.ProvideNoopAggregatorConfigurator()
playlistAppInstaller, err := playlist.RegisterAppInstaller(playlistService, cfg, featureToggles)