-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
101 lines (97 loc) · 2.4 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package main
import (
"github.com/charmbracelet/log"
exports "grafiport/export"
restores "grafiport/restore"
)
var (
errors []error
err error
)
func main() {
if restore {
if datasources {
err = restores.DataSources(username, password, url, directory)
if err != nil {
errors = append(errors, err)
}
}
if dashboards {
err = restores.Folders(username, password, url, directory)
if err != nil {
errors = append(errors, err)
}
err = restores.LibraryPanels(username, password, url, directory)
if err != nil {
errors = append(errors, err)
}
err = restores.Dashboards(username, password, url, directory)
if err != nil {
errors = append(errors, err)
}
}
if alerting {
err = restores.AlertRules(username, password, url, directory)
if err != nil {
errors = append(errors, err)
}
err = restores.ContactPoints(username, password, url, directory)
if err != nil {
errors = append(errors, err)
}
err = restores.NotificationPolicies(username, password, url, directory)
if err != nil {
errors = append(errors, err)
}
err = restores.NotificationTemplates(username, password, url, directory)
if err != nil {
errors = append(errors, err)
}
}
if errors != nil {
log.Error("Error in Export execution")
}
} else {
if datasources {
err = exports.DataSources(username, password, url, directory)
if err != nil {
errors = append(errors, err)
}
}
if dashboards {
err = exports.Dashboards(username, password, url, directory)
if err != nil {
errors = append(errors, err)
}
err = exports.Folders(username, password, url, directory)
if err != nil {
errors = append(errors, err)
}
err = exports.LibraryPanels(username, password, url, directory)
if err != nil {
errors = append(errors, err)
}
}
if alerting {
err = exports.AlertRules(username, password, url, directory)
if err != nil {
errors = append(errors, err)
}
err = exports.ContactPoints(username, password, url, directory)
if err != nil {
errors = append(errors, err)
}
err = exports.NotificationPolicies(username, password, url, directory)
if err != nil {
errors = append(errors, err)
}
err = exports.NotificationTemplates(username, password, url, directory)
if err != nil {
errors = append(errors, err)
}
}
if errors != nil {
log.Error("Error in Restore execution")
}
}
}