瀏覽代碼

Don't use command line parameters in puller

Brendan Abolivier 6 年之前
父節點
當前提交
28d65661be
簽署人: Brendan Abolivier <contact@brendanabolivier.com> GPG 金鑰 ID: 8EF1500759F70623
共有 2 個檔案被更改,包括 9 行新增4 行删除
  1. 3
    1
      src/puller/main.go
  2. 6
    3
      src/puller/puller.go

+ 3
- 1
src/puller/main.go 查看文件

@@ -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 查看文件

@@ -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