This repository has been archived by the owner on Apr 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
grafana.go
77 lines (70 loc) · 2.7 KB
/
grafana.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
package grafana
import (
"github.com/caos/orbos/internal/operator/boom/api/v1beta1/grafana/admin"
"github.com/caos/orbos/internal/operator/boom/api/v1beta1/grafana/auth"
"github.com/caos/orbos/internal/operator/boom/api/v1beta1/network"
"github.com/caos/orbos/internal/operator/boom/api/v1beta1/storage"
)
type Grafana struct {
//Flag if tool should be deployed
//@default: false
Deploy bool `json:"deploy" yaml:"deploy"`
//Spec for the definition of the admin account
Admin *admin.Admin `json:"admin,omitempty" yaml:"admin,omitempty"`
//Spec for additional datasources
Datasources []*Datasource `json:"datasources,omitempty" yaml:"datasources,omitempty"`
//Spec for additional Dashboardproviders
DashboardProviders []*Provider `json:"dashboardproviders,omitempty" yaml:"dashboardproviders,omitempty"`
//Spec to define how the persistence should be handled
Storage *storage.Spec `json:"storage,omitempty" yaml:"storage,omitempty"`
//Network configuration, used for SSO and external access
Network *network.Network `json:"network,omitempty" yaml:"network,omitempty"`
//Authorization and Authentication configuration for SSO
Auth *auth.Auth `json:"auth,omitempty" yaml:"auth,omitempty"`
//List of plugins which get added to the grafana instance
Plugins []string `json:"plugins,omitempty" yaml:"plugins,omitempty"`
//NodeSelector for deployment
NodeSelector map[string]string `json:"nodeSelector,omitempty" yaml:"nodeSelector,omitempty"`
}
func (g *Grafana) InitSecrets() {
if g.Admin == nil {
g.Admin = &admin.Admin{}
}
g.Admin.InitSecrets()
if g.Auth == nil {
g.Auth = &auth.Auth{}
}
g.Auth.InitSecrets()
}
func (m *Grafana) IsZero() bool {
if !m.Deploy &&
(m.Admin == nil || m.Admin.IsZero()) &&
(m.Auth == nil || m.Auth.IsZero()) &&
m.Datasources == nil &&
m.DashboardProviders == nil &&
m.Storage == nil &&
m.Network == nil &&
m.Plugins == nil &&
m.NodeSelector == nil {
return true
}
return false
}
type Datasource struct {
//Name of the datasource
Name string `json:"name,omitempty" yaml:"name,omitempty"`
//Type of the datasource (for example prometheus)
Type string `json:"type,omitempty" yaml:"type,omitempty"`
//URL to the datasource
Url string `json:"url,omitempty" yaml:"url,omitempty"`
//Access defintion of the datasource
Access string `json:"access,omitempty" yaml:"access,omitempty"`
//Boolean if datasource should be used as default
IsDefault bool `json:"isDefault,omitempty" yaml:"isDefault,omitempty"`
}
type Provider struct {
//ConfigMaps in which the dashboards are stored
ConfigMaps []string `json:"configMaps,omitempty" yaml:"configMaps,omitempty"`
//Local folder in which the dashboards are mounted
Folder string `json:"folder,omitempty" yaml:"folder,omitempty"`
}