Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make plugin IDs match for datasource-http-backend example #484

Merged
merged 2 commits into from
Mar 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services:
grafana:
user: root
container_name: 'example-httpbackend-datasource'
container_name: 'myorg-httpbackend-datasource'

build:
context: .
Expand All @@ -19,13 +19,13 @@ services:
cap_add:
- SYS_PTRACE
volumes:
- ../dist:/var/lib/grafana/plugins/example-httpbackend-datasource
- ../dist:/var/lib/grafana/plugins/myorg-httpbackend-datasource
- ../provisioning:/etc/grafana/provisioning
- ..:/root/example-httpbackend-datasource
- ..:/root/myorg-httpbackend-datasource

environment:
NODE_ENV: development
GF_LOG_FILTERS: plugin.example-httpbackend-datasource:debug
GF_LOG_FILTERS: plugin.myorg-httpbackend-datasource:debug
GF_LOG_LEVEL: debug
GF_DATAPROXY_LOGGING: 1
GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS: example-httpbackend-datasource
GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS: myorg-httpbackend-datasource
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ user=root
[program:grafana]
user=root
directory=/var/lib/grafana
command=bash -c 'while [ ! -f /root/example-httpbackend-datasource/dist/gpx_datasource_http_backend* ]; do sleep 1; done; /run.sh'
command=bash -c 'while [ ! -f /root/myorg-httpbackend-datasource/dist/gpx_datasource_http_backend* ]; do sleep 1; done; /run.sh'
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
redirect_stderr=true
Expand All @@ -26,7 +26,7 @@ autorestart=true

[program:build-watcher]
user=root
command=/bin/bash -c 'while inotifywait -e modify,create,delete -r /var/lib/grafana/plugins/example-httpbackend-datasource; do echo "Change detected, restarting delve...";supervisorctl restart delve; done'
command=/bin/bash -c 'while inotifywait -e modify,create,delete -r /var/lib/grafana/plugins/myorg-httpbackend-datasource; do echo "Change detected, restarting delve...";supervisorctl restart delve; done'
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
redirect_stderr=true
Expand All @@ -37,8 +37,8 @@ autostart=true
[program:mage-watcher]
user=root
environment=PATH="/usr/local/go/bin:/root/go/bin:%(ENV_PATH)s"
directory=/root/example-httpbackend-datasource
command=/bin/bash -c 'git config --global --add safe.directory /root/example-httpbackend-datasource && mage -v watch'
directory=/root/myorg-httpbackend-datasource
command=/bin/bash -c 'git config --global --add safe.directory /root/myorg-httpbackend-datasource && mage -v watch'
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
redirect_stderr=true
Expand Down
6 changes: 3 additions & 3 deletions examples/datasource-http-backend/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3.0'

services:
grafana:
container_name: 'grafana-datasourcehttpbackend-datasource'
container_name: 'myorg-httpbackend-datasource'
build:
context: ./.config
args:
Expand All @@ -11,12 +11,12 @@ services:
ports:
- 3000:3000/tcp
volumes:
- ./dist:/var/lib/grafana/plugins/grafana-datasourcehttpbackend-datasource
- ./dist:/var/lib/grafana/plugins/myorg-httpbackend-datasource
- ./provisioning:/etc/grafana/provisioning
extra_hosts:
- 'host.docker.internal:host-gateway'
mockserver:
container_name: 'mockserver-datasourcehttpbackend-datasource'
container_name: 'mockserver-httpbackend-datasource'
build:
context: ./server
ports:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
{
"refId": "A",
"datasource": {
"type": "example-httpbackend-datasource",
"type": "myorg-httpbackend-datasource",
"uid": "TheUID"
},
"multiplier": 1
}
]
}
}
2 changes: 1 addition & 1 deletion examples/datasource-http-backend/pkg/kinds/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
func TestQueryTypeDefinitions(t *testing.T) {
builder, err := schemabuilder.NewSchemaBuilder(
schemabuilder.BuilderOptions{
PluginID: []string{"example-httpbackend-datasource"},
PluginID: []string{"myorg-httpbackend-datasource"},
ScanCode: []schemabuilder.CodePaths{{
BasePackage: "github.com/grafana/datasource-http-backend/pkg/kinds",
CodePath: "./",
Expand Down
2 changes: 1 addition & 1 deletion examples/datasource-http-backend/pkg/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func main() {
// from Grafana to create different instances of SampleDatasource (per datasource
// ID). When datasource configuration changed Dispose method will be called and
// new datasource instance created using NewSampleDatasource factory.
if err := datasource.Manage("grafana-datasourcehttpbackend-datasource", plugin.NewDatasource, plugin.DatasourceOpts); err != nil {
if err := datasource.Manage("myorg-httpbackend-datasource", plugin.NewDatasource, plugin.DatasourceOpts); err != nil {
log.DefaultLogger.Error(err.Error())
os.Exit(1)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: 1

datasources:
- name: Http Backend Data Source
type: example-httpbackend-datasource
type: myorg-httpbackend-datasource
isDefault: true
orgId: 1
version: 1
Expand Down
2 changes: 1 addition & 1 deletion examples/datasource-http-backend/src/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://raw.githubusercontent.com/grafana/grafana/main/docs/sources/developers/plugins/plugin.schema.json",
"type": "datasource",
"name": "Datasource Http Backend",
"id": "example-httpbackend-datasource",
"id": "myorg-httpbackend-datasource",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, this breaks some of my devs dashboards and other stuff, can we keep the same plugin ID? (I know it's incosistent between examples though).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can sure but I was thinking it might be a good idea to make the IDs consistent at some point. Considering this is dev only, I figured breaking changes would be acceptable 🤷

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, not a big deal but it'd be still incosistent, some of them use grafana as the org, others myorg and others example 🤷

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No that's what I meant 🙈 #485

"metrics": true,
"backend": true,
"alerting": true,
Expand Down