Browse Source

renames intervalSeconds to updateIntervalSeconds

bergquist 7 years ago
parent
commit
75ee1e9208

+ 1 - 0
docs/sources/administration/provisioning.md

@@ -197,6 +197,7 @@ providers:
   folder: ''
   type: file
   disableDeletion: false
+  updateIntervalSeconds: 3 #how often Grafana will scan for changed dashboards
   options:
     path: /var/lib/grafana/dashboards
 ```

+ 2 - 2
pkg/services/provisioning/dashboards/config_reader.go

@@ -82,8 +82,8 @@ func (cr *configReader) readConfig() ([]*DashboardsAsConfig, error) {
 			dashboards[i].OrgId = 1
 		}
 
-		if dashboards[i].IntervalSeconds == 0 {
-			dashboards[i].IntervalSeconds = 3
+		if dashboards[i].UpdateIntervalSeconds == 0 {
+			dashboards[i].UpdateIntervalSeconds = 3
 		}
 	}
 

+ 7 - 5
pkg/services/provisioning/dashboards/config_reader_test.go

@@ -22,7 +22,7 @@ func TestDashboardsAsConfig(t *testing.T) {
 			cfg, err := cfgProvider.readConfig()
 			So(err, ShouldBeNil)
 
-			validateDashboardAsConfig(cfg)
+			validateDashboardAsConfig(t, cfg)
 		})
 
 		Convey("Can read config file in version 0 format", func() {
@@ -30,7 +30,7 @@ func TestDashboardsAsConfig(t *testing.T) {
 			cfg, err := cfgProvider.readConfig()
 			So(err, ShouldBeNil)
 
-			validateDashboardAsConfig(cfg)
+			validateDashboardAsConfig(t, cfg)
 		})
 
 		Convey("Should skip invalid path", func() {
@@ -56,7 +56,9 @@ func TestDashboardsAsConfig(t *testing.T) {
 		})
 	})
 }
-func validateDashboardAsConfig(cfg []*DashboardsAsConfig) {
+func validateDashboardAsConfig(t *testing.T, cfg []*DashboardsAsConfig) {
+	t.Helper()
+
 	So(len(cfg), ShouldEqual, 2)
 
 	ds := cfg[0]
@@ -68,7 +70,7 @@ func validateDashboardAsConfig(cfg []*DashboardsAsConfig) {
 	So(len(ds.Options), ShouldEqual, 1)
 	So(ds.Options["path"], ShouldEqual, "/var/lib/grafana/dashboards")
 	So(ds.DisableDeletion, ShouldBeTrue)
-	So(ds.IntervalSeconds, ShouldEqual, 10)
+	So(ds.UpdateIntervalSeconds, ShouldEqual, 10)
 
 	ds2 := cfg[1]
 	So(ds2.Name, ShouldEqual, "default")
@@ -79,5 +81,5 @@ func validateDashboardAsConfig(cfg []*DashboardsAsConfig) {
 	So(len(ds2.Options), ShouldEqual, 1)
 	So(ds2.Options["path"], ShouldEqual, "/var/lib/grafana/dashboards")
 	So(ds2.DisableDeletion, ShouldBeFalse)
-	So(ds2.IntervalSeconds, ShouldEqual, 3)
+	So(ds2.UpdateIntervalSeconds, ShouldEqual, 3)
 }

+ 1 - 1
pkg/services/provisioning/dashboards/file_reader.go

@@ -66,7 +66,7 @@ func (fr *fileReader) ReadAndListen(ctx context.Context) error {
 		fr.log.Error("failed to search for dashboards", "error", err)
 	}
 
-	ticker := time.NewTicker(time.Duration(int64(time.Second) * fr.Cfg.IntervalSeconds))
+	ticker := time.NewTicker(time.Duration(int64(time.Second) * fr.Cfg.UpdateIntervalSeconds))
 
 	running := false
 

+ 1 - 1
pkg/services/provisioning/dashboards/testdata/test-configs/dashboards-from-disk/dev-dashboards.yaml

@@ -6,7 +6,7 @@ providers:
   folder: 'developers'
   editable: true
   disableDeletion: true
-  intervalSeconds: 10
+  updateIntervalSeconds: 10
   type: file
   options:
     path: /var/lib/grafana/dashboards

+ 1 - 1
pkg/services/provisioning/dashboards/testdata/test-configs/version-0/version-0.yaml

@@ -3,7 +3,7 @@
   folder: 'developers'
   editable: true
   disableDeletion: true
-  intervalSeconds: 10
+  updateIntervalSeconds: 10
   type: file
   options:
     path: /var/lib/grafana/dashboards

+ 40 - 40
pkg/services/provisioning/dashboards/types.go

@@ -10,25 +10,25 @@ import (
 )
 
 type DashboardsAsConfig struct {
-	Name            string
-	Type            string
-	OrgId           int64
-	Folder          string
-	Editable        bool
-	Options         map[string]interface{}
-	DisableDeletion bool
-	IntervalSeconds int64
+	Name                  string
+	Type                  string
+	OrgId                 int64
+	Folder                string
+	Editable              bool
+	Options               map[string]interface{}
+	DisableDeletion       bool
+	UpdateIntervalSeconds int64
 }
 
 type DashboardsAsConfigV0 struct {
-	Name            string                 `json:"name" yaml:"name"`
-	Type            string                 `json:"type" yaml:"type"`
-	OrgId           int64                  `json:"org_id" yaml:"org_id"`
-	Folder          string                 `json:"folder" yaml:"folder"`
-	Editable        bool                   `json:"editable" yaml:"editable"`
-	Options         map[string]interface{} `json:"options" yaml:"options"`
-	DisableDeletion bool                   `json:"disableDeletion" yaml:"disableDeletion"`
-	IntervalSeconds int64                  `json:"intervalSeconds" yaml:"intervalSeconds"`
+	Name                  string                 `json:"name" yaml:"name"`
+	Type                  string                 `json:"type" yaml:"type"`
+	OrgId                 int64                  `json:"org_id" yaml:"org_id"`
+	Folder                string                 `json:"folder" yaml:"folder"`
+	Editable              bool                   `json:"editable" yaml:"editable"`
+	Options               map[string]interface{} `json:"options" yaml:"options"`
+	DisableDeletion       bool                   `json:"disableDeletion" yaml:"disableDeletion"`
+	UpdateIntervalSeconds int64                  `json:"updateIntervalSeconds" yaml:"updateIntervalSeconds"`
 }
 
 type ConfigVersion struct {
@@ -40,14 +40,14 @@ type DashboardAsConfigV1 struct {
 }
 
 type DashboardProviderConfigs struct {
-	Name            string                 `json:"name" yaml:"name"`
-	Type            string                 `json:"type" yaml:"type"`
-	OrgId           int64                  `json:"orgId" yaml:"orgId"`
-	Folder          string                 `json:"folder" yaml:"folder"`
-	Editable        bool                   `json:"editable" yaml:"editable"`
-	Options         map[string]interface{} `json:"options" yaml:"options"`
-	DisableDeletion bool                   `json:"disableDeletion" yaml:"disableDeletion"`
-	IntervalSeconds int64                  `json:"intervalSeconds" yaml:"intervalSeconds"`
+	Name                  string                 `json:"name" yaml:"name"`
+	Type                  string                 `json:"type" yaml:"type"`
+	OrgId                 int64                  `json:"orgId" yaml:"orgId"`
+	Folder                string                 `json:"folder" yaml:"folder"`
+	Editable              bool                   `json:"editable" yaml:"editable"`
+	Options               map[string]interface{} `json:"options" yaml:"options"`
+	DisableDeletion       bool                   `json:"disableDeletion" yaml:"disableDeletion"`
+	UpdateIntervalSeconds int64                  `json:"updateIntervalSeconds" yaml:"updateIntervalSeconds"`
 }
 
 func createDashboardJson(data *simplejson.Json, lastModified time.Time, cfg *DashboardsAsConfig, folderId int64) (*dashboards.SaveDashboardDTO, error) {
@@ -71,14 +71,14 @@ func mapV0ToDashboardAsConfig(v0 []*DashboardsAsConfigV0) []*DashboardsAsConfig
 
 	for _, v := range v0 {
 		r = append(r, &DashboardsAsConfig{
-			Name:            v.Name,
-			Type:            v.Type,
-			OrgId:           v.OrgId,
-			Folder:          v.Folder,
-			Editable:        v.Editable,
-			Options:         v.Options,
-			DisableDeletion: v.DisableDeletion,
-			IntervalSeconds: v.IntervalSeconds,
+			Name:                  v.Name,
+			Type:                  v.Type,
+			OrgId:                 v.OrgId,
+			Folder:                v.Folder,
+			Editable:              v.Editable,
+			Options:               v.Options,
+			DisableDeletion:       v.DisableDeletion,
+			UpdateIntervalSeconds: v.UpdateIntervalSeconds,
 		})
 	}
 
@@ -90,14 +90,14 @@ func (dc *DashboardAsConfigV1) mapToDashboardAsConfig() []*DashboardsAsConfig {
 
 	for _, v := range dc.Providers {
 		r = append(r, &DashboardsAsConfig{
-			Name:            v.Name,
-			Type:            v.Type,
-			OrgId:           v.OrgId,
-			Folder:          v.Folder,
-			Editable:        v.Editable,
-			Options:         v.Options,
-			DisableDeletion: v.DisableDeletion,
-			IntervalSeconds: v.IntervalSeconds,
+			Name:                  v.Name,
+			Type:                  v.Type,
+			OrgId:                 v.OrgId,
+			Folder:                v.Folder,
+			Editable:              v.Editable,
+			Options:               v.Options,
+			DisableDeletion:       v.DisableDeletion,
+			UpdateIntervalSeconds: v.UpdateIntervalSeconds,
 		})
 	}