mirror of
https://github.com/grafana/grafana.git
synced 2025-01-24 15:27:01 -06:00
Datasource: Pass access type to data source instance settings (#37577)
* Pass Access info to datasourceInstance * Update packages/grafana-data/src/types/datasource.ts Co-authored-by: Giordano Ricci <me@giordanoricci.com> * Type access as direct | proxy * Fix tests where mocking datasourceInstance, include access * Pass access to data source instance mocks * Update comment * Pass access to data source instance mocks Co-authored-by: Giordano Ricci <me@giordanoricci.com>
This commit is contained in:
parent
8e7c4af366
commit
ba76877d28
@ -599,6 +599,7 @@ export interface DataSourceInstanceSettings<T extends DataSourceJsonData = DataS
|
||||
password?: string; // when access is direct, for some legacy datasources
|
||||
database?: string;
|
||||
isDefault?: boolean;
|
||||
access: 'direct' | 'proxy'; // Currently we support 2 options - direct (browser) and proxy (server)
|
||||
|
||||
/**
|
||||
* This is the full Authorization header if basic auth is enabled.
|
||||
|
@ -58,6 +58,7 @@ func (hs *HTTPServer) getFSDataSources(c *models.ReqContext, enabledPlugins *plu
|
||||
"name": ds.Name,
|
||||
"url": url,
|
||||
"isDefault": ds.IsDefault,
|
||||
"access": ds.Access,
|
||||
}
|
||||
|
||||
meta, exists := enabledPlugins.DataSources[ds.Type]
|
||||
|
@ -19,6 +19,7 @@ describe('InputDatasource', () => {
|
||||
type: 'x',
|
||||
name: 'xxx',
|
||||
meta: {} as PluginMeta,
|
||||
access: 'proxy',
|
||||
jsonData: {
|
||||
data,
|
||||
},
|
||||
|
@ -38,6 +38,7 @@ const mockRuleSourceByName = () => {
|
||||
id: 1,
|
||||
meta: {} as PluginMeta,
|
||||
jsonData: {} as DataSourceJsonData,
|
||||
access: 'proxy',
|
||||
});
|
||||
};
|
||||
|
||||
@ -95,6 +96,7 @@ const mockedRules: CombinedRule[] = [
|
||||
id: 1,
|
||||
meta: {} as PluginMeta,
|
||||
jsonData: {} as DataSourceJsonData,
|
||||
access: 'proxy',
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -123,6 +125,7 @@ const mockedRules: CombinedRule[] = [
|
||||
id: 1,
|
||||
meta: {} as PluginMeta,
|
||||
jsonData: {} as DataSourceJsonData,
|
||||
access: 'proxy',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -122,6 +122,7 @@ const mockCloudRule = {
|
||||
id: 1,
|
||||
meta: {} as PluginMeta,
|
||||
jsonData: {} as DataSourceJsonData,
|
||||
access: 'proxy',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
@ -25,6 +25,7 @@ export const mockDataSource = (
|
||||
uid: `mock-ds-${nextDataSourceId}`,
|
||||
type: 'prometheus',
|
||||
name: `Prometheus-${id}`,
|
||||
access: 'proxy',
|
||||
jsonData: {},
|
||||
meta: ({
|
||||
info: {
|
||||
|
@ -50,6 +50,7 @@ describe('alertRuleToQueries', () => {
|
||||
type: 'prometheus',
|
||||
uid: 'asdf23',
|
||||
id: 1,
|
||||
access: 'proxy',
|
||||
meta: {} as PluginMeta,
|
||||
jsonData: {} as DataSourceJsonData,
|
||||
},
|
||||
|
@ -377,6 +377,7 @@ function makeDatasourceSetup({ name = 'loki', id = 1 }: { name?: string; id?: nu
|
||||
type: 'logs',
|
||||
name,
|
||||
meta,
|
||||
access: 'proxy',
|
||||
jsonData: {},
|
||||
},
|
||||
api: {
|
||||
|
@ -34,6 +34,7 @@ export const instanceSettings: DataSourceInstanceSettings = {
|
||||
uid: ExpressionDatasourceUID,
|
||||
name: ExpressionDatasourceID,
|
||||
type: 'grafana-expression',
|
||||
access: 'proxy',
|
||||
meta: {
|
||||
baseUrl: '',
|
||||
module: '',
|
||||
|
@ -7,6 +7,7 @@ export function getDataSourceInstanceSetting(name: string, meta: DataSourcePlugi
|
||||
type: '',
|
||||
name,
|
||||
meta,
|
||||
access: 'proxy',
|
||||
jsonData: ({} as unknown) as DataSourceJsonData,
|
||||
};
|
||||
}
|
||||
|
@ -100,6 +100,7 @@ function getTestContext({
|
||||
name: 'test-elastic',
|
||||
type: 'type',
|
||||
uid: 'uid',
|
||||
access: 'proxy',
|
||||
url: ELASTICSEARCH_MOCK_URL,
|
||||
database,
|
||||
jsonData,
|
||||
|
@ -6,6 +6,7 @@ export const createMockInstanceSetttings = (): AzureDataSourceInstanceSettings =
|
||||
id: 1,
|
||||
uid: 'abc',
|
||||
type: 'azuremonitor',
|
||||
access: 'proxy',
|
||||
meta: {} as DataSourcePluginMeta,
|
||||
name: 'azure',
|
||||
|
||||
|
@ -215,6 +215,7 @@ const defaultSettings: DataSourceInstanceSettings = {
|
||||
type: 'tracing',
|
||||
name: 'jaeger',
|
||||
url: 'http://grafana.com',
|
||||
access: 'proxy',
|
||||
meta: {
|
||||
id: 'jaeger',
|
||||
name: 'jaeger',
|
||||
|
@ -114,6 +114,7 @@ const defaultSettings: DataSourceInstanceSettings = {
|
||||
uid: '0',
|
||||
type: 'tracing',
|
||||
name: 'jaeger',
|
||||
access: 'proxy',
|
||||
meta: {
|
||||
id: 'jaeger',
|
||||
name: 'jaeger',
|
||||
|
@ -67,4 +67,5 @@ const defaultSettings: DataSourceInstanceSettings = {
|
||||
name: 'zipkin',
|
||||
meta: {} as any,
|
||||
jsonData: {},
|
||||
access: 'proxy',
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user