mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat: data source proxy refactoring and route handling, #9078
This commit is contained in:
38
tests/datasource-test/module.js
Normal file
38
tests/datasource-test/module.js
Normal file
@@ -0,0 +1,38 @@
|
||||
System.register([], function (_export) {
|
||||
"use strict";
|
||||
|
||||
return {
|
||||
setters: [],
|
||||
execute: function () {
|
||||
|
||||
function Datasource(instanceSettings, backendSrv) {
|
||||
this.url = instanceSettings.url;
|
||||
|
||||
this.testDatasource = function() {
|
||||
return backendSrv.datasourceRequest({
|
||||
method: 'GET',
|
||||
url: this.url + '/api/v4/search'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function ConfigCtrl() {
|
||||
|
||||
}
|
||||
|
||||
ConfigCtrl.template = `
|
||||
<div class="gf-form">
|
||||
<label class="gf-form-label width-13">Email </label>
|
||||
<input type="text" class="gf-form-input max-width-18" ng-model='ctrl.current.jsonData.email'></input>
|
||||
</div>
|
||||
<div class="gf-form">
|
||||
<label class="gf-form-label width-13">Access key ID </label>
|
||||
<input type="text" class="gf-form-input max-width-18" ng-model='ctrl.current.secureJsonData.token'></input>
|
||||
</div>
|
||||
`;
|
||||
|
||||
_export('Datasource', Datasource);
|
||||
_export('ConfigCtrl', ConfigCtrl);
|
||||
}
|
||||
};
|
||||
});
|
31
tests/datasource-test/plugin.json
Normal file
31
tests/datasource-test/plugin.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"type": "datasource",
|
||||
"name": "Test Datasource",
|
||||
"id": "test-ds",
|
||||
|
||||
"routes": [
|
||||
{
|
||||
"path": "api/v5/",
|
||||
"method": "*",
|
||||
"url": "https://grafana-api.kentik.com/api/v5",
|
||||
"tokenAuth": {
|
||||
"url": "https://login.microsoftonline.com/{{.JsonData.tenantId}}/oauth2/token",
|
||||
"body": {
|
||||
"grant_type": "client_credentials",
|
||||
"client_id": "{{.JsonData.clientId}}",
|
||||
"client_secret": "{{.SecureJsonData.clientSecret}}",
|
||||
"resource": "https://management.azure.com/"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "api/v4/",
|
||||
"method": "*",
|
||||
"url": "http://localhost:3333",
|
||||
"headers": [
|
||||
{"name": "X-CH-Auth-API-Token", "content": "test {{.SecureJsonData.token}}"},
|
||||
{"name": "X-CH-Auth-Email", "content": "test {{.JsonData.email}}"}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Reference in New Issue
Block a user