@@ -3,9 +3,7 @@ package k8s
33import (
44 "context"
55
6- osmv1 "github.com/openshift/api/monitoring/v1"
76 monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
8- "github.com/prometheus/prometheus/model/relabel"
97 "k8s.io/apimachinery/pkg/types"
108)
119
@@ -21,23 +19,29 @@ type Client interface {
2119 // TestConnection tests the connection to the Kubernetes cluster
2220 TestConnection (ctx context.Context ) error
2321
24- // PrometheusAlerts retrieves active Prometheus alerts
25- PrometheusAlerts () PrometheusAlertsInterface
26-
2722 // PrometheusRules returns the PrometheusRule interface
2823 PrometheusRules () PrometheusRuleInterface
2924
30- // AlertRelabelConfigs returns the AlertRelabelConfig interface
31- AlertRelabelConfigs () AlertRelabelConfigInterface
25+ // Namespace returns the Namespace interface
26+ Namespace () NamespaceInterface
27+ }
3228
33- // AlertingRules returns the AlertingRule interface
34- AlertingRules () AlertingRuleInterface
29+ // PrometheusRuleInterface defines operations for managing PrometheusRules
30+ type PrometheusRuleInterface interface {
31+ // List lists all PrometheusRules in the cluster
32+ List (ctx context.Context , namespace string ) ([]monitoringv1.PrometheusRule , error )
3533
36- // RelabeledRules returns the RelabeledRules interface
37- RelabeledRules () RelabeledRulesInterface
34+ // Get retrieves a PrometheusRule by namespace and name
35+ Get ( ctx context. Context , namespace string , name string ) ( * monitoringv1. PrometheusRule , bool , error )
3836
39- // Namespace returns the Namespace interface
40- Namespace () NamespaceInterface
37+ // Update updates an existing PrometheusRule
38+ Update (ctx context.Context , pr monitoringv1.PrometheusRule ) error
39+
40+ // Delete deletes a PrometheusRule by namespace and name
41+ Delete (ctx context.Context , namespace string , name string ) error
42+
43+ // AddRule adds a new rule to the specified PrometheusRule
44+ AddRule (ctx context.Context , namespacedName types.NamespacedName , groupName string , rule monitoringv1.Rule ) error
4145}
4246
4347// RouteStatus describes the availability state of a monitoring route.
@@ -71,81 +75,6 @@ type AlertingHealth struct {
7175 UserWorkload * AlertingStackHealth `json:"userWorkload"`
7276}
7377
74- // PrometheusAlertsInterface defines operations for managing PrometheusAlerts
75- type PrometheusAlertsInterface interface {
76- // GetAlerts retrieves Prometheus alerts with optional state filtering
77- GetAlerts (ctx context.Context , req GetAlertsRequest ) ([]PrometheusAlert , error )
78- // GetRules retrieves Prometheus alerting rules and active alerts
79- GetRules (ctx context.Context , req GetRulesRequest ) ([]PrometheusRuleGroup , error )
80- }
81-
82- // PrometheusRuleInterface defines operations for managing PrometheusRules
83- type PrometheusRuleInterface interface {
84- // List lists all PrometheusRules in the cluster
85- List (ctx context.Context , namespace string ) ([]monitoringv1.PrometheusRule , error )
86-
87- // Get retrieves a PrometheusRule by namespace and name
88- Get (ctx context.Context , namespace string , name string ) (* monitoringv1.PrometheusRule , bool , error )
89-
90- // Update updates an existing PrometheusRule
91- Update (ctx context.Context , pr monitoringv1.PrometheusRule ) error
92-
93- // Delete deletes a PrometheusRule by namespace and name
94- Delete (ctx context.Context , namespace string , name string ) error
95-
96- // AddRule adds a new rule to the specified PrometheusRule
97- AddRule (ctx context.Context , namespacedName types.NamespacedName , groupName string , rule monitoringv1.Rule ) error
98- }
99-
100- // AlertRelabelConfigInterface defines operations for managing AlertRelabelConfigs
101- type AlertRelabelConfigInterface interface {
102- // List lists all AlertRelabelConfigs in the cluster
103- List (ctx context.Context , namespace string ) ([]osmv1.AlertRelabelConfig , error )
104-
105- // Get retrieves an AlertRelabelConfig by namespace and name
106- Get (ctx context.Context , namespace string , name string ) (* osmv1.AlertRelabelConfig , bool , error )
107-
108- // Create creates a new AlertRelabelConfig
109- Create (ctx context.Context , arc osmv1.AlertRelabelConfig ) (* osmv1.AlertRelabelConfig , error )
110-
111- // Update updates an existing AlertRelabelConfig
112- Update (ctx context.Context , arc osmv1.AlertRelabelConfig ) error
113-
114- // Delete deletes an AlertRelabelConfig by namespace and name
115- Delete (ctx context.Context , namespace string , name string ) error
116- }
117-
118- // AlertingRuleInterface defines operations for managing AlertingRules
119- // in the cluster monitoring namespace
120- type AlertingRuleInterface interface {
121- // List lists all AlertingRules in the cluster
122- List (ctx context.Context ) ([]osmv1.AlertingRule , error )
123-
124- // Get retrieves an AlertingRule by name
125- Get (ctx context.Context , name string ) (* osmv1.AlertingRule , bool , error )
126-
127- // Create creates a new AlertingRule
128- Create (ctx context.Context , ar osmv1.AlertingRule ) (* osmv1.AlertingRule , error )
129-
130- // Update updates an existing AlertingRule
131- Update (ctx context.Context , ar osmv1.AlertingRule ) error
132-
133- // Delete deletes an AlertingRule by name
134- Delete (ctx context.Context , name string ) error
135- }
136-
137- // RelabeledRulesInterface defines operations for managing relabeled rules
138- type RelabeledRulesInterface interface {
139- // List retrieves the relabeled rules for a given PrometheusRule
140- List (ctx context.Context ) []monitoringv1.Rule
141-
142- // Get retrieves the relabeled rule for a given id
143- Get (ctx context.Context , id string ) (monitoringv1.Rule , bool )
144-
145- // Config returns the list of alert relabel configs
146- Config () []* relabel.Config
147- }
148-
14978// NamespaceInterface defines operations for Namespaces
15079type NamespaceInterface interface {
15180 // IsClusterMonitoringNamespace checks if a namespace has the openshift.io/cluster-monitoring=true label
0 commit comments