grafana-watcher: wait for Grafana to be available and initialize

This commit is contained in:
Frederic Branczyk
2016-10-20 11:17:36 +02:00
parent 37f9502e3a
commit 18652f9b84
3 changed files with 42 additions and 1 deletions

View File

@@ -9,6 +9,7 @@ import (
)
type Updater interface {
Init() error
OnModify() error
}
@@ -24,7 +25,15 @@ func NewGrafanaDashboardUpdater(c grafana.DashboardsInterface, g string) Updater
}
}
func (u *GrafanaDashboardUpdater) Init() error {
return u.updateDashboards()
}
func (u *GrafanaDashboardUpdater) OnModify() error {
return u.updateDashboards()
}
func (u *GrafanaDashboardUpdater) updateDashboards() error {
err := u.deleteAllDashboards()
if err != nil {
return err

View File

@@ -20,7 +20,15 @@ func NewGrafanaDatasourceUpdater(c grafana.DatasourcesInterface, g string) Updat
}
}
func (u *GrafanaDatasourceUpdater) Init() error {
return u.updateDatasources()
}
func (u *GrafanaDatasourceUpdater) OnModify() error {
return u.updateDatasources()
}
func (u *GrafanaDatasourceUpdater) updateDatasources() error {
err := u.deleteAllDatasources()
if err != nil {
return err