Browse Source

Comment main functions

Brendan Abolivier 6 years ago
parent
commit
5203f39154
Signed by: Brendan Abolivier <contact@brendanabolivier.com> GPG key ID: 8EF1500759F70623
2 changed files with 13 additions and 0 deletions
  1. 6
    0
      src/puller/main.go
  2. 7
    0
      src/pusher/main.go

+ 6
- 0
src/puller/main.go View File

@@ -11,17 +11,23 @@ import (
11 11
 )
12 12
 
13 13
 func main() {
14
+	// Define this flag in the main function because else it would cause a
15
+	// conflict with the one in the pusher.
14 16
 	configFile := flag.String("config", "config.yaml", "Path to the configuration file")
15 17
 	flag.Parse()
16 18
 
19
+	// Load the logger's configuration.
17 20
 	logger.LogConfig()
18 21
 
22
+	// Load the configuration.
19 23
 	cfg, err := config.Load(*configFile)
20 24
 	if err != nil {
21 25
 		logrus.Panic(err)
22 26
 	}
23 27
 
28
+	// Initialise the Grafana API client.
24 29
 	client := grafana.NewClient(cfg.Grafana.BaseURL, cfg.Grafana.APIKey)
30
+	// Run the puller.
25 31
 	if err := PullGrafanaAndCommit(client, cfg); err != nil {
26 32
 		logrus.Panic(err)
27 33
 	}

+ 7
- 0
src/pusher/main.go View File

@@ -19,18 +19,25 @@ var (
19 19
 func main() {
20 20
 	var err error
21 21
 
22
+	// Define this flag in the main function because else it would cause a
23
+	// conflict with the one in the puller.
22 24
 	configFile := flag.String("config", "config.yaml", "Path to the configuration file")
23 25
 	flag.Parse()
24 26
 
27
+	// Load the logger's configuration.
25 28
 	logger.LogConfig()
26 29
 
30
+	// Load the configuration.
27 31
 	cfg, err := config.Load(*configFile)
28 32
 	if err != nil {
29 33
 		logrus.Panic(err)
30 34
 	}
31 35
 
36
+	// Initialise the Grafana API client.
32 37
 	grafanaClient := grafana.NewClient(cfg.Grafana.BaseURL, cfg.Grafana.APIKey)
33 38
 
39
+	// Set up either a webhook or a poller depending on the mode specified in the
40
+	// configuration file.
34 41
 	switch cfg.Pusher.Mode {
35 42
 	case "webhook":
36 43
 		err = webhook.Setup(cfg, grafanaClient, *deleteRemoved)