Skip to content

Commit ed3eb46

Browse files
upgraded grafana packages
1 parent faf9d31 commit ed3eb46

24 files changed

+2118
-3304
lines changed

.config/.cprc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"version": "3.0.0"
2+
"version": "5.19.0"
33
}

.config/.eslintrc

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* ⚠️⚠️⚠️ THIS FILE WAS SCAFFOLDED BY `@grafana/create-plugin`. DO NOT EDIT THIS FILE DIRECTLY. ⚠️⚠️⚠️
33
*
44
* In order to extend the configuration follow the steps in
5-
* https://grafana.com/developers/plugin-tools/create-a-plugin/extend-a-plugin/extend-configurations#extend-the-eslint-config
5+
* https://grafana.com/developers/plugin-tools/get-started/set-up-development-environment#extend-the-eslint-config
66
*/
77
{
88
"extends": ["@grafana/eslint-config"],
@@ -20,6 +20,12 @@
2020
"parserOptions": {
2121
"project": "./tsconfig.json"
2222
}
23+
},
24+
{
25+
"files": ["./tests/**/*"],
26+
"rules": {
27+
"react-hooks/rules-of-hooks": "off"
28+
}
2329
}
2430
]
2531
}

.config/Dockerfile

+41-3
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,52 @@ ARG grafana_image=grafana-enterprise
33

44
FROM grafana/${grafana_image}:${grafana_version}
55

6+
ARG anonymous_auth_enabled=true
7+
ARG development=false
8+
ARG TARGETARCH
9+
10+
11+
ENV DEV "${development}"
12+
613
# Make it as simple as possible to access the grafana instance for development purposes
714
# Do NOT enable these settings in a public facing / production grafana instance
815
ENV GF_AUTH_ANONYMOUS_ORG_ROLE "Admin"
9-
ENV GF_AUTH_ANONYMOUS_ENABLED "true"
16+
ENV GF_AUTH_ANONYMOUS_ENABLED "${anonymous_auth_enabled}"
1017
ENV GF_AUTH_BASIC_ENABLED "false"
1118
# Set development mode so plugins can be loaded without the need to sign
1219
ENV GF_DEFAULT_APP_MODE "development"
1320

14-
# Inject livereload script into grafana index.html
21+
22+
LABEL maintainer="Grafana Labs <[email protected]>"
23+
24+
ENV GF_PATHS_HOME="/usr/share/grafana"
25+
WORKDIR $GF_PATHS_HOME
26+
1527
USER root
16-
RUN sed -i 's/<\/body><\/html>/<script src=\"http:\/\/localhost:35729\/livereload.js\"><\/script><\/body><\/html>/g' /usr/share/grafana/public/views/index.html
28+
29+
# Installing supervisor and inotify-tools
30+
RUN if [ "${development}" = "true" ]; then \
31+
if grep -i -q alpine /etc/issue; then \
32+
apk add supervisor inotify-tools git; \
33+
elif grep -i -q ubuntu /etc/issue; then \
34+
DEBIAN_FRONTEND=noninteractive && \
35+
apt-get update && \
36+
apt-get install -y supervisor inotify-tools git && \
37+
rm -rf /var/lib/apt/lists/*; \
38+
else \
39+
echo 'ERROR: Unsupported base image' && /bin/false; \
40+
fi \
41+
fi
42+
43+
COPY supervisord/supervisord.conf /etc/supervisor.d/supervisord.ini
44+
COPY supervisord/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
45+
46+
47+
48+
# Inject livereload script into grafana index.html
49+
RUN sed -i 's|</body>|<script src="http://localhost:35729/livereload.js"></script></body>|g' /usr/share/grafana/public/views/index.html
50+
51+
52+
COPY entrypoint.sh /entrypoint.sh
53+
RUN chmod +x /entrypoint.sh
54+
ENTRYPOINT ["/entrypoint.sh"]

.config/README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,15 @@ version: '3.7'
151151

152152
services:
153153
grafana:
154-
container_name: 'myorg-basic-app'
154+
extends:
155+
file: .config/docker-compose-base.yaml
156+
service: grafana
155157
build:
156-
context: ./.config
157158
args:
158159
grafana_version: ${GRAFANA_VERSION:-9.1.2}
159160
grafana_image: ${GRAFANA_IMAGE:-grafana}
160161
```
161162
162-
In this example, we assign the environment variable `GRAFANA_IMAGE` to the build arg `grafana_image` with a default value of `grafana`. This will allow you to set the value while running the docker-compose commands, which might be convenient in some scenarios.
163+
In this example, we assign the environment variable `GRAFANA_IMAGE` to the build arg `grafana_image` with a default value of `grafana`. This will allow you to set the value while running the docker compose commands, which might be convenient in some scenarios.
163164

164165
---

.config/docker-compose-base.yaml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
services:
2+
grafana:
3+
user: root
4+
container_name: 'victoriametrics-logs-datasource'
5+
6+
build:
7+
context: .
8+
args:
9+
grafana_image: ${GRAFANA_IMAGE:-grafana-enterprise}
10+
grafana_version: ${GRAFANA_VERSION:-11.5.2}
11+
development: ${DEVELOPMENT:-false}
12+
anonymous_auth_enabled: ${ANONYMOUS_AUTH_ENABLED:-true}
13+
ports:
14+
- 3000:3000/tcp
15+
volumes:
16+
- ../plugins/victoriametrics-logs-datasource:/var/lib/grafana/plugins/victoriametrics-logs-datasource
17+
- ../provisioning:/etc/grafana/provisioning
18+
- ..:/root/victoriametrics-logs-datasource
19+
20+
environment:
21+
NODE_ENV: development
22+
GF_LOG_FILTERS: plugin.victoriametrics-logs-datasource:debug
23+
GF_LOG_LEVEL: debug
24+
GF_DATAPROXY_LOGGING: 1
25+
GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS: victoriametrics-logs-datasource

.config/entrypoint.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/sh
2+
3+
if [ "${DEV}" = "false" ]; then
4+
echo "Starting test mode"
5+
exec /run.sh
6+
fi
7+
8+
echo "Starting development mode"
9+
10+
if grep -i -q alpine /etc/issue; then
11+
exec /usr/bin/supervisord -c /etc/supervisord.conf
12+
elif grep -i -q ubuntu /etc/issue; then
13+
exec /usr/bin/supervisord -c /etc/supervisor/supervisord.conf
14+
else
15+
echo 'ERROR: Unsupported base image'
16+
exit 1
17+
fi
18+

.config/jest-setup.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22
* ⚠️⚠️⚠️ THIS FILE WAS SCAFFOLDED BY `@grafana/create-plugin`. DO NOT EDIT THIS FILE DIRECTLY. ⚠️⚠️⚠️
33
*
44
* In order to extend the configuration follow the steps in
5-
* https://grafana.com/developers/plugin-tools/create-a-plugin/extend-a-plugin/extend-configurations#extend-the-jest-config
5+
* https://grafana.com/developers/plugin-tools/get-started/set-up-development-environment#extend-the-jest-config
66
*/
77

88
import '@testing-library/jest-dom';
9+
import { TextEncoder, TextDecoder } from 'util';
10+
11+
Object.assign(global, { TextDecoder, TextEncoder });
912

1013
// https://jestjs.io/docs/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom
1114
Object.defineProperty(global, 'matchMedia', {
1215
writable: true,
13-
value: jest.fn().mockImplementation((query) => ({
16+
value: (query) => ({
1417
matches: false,
1518
media: query,
1619
onchange: null,
@@ -19,7 +22,7 @@ Object.defineProperty(global, 'matchMedia', {
1922
addEventListener: jest.fn(),
2023
removeEventListener: jest.fn(),
2124
dispatchEvent: jest.fn(),
22-
})),
25+
}),
2326
});
2427

2528
HTMLCanvasElement.prototype.getContext = () => {};

.config/jest.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* ⚠️⚠️⚠️ THIS FILE WAS SCAFFOLDED BY `@grafana/create-plugin`. DO NOT EDIT THIS FILE DIRECTLY. ⚠️⚠️⚠️
33
*
44
* In order to extend the configuration follow the steps in
5-
* https://grafana.com/developers/plugin-tools/create-a-plugin/extend-a-plugin/extend-configurations#extend-the-jest-config
5+
* https://grafana.com/developers/plugin-tools/get-started/set-up-development-environment#extend-the-jest-config
66
*/
77

88
const path = require('path');

.config/supervisord/supervisord.conf

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[supervisord]
2+
nodaemon=true
3+
user=root
4+
5+
[program:grafana]
6+
user=root
7+
directory=/var/lib/grafana
8+
command=/run.sh
9+
stdout_logfile=/dev/fd/1
10+
stdout_logfile_maxbytes=0
11+
redirect_stderr=true
12+
killasgroup=true
13+
stopasgroup=true
14+
autostart=true
15+

.config/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* ⚠️⚠️⚠️ THIS FILE WAS SCAFFOLDED BY `@grafana/create-plugin`. DO NOT EDIT THIS FILE DIRECTLY. ⚠️⚠️⚠️
33
*
44
* In order to extend the configuration follow the steps in
5-
* https://grafana.com/developers/plugin-tools/create-a-plugin/extend-a-plugin/extend-configurations#extend-the-typescript-config
5+
* https://grafana.com/developers/plugin-tools/get-started/set-up-development-environment#extend-the-typescript-config
66
*/
77
{
88
"compilerOptions": {
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import * as webpack from 'webpack';
2+
3+
const PLUGIN_NAME = 'BuildModeWebpack';
4+
5+
export class BuildModeWebpackPlugin {
6+
apply(compiler: webpack.Compiler) {
7+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
8+
compilation.hooks.processAssets.tap(
9+
{
10+
name: PLUGIN_NAME,
11+
stage: webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
12+
},
13+
async () => {
14+
const assets = compilation.getAssets();
15+
for (const asset of assets) {
16+
if (asset.name.endsWith('plugin.json')) {
17+
const pluginJsonString = asset.source.source().toString();
18+
const pluginJsonWithBuildMode = JSON.stringify(
19+
{
20+
...JSON.parse(pluginJsonString),
21+
buildMode: compilation.options.mode,
22+
},
23+
null,
24+
4
25+
);
26+
compilation.updateAsset(asset.name, new webpack.sources.RawSource(pluginJsonWithBuildMode));
27+
}
28+
}
29+
}
30+
);
31+
});
32+
}
33+
}

.config/webpack/utils.ts

+5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ export function getPluginJson() {
2929
return require(path.resolve(process.cwd(), `${SOURCE_DIR}/plugin.json`));
3030
}
3131

32+
export function getCPConfigVersion() {
33+
const cprcJson = path.resolve(__dirname, '../', '.cprc.json');
34+
return fs.existsSync(cprcJson) ? require(cprcJson).version : { version: 'unknown' };
35+
}
36+
3237
export function hasReadme() {
3338
return fs.existsSync(path.resolve(process.cwd(), SOURCE_DIR, 'README.md'));
3439
}

0 commit comments

Comments
 (0)