mirror of https://github.com/grafana/grafana
RuntimeDataSource: Support in core for runtime registered data sources (#93956)
* RuntimeDataSource: Support in core for runtime registered data sources * Added tests for runtime datasource. * added another test to make sure runtime ds isn't included in datasource list. * changed so we not are expecting the settings to be returned by name. * Fixed betterer error. * fixed type issues. * updated comment according to feedback. * will prevent runtime ds registration from overwriting regular ds. --------- Co-authored-by: Marcus Andersson <marcus.andersson@grafana.com>pull/98816/head
parent
d4de5022eb
commit
7639934818
@ -0,0 +1,54 @@ |
||||
import { |
||||
DataQuery, |
||||
DataSourceApi, |
||||
DataSourceInstanceSettings, |
||||
PluginType, |
||||
TestDataSourceResponse, |
||||
} from '@grafana/data'; |
||||
|
||||
export abstract class RuntimeDataSource<TQuery extends DataQuery = DataQuery> extends DataSourceApi<TQuery> { |
||||
public instanceSettings: DataSourceInstanceSettings; |
||||
|
||||
public constructor(pluginId: string, uid: string) { |
||||
const instanceSettings: DataSourceInstanceSettings = { |
||||
name: 'RuntimeDataSource-' + pluginId, |
||||
uid: uid, |
||||
type: pluginId, |
||||
id: 1, |
||||
readOnly: true, |
||||
jsonData: {}, |
||||
access: 'direct', |
||||
meta: { |
||||
id: pluginId, |
||||
name: 'RuntimeDataSource-' + pluginId, |
||||
type: PluginType.datasource, |
||||
info: { |
||||
author: { |
||||
name: '', |
||||
}, |
||||
description: '', |
||||
links: [], |
||||
logos: { |
||||
large: '', |
||||
small: '', |
||||
}, |
||||
screenshots: [], |
||||
updated: '', |
||||
version: '', |
||||
}, |
||||
module: '', |
||||
baseUrl: '', |
||||
}, |
||||
}; |
||||
|
||||
super(instanceSettings); |
||||
this.instanceSettings = instanceSettings; |
||||
} |
||||
|
||||
public testDatasource(): Promise<TestDataSourceResponse> { |
||||
return Promise.resolve({ |
||||
status: 'success', |
||||
message: '', |
||||
}); |
||||
} |
||||
} |
Loading…
Reference in new issue