|
@@ -6,14 +6,12 @@ import (
|
6
|
6
|
"config"
|
7
|
7
|
"grafana"
|
8
|
8
|
"logger"
|
|
9
|
+ "pusher/webhook"
|
|
10
|
+
|
|
11
|
+ "github.com/sirupsen/logrus"
|
9
|
12
|
)
|
10
|
13
|
|
11
|
|
-// Some variables need to be global to the package since we need them in the
|
12
|
|
-// webhook handlers.
|
13
|
|
-// TODO: Find a better way to pass it to the handlers
|
14
|
14
|
var (
|
15
|
|
- grafanaClient *grafana.Client
|
16
|
|
- cfg *config.Config
|
17
|
15
|
deleteRemoved = flag.Bool("delete-removed", false, "For each file removed from Git, delete the corresponding dashboard on the Grafana API")
|
18
|
16
|
)
|
19
|
17
|
|
|
@@ -25,14 +23,14 @@ func main() {
|
25
|
23
|
|
26
|
24
|
logger.LogConfig()
|
27
|
25
|
|
28
|
|
- cfg, err = config.Load(*configFile)
|
|
26
|
+ cfg, err := config.Load(*configFile)
|
29
|
27
|
if err != nil {
|
30
|
|
- panic(err)
|
|
28
|
+ logrus.Panic(err)
|
31
|
29
|
}
|
32
|
30
|
|
33
|
|
- grafanaClient = grafana.NewClient(cfg.Grafana.BaseURL, cfg.Grafana.APIKey)
|
|
31
|
+ grafanaClient := grafana.NewClient(cfg.Grafana.BaseURL, cfg.Grafana.APIKey)
|
34
|
32
|
|
35
|
|
- if err = SetupWebhook(cfg); err != nil {
|
36
|
|
- panic(err)
|
|
33
|
+ if err = webhook.Setup(cfg, grafanaClient, *deleteRemoved); err != nil {
|
|
34
|
+ logrus.Panic(err)
|
37
|
35
|
}
|
38
|
36
|
}
|