Skip to content

Commit 0a45055

Browse files
committed
Rebranding I
This change welcomes Community, Pro, Ultimate, Ultimate with multi-tenancy and Cloud edition descriptors. The restrictions over the editions are preserved. Internally, still working with RAW and CEE types. Cloud (former SaaS) not supported.
1 parent 163eb1f commit 0a45055

File tree

9 files changed

+85
-16
lines changed

9 files changed

+85
-16
lines changed

src/DataSource.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
TestDataSourceResponse,
88
} from '@grafana/data';
99
import { FetchResponse } from '@grafana/runtime';
10+
import { EditionFamily, getEditionFamily } from 'edition';
1011
import { replaceVariables } from 'utils';
1112

1213
import { MetricFindQuery, RequestSpec } from './RequestSpec';
@@ -82,4 +83,8 @@ export class DataSource extends DataSourceApi<CmkQuery> {
8283
getUsername(): string {
8384
return this.settings.username;
8485
}
86+
87+
getEditionFamily(): EditionFamily {
88+
return getEditionFamily(this.settings.edition);
89+
}
8590
}

src/backend/rest.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
toDataFrame,
1414
} from '@grafana/data';
1515
import { BackendSrvRequest, FetchError, FetchResponse, getBackendSrv } from '@grafana/runtime';
16+
import { EditionFamily, getEditionFamily, isCloudEdition } from 'edition';
1617
import { lastValueFrom } from 'rxjs';
1718

1819
import { Aggregation, GraphType, MetricFindQuery } from '../RequestSpec';
@@ -181,17 +182,23 @@ export default class RestApiBackend implements Backend {
181182
if (checkMkVersion.startsWith('2.0') || checkMkVersion.startsWith('2.1') || checkMkVersion.startsWith('1.')) {
182183
throw new Error(`A Checkmk version below 2.2.0 is not supported for this plugin.`);
183184
}
184-
if (this.datasource.getEdition() !== 'RAW' && result.data.edition === 'cre') {
185+
if (
186+
this.datasource.getEditionFamily() !== EditionFamily.COMMUNITY &&
187+
getEditionFamily(result.data.edition) === EditionFamily.COMMUNITY
188+
) {
185189
throw new Error(
186-
'The data source specified the Checkmk commercial editions, but Checkmk Raw Edition was detected. Choose the raw edition in the data source settings.'
190+
'The data source specified the Checkmk commercial editions, but Checkmk Community Edition was detected. Choose the Community Edition in the data source settings.'
187191
);
188192
}
189-
if (this.datasource.getEdition() === 'RAW' && result.data.edition !== 'cre') {
193+
if (
194+
this.datasource.getEditionFamily() === EditionFamily.COMMUNITY &&
195+
getEditionFamily(result.data.edition) !== EditionFamily.COMMUNITY
196+
) {
190197
throw new Error(
191-
'The data source specified the Checkmk Raw Edition, but a Checkmk commercial edition was detected. Some functionality may not be available. Choose commercial editions in the data source settings to enable all features.'
198+
'The data source specified the Checkmk Community Edition, but a Checkmk commercial edition was detected. Some functionality may not be available. Choose commercial editions in the data source settings to enable all features.'
192199
);
193200
}
194-
if (result.data.edition === 'cse') {
201+
if (isCloudEdition(result.data.edition)) {
195202
throw new Error('Detected Checkmk Cloud (SaaS). Can not query data from Checkmk Cloud (SaaS).');
196203
}
197204
// The REST API would be ok with other users, but the autocompleter are not
@@ -251,7 +258,7 @@ export default class RestApiBackend implements Backend {
251258
// check for cloud edition header
252259
const checkmkEdition = result.headers.get('X-Checkmk-Edition');
253260
// CSE is never supported
254-
if (checkmkEdition === 'cse') {
261+
if (checkmkEdition && isCloudEdition(checkmkEdition)) {
255262
throw new Error('Cannot query data from Checkmk Cloud (SaaS).');
256263
}
257264

@@ -264,7 +271,6 @@ export default class RestApiBackend implements Backend {
264271
// our api only supports a single chart/query per api call.
265272
updateQuery(query);
266273

267-
// prepare data required by cre and cee
268274
if (
269275
query.requestSpec === undefined ||
270276
(query.requestSpec.graph_type !== 'single_metric' && query.requestSpec.graph_type !== 'predefined_graph') ||
@@ -290,8 +296,8 @@ export default class RestApiBackend implements Backend {
290296
}
291297

292298
let response: FetchResponse<RestApiGraphResponse>;
293-
if (this.datasource.getEdition() === 'RAW') {
294-
// send request for cre
299+
if (this.datasource.getEditionFamily() === EditionFamily.COMMUNITY) {
300+
// send request for community edition
295301
if (
296302
query.requestSpec.site === undefined ||
297303
query.requestSpec.host_name === undefined ||
@@ -315,7 +321,7 @@ export default class RestApiBackend implements Backend {
315321
data: request,
316322
});
317323
} else {
318-
// send request for cee
324+
// send request for commercial editions
319325
const request: RestApiFilterRequest = {
320326
filter: createCmkContext(query.requestSpec),
321327
aggregation: query.requestSpec.aggregation,

src/backend/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { DataQueryRequest, DataQueryResponse, MetricFindValue, TestDataSourceResponse } from '@grafana/data';
2+
import { EditionFamily } from 'edition';
23

34
import { MetricFindQuery } from '../RequestSpec';
45
import { CmkQuery, Edition } from '../types';
@@ -14,4 +15,5 @@ export interface DatasourceOptions {
1415
getEdition: () => Edition;
1516
getUrl: () => string | undefined;
1617
getUsername(): string;
18+
getEditionFamily: () => EditionFamily;
1719
}

src/backend/validate.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { EditionFamily, getEditionFamily } from 'edition';
2+
13
import { RequestSpec } from '../RequestSpec';
24
import { Edition } from '../types';
35
import { labelForRequestSpecKey } from '../ui/utils';
@@ -11,7 +13,7 @@ const missingRequiredFields = (rq: Partial<RequestSpec>, edition: Edition): stri
1113
result.push('graph');
1214
}
1315

14-
if (edition === 'RAW') {
16+
if (getEditionFamily(edition) === EditionFamily.COMMUNITY) {
1517
if (rq.site === undefined) {
1618
result.push('site');
1719
}

src/edition.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
export enum EditionFamily {
2+
COMMUNITY = 'COMMUNITY',
3+
COMMERCIAL = 'COMMERCIAL',
4+
}
5+
6+
export enum EditionFamilyLabel {
7+
COMMUNITY = 'Community Edition',
8+
COMMERCIAL = 'Commercial editions',
9+
}
10+
11+
export enum Edition {
12+
// Pre 2.5.0
13+
CRE = 'raw',
14+
CEE = 'cee',
15+
CCE = 'cce',
16+
CME = 'cme',
17+
CSE = 'cse',
18+
19+
//2.5.0
20+
COMMUNITY = 'community',
21+
PRO = 'pro',
22+
ULTIMATE = 'ultimate',
23+
ULTIMATE_MULTI_TENANCY = 'ultimatemt',
24+
CLOUD = 'cloud',
25+
}
26+
27+
export const getEditionFamily = (editionString: string | Edition): EditionFamily => {
28+
const commercialEditions: Array<string | Edition> = [
29+
'CEE',
30+
'cee',
31+
'cce',
32+
'cme',
33+
'cse',
34+
'pro',
35+
'ultimate',
36+
'ultimatemt',
37+
'cloud',
38+
Edition.CEE,
39+
Edition.CCE,
40+
Edition.CME,
41+
Edition.CSE,
42+
Edition.PRO,
43+
Edition.ULTIMATE,
44+
Edition.ULTIMATE_MULTI_TENANCY,
45+
Edition.CLOUD,
46+
];
47+
return commercialEditions.includes(editionString) ? EditionFamily.COMMERCIAL : EditionFamily.COMMUNITY;
48+
};
49+
50+
export const isCloudEdition = (editionString: string): boolean => {
51+
return ['cse', 'cloud'].includes(editionString);
52+
};

src/ui/ConfigEditor.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { DataSourcePluginOptionsEditorProps, SelectableValue } from '@grafana/data';
22
import { FieldSet, InlineField, LegacyForms, Select } from '@grafana/ui';
3+
import { EditionFamilyLabel } from 'edition';
34
import React, { ChangeEvent, useCallback } from 'react';
45

56
import { Settings } from '../settings';
@@ -16,8 +17,8 @@ interface EditionOption {
1617
}
1718

1819
const cmkEditions: EditionOption[] = [
19-
{ value: 'CEE', label: 'Commercial editions' },
20-
{ value: 'RAW', label: 'Raw Edition' },
20+
{ value: 'CEE', label: EditionFamilyLabel.COMMERCIAL },
21+
{ value: 'RAW', label: EditionFamilyLabel.COMMUNITY },
2122
];
2223

2324
export const ConfigEditor = (props: Props) => {

tests/e2e/constants.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ export const HOSTNAME1 = 'localhost_grafana1';
44
export const TESTDATASOURCENAME0 = 'cmk_test_datasource_0';
55
export const TESTDATASOURCENAME1 = 'cmk_test_datasource_1';
66

7+
// Must match EditionFamilyLabel elements
78
export enum CmkEdition {
8-
CRE = 'Raw Edition',
9+
CRE = 'Community Edition',
910
CEE = 'Commercial editions',
1011
}
1112

tests/e2e/tests/autocompleters.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ test.describe('Comercial editions tests', () => {
6363
});
6464
});
6565

66-
test.describe('Raw edition tests', () => {
66+
test.describe('Community edition tests', () => {
6767
test.slow();
6868
test('Filtering autocompleters', async ({ panelEditPage, page, selectors }) => {
6969
const panelPage = new CmkRawQueryEditorPage(page, selectors, panelEditPage);

tests/e2e/tests/e2e.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ test.describe('Comercial editions tests', () => {
154154
});
155155
});
156156

157-
test.describe('RAW edition tests', () => {
157+
test.describe('Community edition tests', () => {
158158
test.slow();
159159

160160
test('time-usage panel by service (Single host)', async ({ page, selectors, panelEditPage }, testInfo) => {

0 commit comments

Comments
 (0)