1
+ /*
2
+ Copyright 2024.
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
1
17
package controller
2
18
3
19
import (
@@ -7,38 +23,101 @@ import (
7
23
v1alpha1 "prosimcorp.com/SearchRuler/api/v1alpha1"
8
24
)
9
25
10
- func (r * SearchRuleReconciler ) UpdateConditionSuccess (searchRule * v1alpha1.SearchRule ) {
26
+ // UpdateConditionSuccess updates the status of the SearchRule resource with a success condition
27
+ func (r * SearchRuleReconciler ) UpdateConditionSuccess (SearchRule * v1alpha1.SearchRule ) {
11
28
12
- //
29
+ // Create the new condition with the success status
13
30
condition := globals .NewCondition (globals .ConditionTypeResourceSynced , metav1 .ConditionTrue ,
14
31
globals .ConditionReasonTargetSynced , globals .ConditionReasonTargetSyncedMessage )
15
32
16
- globals .UpdateCondition (& searchRule .Status .Conditions , condition )
33
+ // Update the status of the SearchRule resource
34
+ globals .UpdateCondition (& SearchRule .Status .Conditions , condition )
17
35
}
18
36
19
- func (r * SearchRuleReconciler ) UpdateConditionKubernetesApiCallFailure (searchRule * v1alpha1.SearchRule ) {
37
+ // UpdateConditionKubernetesApiCallFailure updates the status of the SearchRule resource with a failure condition
38
+ func (r * SearchRuleReconciler ) UpdateConditionKubernetesApiCallFailure (SearchRule * v1alpha1.SearchRule ) {
20
39
21
- //
40
+ // Create the new condition with the failure status
22
41
condition := globals .NewCondition (globals .ConditionTypeResourceSynced , metav1 .ConditionTrue ,
23
42
globals .ConditionReasonKubernetesApiCallErrorType , globals .ConditionReasonKubernetesApiCallErrorMessage )
24
43
44
+ // Update the status of the SearchRule resource
45
+ globals .UpdateCondition (& SearchRule .Status .Conditions , condition )
46
+ }
47
+
48
+ // Note: No state status means no alert fired never for this rule
49
+ // UpdateConditionNoCredsFound updates the status of the SearchRule resource with alert firing condition
50
+ func (r * SearchRuleReconciler ) UpdateConditionAlertFiring (searchRule * v1alpha1.SearchRule ) {
51
+
52
+ // Create the new condition with the alert firing status
53
+ condition := globals .NewCondition (globals .ConditionTypeState , metav1 .ConditionTrue ,
54
+ globals .ConditionReasonAlertFiring , globals .ConditionReasonAlertFiringMessage )
55
+
56
+ // Update the status of the SearchRule resource
25
57
globals .UpdateCondition (& searchRule .Status .Conditions , condition )
26
58
}
27
59
28
- func (r * SearchRuleReconciler ) UpdateConditionAlertFiring (searchRule * v1alpha1.SearchRule , conditionReasonAlertFiringMessage string ) {
60
+ // UpdateConditionNoCredsFound updates the status of the SearchRule resource with alert resolved condition
61
+ func (r * SearchRuleReconciler ) UpdateConditionAlertResolved (searchRule * v1alpha1.SearchRule ) {
29
62
30
- //
63
+ // Create the new condition with the alert resolved status
31
64
condition := globals .NewCondition (globals .ConditionTypeState , metav1 .ConditionTrue ,
32
- globals .ConditionReasonAlertFiring , conditionReasonAlertFiringMessage )
65
+ globals .ConditionReasonAlertResolved , globals . ConditionReasonAlertResolvedMessage )
33
66
67
+ // Update the status of the SearchRule resource
34
68
globals .UpdateCondition (& searchRule .Status .Conditions , condition )
35
69
}
36
70
37
- func (r * SearchRuleReconciler ) UpdateConditionAlertResolved (searchRule * v1alpha1.SearchRule , conditionReasonAlertResolvedMessage string ) {
71
+ // UpdateConditionConnectionError updates the status of the SearchRule resource with a QueryConnector not found condition
72
+ func (r * SearchRuleReconciler ) UpdateConditionQueryConnectorNotFound (searchRule * v1alpha1.SearchRule ) {
38
73
39
- //
74
+ // Create the new condition with the alert firing status
40
75
condition := globals .NewCondition (globals .ConditionTypeState , metav1 .ConditionTrue ,
41
- globals .ConditionReasonAlertResolved , conditionReasonAlertResolvedMessage )
76
+ globals .ConditionReasonQueryConnectorNotFoundType , globals . ConditionReasonQueryConnectorNotFoundMessage )
42
77
78
+ // Update the status of the SearchRule resource
43
79
globals .UpdateCondition (& searchRule .Status .Conditions , condition )
44
80
}
81
+
82
+ // UpdateConditionNoCredsFound updates the status of the SearchRule resource with a NoCreds condition
83
+ func (r * SearchRuleReconciler ) UpdateConditionNoCredsFound (SearchRule * v1alpha1.SearchRule ) {
84
+
85
+ // Create the new condition with the success status
86
+ condition := globals .NewCondition (globals .ConditionTypeState , metav1 .ConditionTrue ,
87
+ globals .ConditionReasonNoCredsFoundType , globals .ConditionReasonNoCredsFoundMessage )
88
+
89
+ // Update the status of the SearchRule resource
90
+ globals .UpdateCondition (& SearchRule .Status .Conditions , condition )
91
+ }
92
+
93
+ func (r * SearchRuleReconciler ) UpdateConditionNoQueryFound (SearchRule * v1alpha1.SearchRule ) {
94
+
95
+ // Create the new condition with the success status
96
+ condition := globals .NewCondition (globals .ConditionTypeState , metav1 .ConditionTrue ,
97
+ globals .ConditionReasonNoQueryFoundType , globals .ConditionReasonNoQueryFoundMessage )
98
+
99
+ // Update the status of the SearchRule resource
100
+ globals .UpdateCondition (& SearchRule .Status .Conditions , condition )
101
+ }
102
+
103
+ // UpdateConditionConnectionError updates the status of the SearchRule resource with a ConnectionError condition
104
+ func (r * SearchRuleReconciler ) UpdateConditionConnectionError (SearchRule * v1alpha1.SearchRule ) {
105
+
106
+ // Create the new condition with the failure status
107
+ condition := globals .NewCondition (globals .ConditionTypeState , metav1 .ConditionTrue ,
108
+ globals .ConditionReasonConnectionErrorType , globals .ConditionReasonConnectionErrorMessage )
109
+
110
+ // Update the status of the SearchRule resource
111
+ globals .UpdateCondition (& SearchRule .Status .Conditions , condition )
112
+ }
113
+
114
+ // UpdateConditionEvaluateTemplateError updates the status of the SearchRule resource with a QueryError condition
115
+ func (r * SearchRuleReconciler ) UpdateConditionQueryError (SearchRule * v1alpha1.SearchRule ) {
116
+
117
+ // Create the new condition with the failure status
118
+ condition := globals .NewCondition (globals .ConditionTypeState , metav1 .ConditionTrue ,
119
+ globals .ConditionReasonQueryErrorType , globals .ConditionReasonQueryErrorMessage )
120
+
121
+ // Update the status of the SearchRule resource
122
+ globals .UpdateCondition (& SearchRule .Status .Conditions , condition )
123
+ }
0 commit comments