Skip to content

Commit 07e47a0

Browse files
committed
prepare for plugin signing
1 parent 1b9a493 commit 07e47a0

File tree

7 files changed

+52
-20
lines changed

7 files changed

+52
-20
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3-
## 1.0.0 (Unreleased)
3+
## 2.0.0
4+
5+
The plugin is compliant with Grafana Signing Requirements.
6+
7+
## 1.0.12
48

59
Initial release.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "netdata-datasource",
3-
"version": "1.0.12",
2+
"name": "netdatacloud-netdata-datasource",
3+
"version": "2.0.0",
44
"description": "netdata datasource plugin",
55
"scripts": {
66
"build": "grafana-toolkit plugin:build",
@@ -13,9 +13,9 @@
1313
"author": "netdata",
1414
"license": "Apache-2.0",
1515
"devDependencies": {
16-
"@grafana/data": "latest",
17-
"@grafana/toolkit": "latest",
18-
"@grafana/ui": "latest",
16+
"@grafana/data": "8.5.5",
17+
"@grafana/toolkit": "8.5.5",
18+
"@grafana/ui": "8.5.5",
1919
"@testing-library/jest-dom": "5.4.0",
2020
"@testing-library/react": "^10.0.2",
2121
"@testing-library/react-hooks": "^8.0.1",

src/QueryEditor.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ const QueryEditor: React.FC<Props> = ({ datasource, query, onChange, onRunQuery
154154
setSelectedAggreagations(Aggreagations[0]);
155155

156156
fetchRooms(v.value || '');
157-
onChange({ spaceId: v.value } as MyQuery);
157+
onChange({ ...query, spaceId: v.value });
158158
onRunQuery();
159159
};
160160

@@ -173,7 +173,7 @@ const QueryEditor: React.FC<Props> = ({ datasource, query, onChange, onRunQuery
173173

174174
fetchContexts(selectedSpace?.value || '', v.value || '');
175175
fetchNodes(selectedSpace?.value || '', v.value || '');
176-
onChange({ spaceId: spaceId, roomId: v.value } as MyQuery);
176+
onChange({ ...query, spaceId: spaceId, roomId: v.value });
177177
onRunQuery();
178178
};
179179

@@ -190,7 +190,6 @@ const QueryEditor: React.FC<Props> = ({ datasource, query, onChange, onRunQuery
190190

191191
fetchDimensions({ spaceId, roomId, contextId: v.value, nodeIDs: selectedNodes?.map((n: any) => n.value) || [] });
192192
onChange({ ...query, contextId: v.value });
193-
onChange({ spaceId, roomId, contextId: v.value } as MyQuery);
194193
onRunQuery();
195194
};
196195

@@ -207,7 +206,7 @@ const QueryEditor: React.FC<Props> = ({ datasource, query, onChange, onRunQuery
207206

208207
fetchDimensions({ spaceId, roomId, contextId, nodeIDs: data });
209208
setSelectedNodes(data);
210-
onChange({ spaceId, roomId, contextId, nodes: data } as MyQuery);
209+
onChange({ ...query, spaceId, roomId, contextId, nodes: data } as MyQuery);
211210
onRunQuery();
212211
};
213212

src/datasource.ts

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ import {
77
FieldType,
88
} from '@grafana/data';
99
import { useGetChartData } from 'shared/hooks/useGetChartData';
10+
import { Get } from 'shared/utils/request';
1011
import { MyQuery, MyDataSourceOptions } from './shared/types';
1112
import PubSub from 'pubsub-js';
13+
1214
export class DataSource extends DataSourceApi<MyQuery, MyDataSourceOptions> {
1315
baseUrl: string;
1416

@@ -80,10 +82,32 @@ export class DataSource extends DataSourceApi<MyQuery, MyDataSourceOptions> {
8082
}
8183

8284
async testDatasource() {
83-
// Implement a health check for your data source.
84-
return {
85-
status: 'success',
86-
message: 'Success',
87-
};
85+
const defaultErrorMessage = 'Cannot connect to API';
86+
87+
try {
88+
const response = await Get({ path: '/v2/accounts/me', baseUrl: this.baseUrl });
89+
90+
if (response.status === 200 && response?.data?.id !== '00000000-0000-0000-0000-000000000000') {
91+
return {
92+
status: 'success',
93+
message: 'Success',
94+
};
95+
} else {
96+
return {
97+
status: 'error',
98+
message:
99+
response.status === 401 || response?.data?.id !== '00000000-0000-0000-0000-000000000000'
100+
? 'Invalid token. Please validate the token defined on the datasource.'
101+
: response.statusText
102+
? response.statusText
103+
: defaultErrorMessage,
104+
};
105+
}
106+
} catch (err) {
107+
return {
108+
status: 'error',
109+
message: defaultErrorMessage,
110+
};
111+
}
88112
}
89113
}

src/img/screenshot.png

752 KB
Loading

src/plugin.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$schema": "https://raw.githubusercontent.com/grafana/grafana/master/docs/sources/developers/plugins/plugin.schema.json",
33
"name": "netdata",
44
"type": "datasource",
5-
"id": "netdata-datasource",
5+
"id": "netdatacloud-netdata-datasource",
66
"metrics": true,
77
"info": {
88
"description": "netdata datasource plugin",
@@ -25,7 +25,12 @@
2525
"url": "https://github.com/grafana/grafana-starter-datasource/blob/master/LICENSE"
2626
}
2727
],
28-
"screenshots": [],
28+
"screenshots": [
29+
{
30+
"name": "main",
31+
"path": "img/screenshot.png"
32+
}
33+
],
2934
"version": "%VERSION%",
3035
"updated": "%TODAY%"
3136
},

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,7 @@
10981098
resolved "https://registry.yarnpkg.com/@grafana/aws-sdk/-/aws-sdk-0.0.35.tgz#ef1a1294decdb859f04f170f33cf45277703bb87"
10991099
integrity sha512-EUi4hF0NQ7c9+XfUvRfrCkxPVkzRFv4VdSMlUOyyg7FynKq4Do9HF+4gR30Krt0ct6zmloPIx2AAIHL5898g7A==
11001100

1101-
"@grafana/[email protected]", "@grafana/data@latest":
1101+
"@grafana/[email protected]":
11021102
version "8.5.5"
11031103
resolved "https://registry.yarnpkg.com/@grafana/data/-/data-8.5.5.tgz#64f72bc81a02ee32faf07e574aaacf828b3fa519"
11041104
integrity sha512-K/TZQ5DCT8lTDCuMiVaJqUpdiziUJK3ggHGcyB0RZV5fneq8VpiySIuZyii2/b2tBNKz0cRVS+LoI3DerlsH+g==
@@ -1194,7 +1194,7 @@
11941194
tiny-invariant "^1.0.1"
11951195
tiny-warning "^0.0.3"
11961196

1197-
"@grafana/toolkit@latest":
1197+
"@grafana/toolkit@8.5.5":
11981198
version "8.5.5"
11991199
resolved "https://registry.yarnpkg.com/@grafana/toolkit/-/toolkit-8.5.5.tgz#2204bd18de0d05f72a19ada13aae8594a16657a1"
12001200
integrity sha512-6N9lN+S1OXH3O4I73PScH2RmW1l/gvzq3tSFZPAyWHTz/QlZDbEGuS1yMMsmmFfr4FE9iOiGqT7Emp9uvVngKg==
@@ -1282,7 +1282,7 @@
12821282
resolved "https://registry.yarnpkg.com/@grafana/tsconfig/-/tsconfig-1.2.0-rc1.tgz#10973c978ec95b0ea637511254b5f478bce04de7"
12831283
integrity sha512-+SgQeBQ1pT6D/E3/dEdADqTrlgdIGuexUZ8EU+8KxQFKUeFeU7/3z/ayI2q/wpJ/Kr6WxBBNlrST6aOKia19Ag==
12841284

1285-
"@grafana/[email protected]", "@grafana/ui@latest":
1285+
"@grafana/[email protected]":
12861286
version "8.5.5"
12871287
resolved "https://registry.yarnpkg.com/@grafana/ui/-/ui-8.5.5.tgz#4382234529b6c01035b084b01f949134562bc0ef"
12881288
integrity sha512-z79v79B8i6z5cVN7BvZIWQZIEbiyxGoCYl4CM+fSx79+rN2+8hbwzCW7IZttL+Auak0Y7fKqSvWXzwvZ21KnsQ==

0 commit comments

Comments
 (0)