-
Notifications
You must be signed in to change notification settings - Fork 94
/
zync_rules.go
69 lines (54 loc) · 1.89 KB
/
zync_rules.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
package prometheusrules
import (
monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
appsv1alpha1 "github.com/3scale/3scale-operator/apis/apps/v1alpha1"
"github.com/3scale/3scale-operator/pkg/3scale/amp/component"
)
func init() {
PrometheusRuleFactories = append(PrometheusRuleFactories, NewZyncPrometheusRuleFactory)
}
type ZyncPrometheusRuleFactory struct {
}
func NewZyncPrometheusRuleFactory() PrometheusRuleFactory {
return &ZyncPrometheusRuleFactory{}
}
func (s *ZyncPrometheusRuleFactory) Type() string {
return "zync"
}
func (s *ZyncPrometheusRuleFactory) PrometheusRule(_ bool, ns string) *monitoringv1.PrometheusRule {
options, err := zyncOptions(ns)
if err != nil {
panic(err)
}
return component.NewZync(options).ZyncPrometheusRules()
}
func zyncOptions(ns string) (*component.ZyncOptions, error) {
o := component.NewZyncOptions()
// Required options for generating PrometheusRules
o.CommonLabels = commonZyncLabels()
o.Namespace = ns
// Required options for passing validation, but not needed for generating the prometheus rules
// To fix this, more granularity at options level.
o.CommonZyncLabels = map[string]string{}
o.CommonZyncQueLabels = map[string]string{}
o.CommonZyncDatabaseLabels = map[string]string{}
o.ZyncPodTemplateLabels = map[string]string{}
o.ZyncQuePodTemplateLabels = map[string]string{}
o.ZyncDatabasePodTemplateLabels = map[string]string{}
o.AuthenticationToken = "_"
o.DatabasePassword = "_"
o.SecretKeyBase = "_"
o.ImageTag = "_"
o.DatabaseImageTag = "_"
o.ZyncReplicas = 1
o.ZyncQueReplicas = 1
o.DatabaseURL = "_"
o.ZyncQueServiceAccountImagePullSecrets = component.DefaultZyncQueServiceAccountImagePullSecrets()
return o, o.Validate()
}
func commonZyncLabels() map[string]string {
return map[string]string{
"app": appsv1alpha1.Default3scaleAppLabel,
"threescale_component": "zync",
}
}