-
Notifications
You must be signed in to change notification settings - Fork 94
/
apicast_rules.go
67 lines (52 loc) · 2.03 KB
/
apicast_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
package prometheusrules
import (
monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
"github.com/3scale/3scale-operator/apis/apps"
appsv1alpha1 "github.com/3scale/3scale-operator/apis/apps/v1alpha1"
"github.com/3scale/3scale-operator/pkg/3scale/amp/component"
)
func init() {
PrometheusRuleFactories = append(PrometheusRuleFactories, NewApicastPrometheusRuleFactory)
}
type ApicastPrometheusRuleFactory struct {
}
func NewApicastPrometheusRuleFactory() PrometheusRuleFactory {
return &ApicastPrometheusRuleFactory{}
}
func (b *ApicastPrometheusRuleFactory) Type() string {
return "apicast"
}
func (b *ApicastPrometheusRuleFactory) PrometheusRule(_ bool, ns string) *monitoringv1.PrometheusRule {
options, err := apicastOptions(ns)
if err != nil {
panic(err)
}
return component.NewApicast(options).ApicastPrometheusRules()
}
func apicastOptions(ns string) (*component.ApicastOptions, error) {
o := component.NewApicastOptions()
// Required options for generating PrometheusRules
o.CommonLabels = commonApicastLabels()
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.ManagementAPI = "_"
o.OpenSSLVerify = "_"
o.ResponseCodes = "_"
o.ImageTag = "_"
o.CommonStagingLabels = map[string]string{}
o.CommonProductionLabels = map[string]string{}
o.StagingPodTemplateLabels = map[string]string{}
o.ProductionPodTemplateLabels = map[string]string{}
o.StagingTracingConfig = &component.APIcastTracingConfig{TracingLibrary: apps.APIcastDefaultTracingLibrary}
o.ProductionTracingConfig = &component.APIcastTracingConfig{TracingLibrary: apps.APIcastDefaultTracingLibrary}
o.StagingAdditionalPodAnnotations = map[string]string{}
o.ProductionAdditionalPodAnnotations = map[string]string{}
return o, o.Validate()
}
func commonApicastLabels() map[string]string {
return map[string]string{
"app": appsv1alpha1.Default3scaleAppLabel,
"threescale_component": "apicast",
}
}