Skip to content
This repository was archived by the owner on Jul 31, 2025. It is now read-only.

Commit d7be0d2

Browse files
committed
Renaming default values
1 parent c40da1f commit d7be0d2

File tree

2 files changed

+25
-23
lines changed

2 files changed

+25
-23
lines changed

pkg/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ func main() {
1616
// argument. This factory will be automatically called on incoming request
1717
// from Grafana to create different instances of SampleDatasource (per datasource
1818
// ID). When datasource configuration changed Dispose method will be called and
19-
// new datasource instance created using NewSampleDatasource factory.
20-
if err := datasource.Manage("grafana-stage-app", plugin.NewSampleDatasource, datasource.ManageOpts{}); err != nil {
19+
// new datasource instance created using NewSynchronizeDatasource factory.
20+
if err := datasource.Manage("novatec-dashboardsync-datasource", plugin.NewSynchronizeDatasource, datasource.ManageOpts{}); err != nil {
2121
log.DefaultLogger.Error(err.Error())
2222
os.Exit(1)
2323
}

pkg/plugin/plugin.go

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,10 @@ import (
2020
// is useful to clean up resources used by previous datasource instance when a new datasource
2121
// instance created upon datasource settings changed.
2222
var (
23-
_ backend.CheckHealthHandler = (*SampleDatasource)(nil)
24-
_ instancemgmt.InstanceDisposer = (*SampleDatasource)(nil)
23+
_ backend.CheckHealthHandler = (*SynchronizeDatasource)(nil)
24+
_ instancemgmt.InstanceDisposer = (*SynchronizeDatasource)(nil)
2525
)
2626

27-
// NewSampleDatasource creates a new datasource instance.
28-
func NewSampleDatasource(_ backend.DataSourceInstanceSettings) (instancemgmt.Instance, error) {
29-
// TODO; initial aufgerufen??
30-
return &SampleDatasource{}, nil
31-
}
32-
33-
// SampleDatasource is an example datasource which can respond to data queries, reports
34-
// its health and has streaming skills.
35-
type SampleDatasource struct{}
36-
37-
// Dispose here tells plugin SDK that plugin wants to clean up resources when a new instance
38-
// created. As soon as datasource settings change detected by SDK old datasource instance will
39-
// be disposed and a new one will be created using NewSampleDatasource factory function.
40-
func (d *SampleDatasource) Dispose() {
41-
// Clean up datasource instance resources.
42-
}
43-
4427
type PullConfiguration struct {
4528
Enable bool `json:"enable"`
4629
GitBranch string `json:"gitBranch"`
@@ -61,11 +44,30 @@ type SynchronizeOptions struct {
6144
PullConfiguration PullConfiguration `json:"pullConfiguration"`
6245
}
6346

47+
// NewSynchronizeDatasource creates a new datasource instance.
48+
func NewSynchronizeDatasource(_ backend.DataSourceInstanceSettings) (instancemgmt.Instance, error) {
49+
log.DefaultLogger.Info("Creating data source.")
50+
return &SynchronizeDatasource{}, nil
51+
}
52+
53+
// SynchronizeDatasource is an example datasource which can respond to data queries, reports
54+
// its health and has streaming skills.
55+
type SynchronizeDatasource struct {
56+
}
57+
58+
// Dispose here tells plugin SDK that plugin wants to clean up resources when a new instance
59+
// created. As soon as datasource settings change detected by SDK old datasource instance will
60+
// be disposed and a new one will be created using NewSampleDatasource factory function.
61+
func (d *SynchronizeDatasource) Dispose() {
62+
log.DefaultLogger.Info("Disposing data source.")
63+
// Clean up datasource instance resources.
64+
}
65+
6466
// CheckHealth handles health checks sent from Grafana to the plugin.
6567
// The main use case for these health checks is the test button on the
6668
// datasource configuration page which allows users to verify that
6769
// a datasource is working as expected.
68-
func (d *SampleDatasource) CheckHealth(_ context.Context, req *backend.CheckHealthRequest) (*backend.CheckHealthResult, error) {
70+
func (d *SynchronizeDatasource) CheckHealth(_ context.Context, req *backend.CheckHealthRequest) (*backend.CheckHealthResult, error) {
6971
log.DefaultLogger.Debug("Backend called with following request", "request", req)
7072

7173
var properties SynchronizeOptions
@@ -143,7 +145,7 @@ func (d *SampleDatasource) CheckHealth(_ context.Context, req *backend.CheckHeal
143145
}, nil
144146
}
145147

146-
func (d *SampleDatasource) PullDashboards(grafanaApi GrafanaApi, gitApi GitApi, repositoryUrl string, branch string) *backend.CheckHealthResult {
148+
func (d *SynchronizeDatasource) PullDashboards(grafanaApi GrafanaApi, gitApi GitApi, repositoryUrl string, branch string) *backend.CheckHealthResult {
147149
log.DefaultLogger.Info("Pulling and importing dashboards", "repositoryUrl", repositoryUrl, "branch", branch)
148150

149151
// clone and fetch repo from specific branch

0 commit comments

Comments
 (0)