Browse Source

Don't use command line parameters in puller

Brendan Abolivier 6 years ago
parent
commit
28d65661be
Signed by: Brendan Abolivier <contact@brendanabolivier.com> GPG key ID: 8EF1500759F70623
2 changed files with 9 additions and 4 deletions
  1. 3
    1
      src/puller/main.go
  2. 6
    3
      src/puller/puller.go

+ 3
- 1
src/puller/main.go View File

40
 	}
40
 	}
41
 
41
 
42
 	client := grafana.NewClient(*grafanaURL, *grafanaAPIKey)
42
 	client := grafana.NewClient(*grafanaURL, *grafanaAPIKey)
43
-	if err := PullGrafanaAndCommit(client); err != nil {
43
+	if err := PullGrafanaAndCommit(
44
+		client, *repoURL, *clonePath, *privateKeyPath,
45
+	); err != nil {
44
 		panic(err)
46
 		panic(err)
45
 	}
47
 	}
46
 }
48
 }

+ 6
- 3
src/puller/puller.go View File

21
 // PullGrafanaAndCommit pulls all the dashboards from Grafana then commits each
21
 // PullGrafanaAndCommit pulls all the dashboards from Grafana then commits each
22
 // of them to Git except for those that have a newer or equal version number
22
 // of them to Git except for those that have a newer or equal version number
23
 // already versionned in the repo
23
 // already versionned in the repo
24
-func PullGrafanaAndCommit(client *grafana.Client) error {
24
+func PullGrafanaAndCommit(
25
+	client *grafana.Client,
26
+	repoURL string, clonePath string, privateKeyPath string,
27
+) error {
25
 	dv := make(map[string]diffVersion)
28
 	dv := make(map[string]diffVersion)
26
 
29
 
27
 	dbVersions, err := getDashboardsVersions()
30
 	dbVersions, err := getDashboardsVersions()
29
 		return err
32
 		return err
30
 	}
33
 	}
31
 
34
 
32
-	repo, err := git.Sync(*repoURL, *clonePath, *privateKeyPath)
35
+	repo, err := git.Sync(repoURL, clonePath, privateKeyPath)
33
 	if err != nil {
36
 	if err != nil {
34
 		return err
37
 		return err
35
 	}
38
 	}
74
 		}
77
 		}
75
 	}
78
 	}
76
 
79
 
77
-	if err = git.Push(repo, *privateKeyPath); err != nil {
80
+	if err = git.Push(repo, privateKeyPath); err != nil {
78
 		return err
81
 		return err
79
 	}
82
 	}
80
 
83