Skip to content

Commit 09f7ddd

Browse files
Merge pull request #43 from NeedleInAJayStack/chore/update-plugin
Updates dependency versions support
2 parents c6e4031 + 5162958 commit 09f7ddd

28 files changed

+4098
-5106
lines changed

.config/.cprc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"version": "4.10.5"
2+
"version": "5.14.1"
33
}

.config/.eslintrc

Lines changed: 7 additions & 1 deletion
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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,19 @@ ARG grafana_image=grafana-enterprise
33

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

6+
ARG anonymous_auth_enabled=true
67
ARG development=false
8+
ARG TARGETARCH
79

810
ARG GO_VERSION=1.21.6
9-
ARG GO_ARCH=amd64
11+
ARG GO_ARCH=${TARGETARCH:-amd64}
1012

1113
ENV DEV "${development}"
1214

1315
# Make it as simple as possible to access the grafana instance for development purposes
1416
# Do NOT enable these settings in a public facing / production grafana instance
1517
ENV GF_AUTH_ANONYMOUS_ORG_ROLE "Admin"
16-
ENV GF_AUTH_ANONYMOUS_ENABLED "true"
18+
ENV GF_AUTH_ANONYMOUS_ENABLED "${anonymous_auth_enabled}"
1719
ENV GF_AUTH_BASIC_ENABLED "false"
1820
# Set development mode so plugins can be loaded without the need to sign
1921
ENV GF_DEFAULT_APP_MODE "development"
@@ -29,14 +31,14 @@ USER root
2931
# Installing supervisor and inotify-tools
3032
RUN if [ "${development}" = "true" ]; then \
3133
if grep -i -q alpine /etc/issue; then \
32-
apk add supervisor inotify-tools git; \
34+
apk add supervisor inotify-tools git; \
3335
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/*; \
36+
DEBIAN_FRONTEND=noninteractive && \
37+
apt-get update && \
38+
apt-get install -y supervisor inotify-tools git && \
39+
rm -rf /var/lib/apt/lists/*; \
3840
else \
39-
echo 'ERROR: Unsupported base image' && /bin/false; \
41+
echo 'ERROR: Unsupported base image' && /bin/false; \
4042
fi \
4143
fi
4244

.config/README.md

Lines changed: 4 additions & 3 deletions
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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
services:
2+
grafana:
3+
user: root
4+
container_name: 'needleinajaystack-haystack-datasource'
5+
6+
build:
7+
context: .
8+
args:
9+
grafana_image: ${GRAFANA_IMAGE:-grafana-enterprise}
10+
grafana_version: ${GRAFANA_VERSION:-11.3.2}
11+
development: ${DEVELOPMENT:-false}
12+
anonymous_auth_enabled: ${ANONYMOUS_AUTH_ENABLED:-true}
13+
ports:
14+
- 3000:3000/tcp
15+
- 2345:2345/tcp # delve
16+
security_opt:
17+
- "apparmor:unconfined"
18+
- "seccomp:unconfined"
19+
cap_add:
20+
- SYS_PTRACE
21+
volumes:
22+
- ../dist:/var/lib/grafana/plugins/needleinajaystack-haystack-datasource
23+
- ../provisioning:/etc/grafana/provisioning
24+
- ..:/root/needleinajaystack-haystack-datasource
25+
26+
environment:
27+
NODE_ENV: development
28+
GF_LOG_FILTERS: plugin.needleinajaystack-haystack-datasource:debug
29+
GF_LOG_LEVEL: debug
30+
GF_DATAPROXY_LOGGING: 1
31+
GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS: needleinajaystack-haystack-datasource

.config/jest-setup.js

Lines changed: 3 additions & 3 deletions
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
import '@testing-library/jest-dom';
@@ -13,7 +13,7 @@ Object.assign(global, { TextDecoder, TextEncoder });
1313
// https://jestjs.io/docs/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom
1414
Object.defineProperty(global, 'matchMedia', {
1515
writable: true,
16-
value: jest.fn().mockImplementation((query) => ({
16+
value: (query) => ({
1717
matches: false,
1818
media: query,
1919
onchange: null,
@@ -22,7 +22,7 @@ Object.defineProperty(global, 'matchMedia', {
2222
addEventListener: jest.fn(),
2323
removeEventListener: jest.fn(),
2424
dispatchEvent: jest.fn(),
25-
})),
25+
}),
2626
});
2727

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

.config/jest.config.js

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ user=root
55
[program:grafana]
66
user=root
77
directory=/var/lib/grafana
8-
command=bash -c 'while [ ! -f /root/needleinajaystack-haystack-datasource/dist/gpx_haystack* ]; do sleep 1; done; /run.sh'
8+
command=bash -c 'while [ ! -f /root/needleinajaystack-haystack-datasource/dist/gpx_haystack_datasource* ]; do sleep 1; done; /run.sh'
99
stdout_logfile=/dev/fd/1
1010
stdout_logfile_maxbytes=0
1111
redirect_stderr=true
@@ -15,7 +15,7 @@ autostart=true
1515

1616
[program:delve]
1717
user=root
18-
command=/bin/bash -c 'pid=""; while [ -z "$pid" ]; do pid=$(pgrep -f gpx_haystack); done; /root/go/bin/dlv attach --api-version=2 --headless --continue --accept-multiclient --listen=:2345 $pid'
18+
command=/bin/bash -c 'pid=""; while [ -z "$pid" ]; do pid=$(pgrep -f gpx_haystack_datasource); done; /root/go/bin/dlv attach --api-version=2 --headless --continue --accept-multiclient --listen=:2345 $pid'
1919
stdout_logfile=/dev/fd/1
2020
stdout_logfile_maxbytes=0
2121
redirect_stderr=true

.config/tsconfig.json

Lines changed: 1 addition & 1 deletion
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": {
Lines changed: 33 additions & 0 deletions
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+
}

0 commit comments

Comments
 (0)