@@ -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.
2222var (
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-
4427type 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