mirror of
https://github.com/grafana/grafana.git
synced 2025-09-28 14:54:15 +08: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:
@ -599,6 +599,7 @@ export interface DataSourceInstanceSettings<T extends DataSourceJsonData = DataS
|
|||||||
password?: string; // when access is direct, for some legacy datasources
|
password?: string; // when access is direct, for some legacy datasources
|
||||||
database?: string;
|
database?: string;
|
||||||
isDefault?: boolean;
|
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.
|
* 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,
|
"name": ds.Name,
|
||||||
"url": url,
|
"url": url,
|
||||||
"isDefault": ds.IsDefault,
|
"isDefault": ds.IsDefault,
|
||||||
|
"access": ds.Access,
|
||||||
}
|
}
|
||||||
|
|
||||||
meta, exists := enabledPlugins.DataSources[ds.Type]
|
meta, exists := enabledPlugins.DataSources[ds.Type]
|
||||||
|
@ -19,6 +19,7 @@ describe('InputDatasource', () => {
|
|||||||
type: 'x',
|
type: 'x',
|
||||||
name: 'xxx',
|
name: 'xxx',
|
||||||
meta: {} as PluginMeta,
|
meta: {} as PluginMeta,
|
||||||
|
access: 'proxy',
|
||||||
jsonData: {
|
jsonData: {
|
||||||
data,
|
data,
|
||||||
},
|
},
|
||||||
|
@ -38,6 +38,7 @@ const mockRuleSourceByName = () => {
|
|||||||
id: 1,
|
id: 1,
|
||||||
meta: {} as PluginMeta,
|
meta: {} as PluginMeta,
|
||||||
jsonData: {} as DataSourceJsonData,
|
jsonData: {} as DataSourceJsonData,
|
||||||
|
access: 'proxy',
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -95,6 +96,7 @@ const mockedRules: CombinedRule[] = [
|
|||||||
id: 1,
|
id: 1,
|
||||||
meta: {} as PluginMeta,
|
meta: {} as PluginMeta,
|
||||||
jsonData: {} as DataSourceJsonData,
|
jsonData: {} as DataSourceJsonData,
|
||||||
|
access: 'proxy',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -123,6 +125,7 @@ const mockedRules: CombinedRule[] = [
|
|||||||
id: 1,
|
id: 1,
|
||||||
meta: {} as PluginMeta,
|
meta: {} as PluginMeta,
|
||||||
jsonData: {} as DataSourceJsonData,
|
jsonData: {} as DataSourceJsonData,
|
||||||
|
access: 'proxy',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -122,6 +122,7 @@ const mockCloudRule = {
|
|||||||
id: 1,
|
id: 1,
|
||||||
meta: {} as PluginMeta,
|
meta: {} as PluginMeta,
|
||||||
jsonData: {} as DataSourceJsonData,
|
jsonData: {} as DataSourceJsonData,
|
||||||
|
access: 'proxy',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -25,6 +25,7 @@ export const mockDataSource = (
|
|||||||
uid: `mock-ds-${nextDataSourceId}`,
|
uid: `mock-ds-${nextDataSourceId}`,
|
||||||
type: 'prometheus',
|
type: 'prometheus',
|
||||||
name: `Prometheus-${id}`,
|
name: `Prometheus-${id}`,
|
||||||
|
access: 'proxy',
|
||||||
jsonData: {},
|
jsonData: {},
|
||||||
meta: ({
|
meta: ({
|
||||||
info: {
|
info: {
|
||||||
|
@ -50,6 +50,7 @@ describe('alertRuleToQueries', () => {
|
|||||||
type: 'prometheus',
|
type: 'prometheus',
|
||||||
uid: 'asdf23',
|
uid: 'asdf23',
|
||||||
id: 1,
|
id: 1,
|
||||||
|
access: 'proxy',
|
||||||
meta: {} as PluginMeta,
|
meta: {} as PluginMeta,
|
||||||
jsonData: {} as DataSourceJsonData,
|
jsonData: {} as DataSourceJsonData,
|
||||||
},
|
},
|
||||||
|
@ -377,6 +377,7 @@ function makeDatasourceSetup({ name = 'loki', id = 1 }: { name?: string; id?: nu
|
|||||||
type: 'logs',
|
type: 'logs',
|
||||||
name,
|
name,
|
||||||
meta,
|
meta,
|
||||||
|
access: 'proxy',
|
||||||
jsonData: {},
|
jsonData: {},
|
||||||
},
|
},
|
||||||
api: {
|
api: {
|
||||||
|
@ -34,6 +34,7 @@ export const instanceSettings: DataSourceInstanceSettings = {
|
|||||||
uid: ExpressionDatasourceUID,
|
uid: ExpressionDatasourceUID,
|
||||||
name: ExpressionDatasourceID,
|
name: ExpressionDatasourceID,
|
||||||
type: 'grafana-expression',
|
type: 'grafana-expression',
|
||||||
|
access: 'proxy',
|
||||||
meta: {
|
meta: {
|
||||||
baseUrl: '',
|
baseUrl: '',
|
||||||
module: '',
|
module: '',
|
||||||
|
@ -7,6 +7,7 @@ export function getDataSourceInstanceSetting(name: string, meta: DataSourcePlugi
|
|||||||
type: '',
|
type: '',
|
||||||
name,
|
name,
|
||||||
meta,
|
meta,
|
||||||
|
access: 'proxy',
|
||||||
jsonData: ({} as unknown) as DataSourceJsonData,
|
jsonData: ({} as unknown) as DataSourceJsonData,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -100,6 +100,7 @@ function getTestContext({
|
|||||||
name: 'test-elastic',
|
name: 'test-elastic',
|
||||||
type: 'type',
|
type: 'type',
|
||||||
uid: 'uid',
|
uid: 'uid',
|
||||||
|
access: 'proxy',
|
||||||
url: ELASTICSEARCH_MOCK_URL,
|
url: ELASTICSEARCH_MOCK_URL,
|
||||||
database,
|
database,
|
||||||
jsonData,
|
jsonData,
|
||||||
|
@ -6,6 +6,7 @@ export const createMockInstanceSetttings = (): AzureDataSourceInstanceSettings =
|
|||||||
id: 1,
|
id: 1,
|
||||||
uid: 'abc',
|
uid: 'abc',
|
||||||
type: 'azuremonitor',
|
type: 'azuremonitor',
|
||||||
|
access: 'proxy',
|
||||||
meta: {} as DataSourcePluginMeta,
|
meta: {} as DataSourcePluginMeta,
|
||||||
name: 'azure',
|
name: 'azure',
|
||||||
|
|
||||||
|
@ -215,6 +215,7 @@ const defaultSettings: DataSourceInstanceSettings = {
|
|||||||
type: 'tracing',
|
type: 'tracing',
|
||||||
name: 'jaeger',
|
name: 'jaeger',
|
||||||
url: 'http://grafana.com',
|
url: 'http://grafana.com',
|
||||||
|
access: 'proxy',
|
||||||
meta: {
|
meta: {
|
||||||
id: 'jaeger',
|
id: 'jaeger',
|
||||||
name: 'jaeger',
|
name: 'jaeger',
|
||||||
|
@ -114,6 +114,7 @@ const defaultSettings: DataSourceInstanceSettings = {
|
|||||||
uid: '0',
|
uid: '0',
|
||||||
type: 'tracing',
|
type: 'tracing',
|
||||||
name: 'jaeger',
|
name: 'jaeger',
|
||||||
|
access: 'proxy',
|
||||||
meta: {
|
meta: {
|
||||||
id: 'jaeger',
|
id: 'jaeger',
|
||||||
name: 'jaeger',
|
name: 'jaeger',
|
||||||
|
@ -67,4 +67,5 @@ const defaultSettings: DataSourceInstanceSettings = {
|
|||||||
name: 'zipkin',
|
name: 'zipkin',
|
||||||
meta: {} as any,
|
meta: {} as any,
|
||||||
jsonData: {},
|
jsonData: {},
|
||||||
|
access: 'proxy',
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user