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:
Ivana Huckova 2021-08-06 03:24:35 -04:00 committed by GitHub
parent 8e7c4af366
commit ba76877d28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 17 additions and 0 deletions

View File

@ -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.

View File

@ -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]

View File

@ -19,6 +19,7 @@ describe('InputDatasource', () => {
type: 'x',
name: 'xxx',
meta: {} as PluginMeta,
access: 'proxy',
jsonData: {
data,
},

View File

@ -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',
},
},
},

View File

@ -122,6 +122,7 @@ const mockCloudRule = {
id: 1,
meta: {} as PluginMeta,
jsonData: {} as DataSourceJsonData,
access: 'proxy',
},
},
};

View File

@ -25,6 +25,7 @@ export const mockDataSource = (
uid: `mock-ds-${nextDataSourceId}`,
type: 'prometheus',
name: `Prometheus-${id}`,
access: 'proxy',
jsonData: {},
meta: ({
info: {

View File

@ -50,6 +50,7 @@ describe('alertRuleToQueries', () => {
type: 'prometheus',
uid: 'asdf23',
id: 1,
access: 'proxy',
meta: {} as PluginMeta,
jsonData: {} as DataSourceJsonData,
},

View File

@ -377,6 +377,7 @@ function makeDatasourceSetup({ name = 'loki', id = 1 }: { name?: string; id?: nu
type: 'logs',
name,
meta,
access: 'proxy',
jsonData: {},
},
api: {

View File

@ -34,6 +34,7 @@ export const instanceSettings: DataSourceInstanceSettings = {
uid: ExpressionDatasourceUID,
name: ExpressionDatasourceID,
type: 'grafana-expression',
access: 'proxy',
meta: {
baseUrl: '',
module: '',

View File

@ -7,6 +7,7 @@ export function getDataSourceInstanceSetting(name: string, meta: DataSourcePlugi
type: '',
name,
meta,
access: 'proxy',
jsonData: ({} as unknown) as DataSourceJsonData,
};
}

View File

@ -100,6 +100,7 @@ function getTestContext({
name: 'test-elastic',
type: 'type',
uid: 'uid',
access: 'proxy',
url: ELASTICSEARCH_MOCK_URL,
database,
jsonData,

View File

@ -6,6 +6,7 @@ export const createMockInstanceSetttings = (): AzureDataSourceInstanceSettings =
id: 1,
uid: 'abc',
type: 'azuremonitor',
access: 'proxy',
meta: {} as DataSourcePluginMeta,
name: 'azure',

View File

@ -215,6 +215,7 @@ const defaultSettings: DataSourceInstanceSettings = {
type: 'tracing',
name: 'jaeger',
url: 'http://grafana.com',
access: 'proxy',
meta: {
id: 'jaeger',
name: 'jaeger',

View File

@ -114,6 +114,7 @@ const defaultSettings: DataSourceInstanceSettings = {
uid: '0',
type: 'tracing',
name: 'jaeger',
access: 'proxy',
meta: {
id: 'jaeger',
name: 'jaeger',

View File

@ -67,4 +67,5 @@ const defaultSettings: DataSourceInstanceSettings = {
name: 'zipkin',
meta: {} as any,
jsonData: {},
access: 'proxy',
};