Sfoglia il codice sorgente

Don't use command line parameters in puller

Brendan Abolivier 7 anni fa
parent
commit
28d65661be
Signed by: Brendan Abolivier <contact@brendanabolivier.com> GPG key ID: 8EF1500759F70623
2 ha cambiato i file con 9 aggiunte e 4 eliminazioni
  1. 3
    1
      src/puller/main.go
  2. 6
    3
      src/puller/puller.go

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

@@ -40,7 +40,9 @@ func main() {
40 40
 	}
41 41
 
42 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 46
 		panic(err)
45 47
 	}
46 48
 }

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

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