Browse Source

Comment common

Brendan Abolivier 6 years ago
parent
commit
b38967b06f
Signed by: Brendan Abolivier <contact@brendanabolivier.com> GPG key ID: 8EF1500759F70623
1 changed files with 17 additions and 0 deletions
  1. 17
    0
      src/pusher/common/common.go

+ 17
- 0
src/pusher/common/common.go View File

10
 	"github.com/sirupsen/logrus"
10
 	"github.com/sirupsen/logrus"
11
 )
11
 )
12
 
12
 
13
+// FilterIgnored takes a map mapping files' names to their contents and remove
14
+// all the files that are supposed to be ignored by the dashboard manager.
15
+// An ignored file is either named "versions.json" or describing a dashboard
16
+// which slug starts with a given prefix.
17
+// Returns an error if the slug couldn't be tested against the prefix.
13
 func FilterIgnored(
18
 func FilterIgnored(
14
 	filesToPush *map[string][]byte, cfg *config.Config,
19
 	filesToPush *map[string][]byte, cfg *config.Config,
15
 ) (err error) {
20
 ) (err error) {
34
 	return
39
 	return
35
 }
40
 }
36
 
41
 
42
+// PushFiles takes a slice of files' names and a map mapping a file's name to its
43
+// content, and iterates over the first slice. For each file name, it will push
44
+// to Grafana the content from the map that matches the name, as a creation or
45
+// an update of an existing dashboard.
46
+// Logs any errors encountered during an iteration, but doesn't return until all
47
+// creation and/or update requests have been performed.
37
 func PushFiles(filenames []string, contents map[string][]byte, client *grafana.Client) {
48
 func PushFiles(filenames []string, contents map[string][]byte, client *grafana.Client) {
38
 	// Push all files to the Grafana API
49
 	// Push all files to the Grafana API
39
 	for _, filename := range filenames {
50
 	for _, filename := range filenames {
46
 	}
57
 	}
47
 }
58
 }
48
 
59
 
60
+// DeleteDashboards takes a slice of files' names and a map mapping a file's name
61
+// to its content, and iterates over the first slice. For each file name, extract
62
+// a dashboard's slug from the content, in the map, that matches the name, and
63
+// will use it to send a deletion request to the Grafana API.
64
+// Logs any errors encountered during an iteration, but doesn't return until all
65
+// deletion requests have been performed.
49
 func DeleteDashboards(filenames []string, contents map[string][]byte, client *grafana.Client) {
66
 func DeleteDashboards(filenames []string, contents map[string][]byte, client *grafana.Client) {
50
 	for _, filename := range filenames {
67
 	for _, filename := range filenames {
51
 		// Retrieve dashboard slug because we need it in the deletion request.
68
 		// Retrieve dashboard slug because we need it in the deletion request.