datasource

package
v11.1.4-modfix Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2024 License: AGPL-3.0 Imports: 45 Imported by: 0

README

Experimental!

This is exploring how to expose any datasource as a k8s aggregated API server.

Unlike the other services, this will register datasources as:

{plugin}.datasource.grafana.app

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataSourceAPIBuilder

type DataSourceAPIBuilder struct {
	// contains filtered or unexported fields
}

DataSourceAPIBuilder is used just so wire has something unique to return

func NewDataSourceAPIBuilder

func NewDataSourceAPIBuilder(
	plugin plugins.JSONData,
	client PluginClient,
	datasources PluginDatasourceProvider,
	contextProvider PluginContextWrapper,
	accessControl accesscontrol.AccessControl,
	loadQueryTypes bool,
) (*DataSourceAPIBuilder, error)

func RegisterAPIService

func RegisterAPIService(
	features featuremgmt.FeatureToggles,
	apiRegistrar builder.APIRegistrar,
	pluginClient plugins.Client,
	datasources ScopedPluginDatasourceProvider,
	contextProvider PluginContextWrapper,
	pluginStore pluginstore.Store,
	accessControl accesscontrol.AccessControl,
) (*DataSourceAPIBuilder, error)

func (*DataSourceAPIBuilder) GetAPIRoutes

func (b *DataSourceAPIBuilder) GetAPIRoutes() *builder.APIRoutes

Register additional routes with the server

func (*DataSourceAPIBuilder) GetAuthorizer

func (b *DataSourceAPIBuilder) GetAuthorizer() authorizer.Authorizer

func (*DataSourceAPIBuilder) GetDesiredDualWriterMode

func (b *DataSourceAPIBuilder) GetDesiredDualWriterMode(dualWrite bool, modeMap map[string]grafanarest.DualWriterMode) grafanarest.DualWriterMode

func (*DataSourceAPIBuilder) GetGroupVersion

func (b *DataSourceAPIBuilder) GetGroupVersion() schema.GroupVersion

func (*DataSourceAPIBuilder) GetOpenAPIDefinitions

func (b *DataSourceAPIBuilder) GetOpenAPIDefinitions() openapi.GetOpenAPIDefinitions

func (*DataSourceAPIBuilder) InstallSchema

func (b *DataSourceAPIBuilder) InstallSchema(scheme *runtime.Scheme) error

func (*DataSourceAPIBuilder) PostProcessOpenAPI

func (b *DataSourceAPIBuilder) PostProcessOpenAPI(oas *spec3.OpenAPI) (*spec3.OpenAPI, error)

type DefaultQuerier

type DefaultQuerier struct {
	// contains filtered or unexported fields
}

func NewDefaultQuerier

func NewDefaultQuerier(
	connectionResourceInfo common.ResourceInfo,
	pluginJSON plugins.JSONData,
	pluginClient plugins.Client,
	dsService datasources.DataSourceService,
	dsCache datasources.CacheService,
) *DefaultQuerier

func (*DefaultQuerier) Datasource

func (*DefaultQuerier) Datasources

func (*DefaultQuerier) Health

func (*DefaultQuerier) Query

func (*DefaultQuerier) Resource

type DefaultQuerierProvider

type DefaultQuerierProvider struct {
	// contains filtered or unexported fields
}

func NewQuerierProvider

func NewQuerierProvider(factory QuerierFactoryFunc) *DefaultQuerierProvider

func ProvideDefaultQuerierProvider

func ProvideDefaultQuerierProvider(pluginClient plugins.Client, dsService datasources.DataSourceService,
	dsCache datasources.CacheService) *DefaultQuerierProvider

func (*DefaultQuerierProvider) Querier

type PluginClient

PluginClient is a subset of the plugins.Client interface with only the functions supported (yet) by the datasource API

type PluginContextWrapper

type PluginContextWrapper interface {
	PluginContextForDataSource(ctx context.Context, datasourceSettings *backend.DataSourceInstanceSettings) (backend.PluginContext, error)
}

PluginContext requires adding system settings (feature flags, etc) to the datasource config

type PluginDatasourceProvider

type PluginDatasourceProvider interface {
	// Get gets a specific datasource (that the user in context can see)
	Get(ctx context.Context, uid string) (*v0alpha1.DataSourceConnection, error)

	// List lists all data sources the user in context can see
	List(ctx context.Context) (*v0alpha1.DataSourceConnectionList, error)

	// Return settings (decrypted!) for a specific plugin
	// This will require "query" permission for the user in context
	GetInstanceSettings(ctx context.Context, uid string) (*backend.DataSourceInstanceSettings, error)
}

This provides access to settings saved in the database. Authorization checks will happen within each function, and the user in ctx will limit which namespace/tenant/org we are talking to

type Querier

type Querier interface {
	// Query runs the query on behalf of the user in context.
	Query(ctx context.Context, query *backend.QueryDataRequest) (*backend.QueryDataResponse, error)
	// Health checks the health of the plugin.
	Health(ctx context.Context, req *backend.CheckHealthRequest) (*backend.CheckHealthResult, error)
	// Resource gets a resource plugin.
	Resource(ctx context.Context, req *backend.CallResourceRequest, sender backend.CallResourceResponseSender) error
	// Datasource gets all data source plugins (with elevated permissions).
	Datasource(ctx context.Context, name string) (*v0alpha1.DataSourceConnection, error)
	// Datasources lists all data sources (with elevated permissions).
	Datasources(ctx context.Context) (*v0alpha1.DataSourceConnectionList, error)
}

Querier is the interface that wraps the Query method.

type QuerierFactoryFunc

type QuerierFactoryFunc func(ctx context.Context, ri common.ResourceInfo, pj plugins.JSONData) (Querier, error)

type QuerierProvider

type QuerierProvider interface {
	Querier(ctx context.Context, ri common.ResourceInfo, pj plugins.JSONData) (Querier, error)
}

type ScopedPluginDatasourceProvider

type ScopedPluginDatasourceProvider interface {
	GetDatasourceProvider(pluginJson plugins.JSONData) PluginDatasourceProvider
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL