Skip to content

Commit f92b7e0

Browse files
committed
Remove signed plugin restrictions
Allow signed plugin to work in every environment. Remove unsigned plugin build actions.
1 parent 3e26193 commit f92b7e0

File tree

15 files changed

+42
-120
lines changed

15 files changed

+42
-120
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,11 @@ on:
99
- cron: '38 0 * * *' # every day at randint(0, 60) minutes after midnight
1010

1111
jobs:
12-
test-plugin-json:
13-
runs-on: ubuntu-latest
14-
steps:
15-
- uses: actions/checkout@v4
16-
17-
- name: Install dependencies
18-
run: |
19-
sudo apt-get install jq
20-
21-
- name: plugin_json_to_cloud.sh should not change src.plugin.json
22-
run: |
23-
# src/plugin.json and plugin_json_to_cloud.sh
24-
# should contain the same ids and strings
25-
# this test makes sure they stay in sync
26-
jq --sort-keys . src/plugin.json > /tmp/before.json
27-
bash utils/plugin_json_to_cloud.sh
28-
jq --sort-keys . src/plugin.json > /tmp/after.json
29-
diff /tmp/before.json /tmp/after.json
30-
3112
build:
3213
runs-on: ubuntu-latest
3314
outputs:
3415
signed-plugin-name: '${{ steps.build-signed.outputs.plugin_path }}'
35-
unsigned-plugin-name: '${{ steps.build-unsigned.outputs.plugin_path }}'
16+
3617
steps:
3718
- uses: actions/checkout@v4
3819

@@ -63,16 +44,6 @@ jobs:
6344
- name: clean up repo
6445
uses: actions/checkout@v4
6546

66-
- name: Build frontend unsigned
67-
id: build-unsigned
68-
uses: ./.github/build/
69-
with:
70-
release: false
71-
signed: false
72-
73-
- name: clean up repo
74-
uses: actions/checkout@v4
75-
7647
- name: Build frontend signed
7748
if: (github.event_name != 'pull_request') || (github.event.pull_request.head.repo.full_name == github.repository)
7849
id: build-signed
@@ -118,12 +89,12 @@ jobs:
11889
- name: Download package from build job
11990
uses: actions/download-artifact@v4
12091
with:
121-
name: '${{ needs.build.outputs.unsigned-plugin-name }}'
92+
name: '${{ needs.build.outputs.signed-plugin-name }}'
12293

12394
- name: unpack and move plugin
12495
run: |
125-
unzip tribe-29-checkmk-datasource*.zip
126-
mv tribe-29-checkmk-datasource dist
96+
unzip checkmk-cloud-datasource*.zip
97+
mv checkmk-cloud-datasource dist
12798
12899
- name: run the e2e tests
129100
run: |
@@ -140,3 +111,4 @@ jobs:
140111
name: playwright
141112
retention-days: 1
142113
path: tests/results
114+
if-no-files-found: ignore

.github/workflows/release.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,6 @@ jobs:
2727

2828
- uses: actions/checkout@v4
2929

30-
- name: build unsigned
31-
id: build-unsigned
32-
uses: ./.github/build/
33-
with:
34-
release: true
35-
signed: false
36-
37-
- uses: actions/checkout@v4
38-
3930
- name: download all action artifacs
4031
uses: actions/download-artifact@v4
4132
with:
@@ -54,8 +45,6 @@ jobs:
5445
files: |
5546
${{ steps.build-signed.outputs.plugin_path }}
5647
${{ steps.build-signed.outputs.plugin_checksum_path }}
57-
${{ steps.build-unsigned.outputs.plugin_path }}
58-
${{ steps.build-unsigned.outputs.plugin_checksum_path }}
5948
6049
- uses: adelynx/[email protected]
6150
with:

.prettierignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
dist/
2-
src/plugin.json
1+
dist/

README.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
# Checkmk data source
22

3-
[![Grafana 9.5](https://img.shields.io/badge/Grafana-9.5-orange)](https://www.grafana.com)
4-
[![Grafana 10.2](https://img.shields.io/badge/Grafana-10.2-orange)](https://www.grafana.com)
3+
[![Grafana 10.4](https://img.shields.io/badge/Grafana-10.4-orange)](https://www.grafana.com)
4+
[![Grafana 11.6](https://img.shields.io/badge/Grafana-11.6-orange)](https://www.grafana.com)
55
[![Checkmk data source for Checkmk Cloud & MSP](https://img.shields.io/badge/dynamic/json?color=blue&label=Checkmk%20for%20Cloud%20Edition&query=%24.version&url=https%3A%2F%2Fgrafana.com%2Fapi%2Fplugins%2Fcheckmk-cloud-datasource)](https://grafana.com/grafana/plugins/checkmk-cloud-datasource)
6-
[![Checkmk unsigned data source](https://img.shields.io/badge/dynamic/json?color=blue&label=Checkmk&query=tag_name&url=https%3A%2F%2Fapi.github.com%2Frepos%2Ftribe29%2Fgrafana-checkmk-datasource%2Freleases%2Flatest)](https://github.com/Checkmk/grafana-checkmk-datasource)
76
[![CI](https://github.com/Checkmk/grafana-checkmk-datasource/actions/workflows/ci.yml/badge.svg?branch=main&event=schedule)](https://github.com/Checkmk/grafana-checkmk-datasource/actions/workflows/ci.yml?query=event%3Aschedule)
87

98

@@ -16,19 +15,17 @@ This [data source][2] plugin for [Grafana][1] allows to address Checkmk as sourc
1615

1716
To make use of the plugin, you need to take care the correct versions are installed. You need to match both, the Grafana and the Checkmk version:
1817

19-
- **Grafana 9.5.15 or higher** Current and previous major version of Grafana
20-
- **Checkmk Cloud or Checkmk MSP 2.2.0 or higher** for the signed plugin available from [Grafana][6]
21-
- **Checkmk 2.2.0 or higher** for the unsigned plugin available from [Github][8]
18+
- **Grafana 10.4.18 or higher** Current and previous major version of Grafana
19+
- **Checkmk 2.2.0 or higher** for the plugin available from [Github][8] or from [Grafana marketplace][6]
2220

2321
## Installing the plug-in
2422

25-
The signed plug-in can be installed from the [Grafana marketplace][6] or by using the `grafana-cli`:
23+
The plug-in can be installed from the [Grafana marketplace][6] or by using the `grafana-cli`:
2624

2725
```bash
2826
grafana-cli plugins install checkmk-cloud-datasource
2927
```
3028

31-
For the installation of the unsigned plugin, please take a look at the official [Checkmk User Guide][3].
3229

3330
## Official documentation
3431

docker-compose.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: '3.0'
22

33
services:
44
grafana:
5-
container_name: 'tribe-29-checkmk-datasource'
5+
container_name: 'checkmk-cloud-datasource'
66
build:
77
context: ./.config
88
args:
@@ -14,14 +14,14 @@ services:
1414
extra_hosts:
1515
- checkmk.local:host-gateway
1616
volumes:
17-
- ./dist:/var/lib/grafana/plugins/tribe-29-checkmk-datasource
17+
- ./dist:/var/lib/grafana/plugins/checkmk-cloud-datasource
1818
- ./provisioning:/etc/grafana/provisioning
1919
- .:/root/checkmk-cmkgrafanadatasource2-datasource
2020

2121
environment:
2222
NODE_ENV: development
23-
GF_LOG_FILTERS: plugin.tribe-29-checkmk-datasource:debug
23+
GF_LOG_FILTERS: plugin.checkmk-cloud-datasource:debug
2424
GF_LOG_LEVEL: debug
2525
GF_DATAPROXY_LOGGING: 1
26-
GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS: tribe-29-checkmk-datasource
26+
GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS: checkmk-cloud-datasource
2727

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"version": "3.4.1",
44
"description": "Datasource for checkmk",
55
"scripts": {
6-
"build": "bash utils/plugin_json_to_unsigned.sh && webpack -c ./webpack.config.ts --env production",
7-
"build:cloud": "bash utils/plugin_json_to_cloud.sh && BUILD_EDITION=CLOUD webpack -c ./webpack.config.ts --env production",
6+
"build": "webpack -c ./webpack.config.ts --env production",
7+
"build:cloud": "webpack -c ./webpack.config.ts --env production",
88
"dev": "webpack -w -c ./webpack.config.ts --env development",
99
"test": "jest --watch --onlyChanged",
1010
"test:ci": "jest --passWithNoTests --maxWorkers 4",
@@ -19,7 +19,8 @@
1919
"e2e": "playwright test",
2020
"e2e:ci": "playwright test",
2121
"e2e:debug": "playwright test --debug",
22-
"e2e:gui": "playwright test --ui"
22+
"e2e:gui": "playwright test --ui",
23+
"e2e:show-trace": "playwright show-trace"
2324
},
2425
"author": "Checkmk",
2526
"license": "Apache-2.0",

src/backend/rest.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
toDataFrame,
1414
} from '@grafana/data';
1515
import { BackendSrvRequest, FetchError, FetchResponse, getBackendSrv } from '@grafana/runtime';
16-
import * as process from 'process';
1716
import { lastValueFrom } from 'rxjs';
1817

1918
import { Aggregation, GraphType, MetricFindQuery } from '../RequestSpec';
@@ -255,12 +254,6 @@ export default class RestApiBackend implements Backend {
255254
if (checkmkEdition === 'cse') {
256255
throw new Error('Cannot query data from Checkmk Cloud (SaaS).');
257256
}
258-
const allowedEditions = new Set(['cce', 'cme']);
259-
if (process.env.BUILD_EDITION === 'CLOUD' && !allowedEditions.has(checkmkEdition || '')) {
260-
throw new Error(
261-
'This Checkmk data source is only compatible with Checkmk Cloud and Checkmk MSP, but you are trying to connect to another edition.'
262-
);
263-
}
264257

265258
return result;
266259
}

src/plugin.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
{
22
"$schema": "https://raw.githubusercontent.com/grafana/grafana/master/docs/sources/developers/plugins/plugin.schema.json",
33
"type": "datasource",
4-
"name": "Checkmk data source for Checkmk Cloud & MSP",
4+
"name": "Checkmk data source",
55
"id": "checkmk-cloud-datasource",
66
"metrics": true,
77
"info": {
8-
"description": "Checkmk data source for Checkmk Cloud or Checkmk MSP 2.2.0 or higher",
8+
"description": "Checkmk data source for Checkmk 2.2.0 or higher",
99
"author": {
1010
"name": "Checkmk GmbH",
1111
"url": "https://github.com/Checkmk/"
1212
},
13-
"keywords": [
14-
"checkmk"
15-
],
13+
"keywords": ["checkmk"],
1614
"logos": {
1715
"small": "img/checkmk_logo.svg",
1816
"large": "img/checkmk_logo.svg"

src/ui/ConfigEditor.tsx

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { DataSourcePluginOptionsEditorProps, SelectableValue } from '@grafana/data';
22
import { FieldSet, InlineField, LegacyForms, Select } from '@grafana/ui';
3-
import * as process from 'process';
43
import React, { ChangeEvent, useCallback } from 'react';
54

65
import { Settings } from '../settings';
@@ -103,25 +102,20 @@ export const ConfigEditor = (props: Props) => {
103102
onChange={onUrlChange}
104103
value={settings.url || ''}
105104
tooltip="Which Checkmk Server to connect to. (Example: https://checkmk.server/site)"
106-
data-test-id="checkmk-url"
105+
data-testid="checkmk-url"
107106
/>
108107
</div>
109-
{process.env.BUILD_EDITION !== 'CLOUD' ? (
110-
<>
111-
<InlineField label="Edition" labelWidth={12}>
112-
<Select
113-
width={32}
114-
options={cmkEditions}
115-
onChange={onEditionChange}
116-
value={settings.edition}
117-
placeholder="Select your checkmk edition"
118-
inputId="checkmk-edition"
119-
/>
120-
</InlineField>
121-
</>
122-
) : (
123-
<></>
124-
)}
108+
<InlineField label="Edition" labelWidth={12}>
109+
<Select
110+
width={32}
111+
options={cmkEditions}
112+
onChange={onEditionChange}
113+
value={settings.edition}
114+
placeholder="Select your checkmk edition"
115+
inputId="checkmk-edition"
116+
data-testid="checkmk-edition"
117+
/>
118+
</InlineField>
125119
</FieldSet>
126120
<FieldSet label="Authentication">
127121
<div className="gf-form">
@@ -132,7 +126,7 @@ export const ConfigEditor = (props: Props) => {
132126
onChange={onUsernameChange}
133127
value={settings.username}
134128
tooltip="A checkmk monitoring user. Don't use 'automation' user, because it has admin rights."
135-
data-test-id="checkmk-username"
129+
data-testid="checkmk-username"
136130
/>
137131
</div>
138132
<div className="gf-form">
@@ -146,7 +140,7 @@ export const ConfigEditor = (props: Props) => {
146140
onReset={onResetSecret}
147141
onChange={onSecretChange}
148142
tooltip="You can find the secret for your user in your checkmk server under Users."
149-
data-test-id="checkmk-password"
143+
data-testid="checkmk-password"
150144
/>
151145
</div>
152146
</FieldSet>

tests/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ services:
1818
GF_ANALYTICS_CHECK_FOR_PLUGIN_UPDATES: 'false'
1919
GF_SECURITY_ADMIN_USER: admin
2020
GF_SECURITY_ADMIN_PASSWORD: password
21-
GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS: tribe-29-checkmk-datasource
21+
GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS: checkmk-cloud-datasource
2222
GF_AUTH_ANONYMOUS_ORG_ROLE: Admin
2323
GF_AUTH_ANONYMOUS_ENABLED: 'true'
2424
extra_hosts:

0 commit comments

Comments
 (0)