@@ -58,6 +58,28 @@ const (
5858 ReasonOpsCancelFailed = "CancelFailed"
5959 ReasonOpsCancelSucceed = "CancelSucceed"
6060 ReasonOpsCancelByController = "CancelByController"
61+
62+ // reasons emitted by NewXxxCondition constructors below. These were
63+ // previously inline string literals; centralized here so consumers
64+ // (Console, tests, lint analyzers in OPS-S1 Slice E) have a single
65+ // authoritative source. String values MUST remain stable — see
66+ // TestReasonConstantsStringDrift.
67+ ReasonValidateOpsRequestPassed = "ValidateOpsRequestPassed"
68+ ReasonOpsRequestProcessedSuccessfully = "OpsRequestProcessedSuccessfully"
69+ ReasonRestartStarted = "RestartStarted"
70+ ReasonStartToRebuildInstances = "StartToRebuildInstances"
71+ ReasonSwitchoverStarted = "SwitchoverStarted"
72+ ReasonVerticalScalingStarted = "VerticalScalingStarted"
73+ ReasonHorizontalScalingStarted = "HorizontalScalingStarted"
74+ ReasonVolumeExpansionStarted = "VolumeExpansionStarted"
75+ ReasonExposeStarted = "ExposeStarted"
76+ ReasonVersionUpgradeStarted = "VersionUpgradeStarted"
77+ ReasonStopStarted = "StopStarted"
78+ ReasonStartCluster = "StartCluster"
79+ ReasonReconfigureStarted = "ReconfigureStarted"
80+ ReasonReconfigureFailed = "ReconfigureFailed"
81+ ReasonBackupStarted = "BackupStarted"
82+ ReasonRestoreStarted = "RestoreStarted"
6183)
6284
6385func (r * OpsRequest ) SetStatusCondition (condition metav1.Condition ) {
@@ -130,7 +152,7 @@ func NewValidatePassedCondition(opsRequestName string) *metav1.Condition {
130152 return & metav1.Condition {
131153 Type : ConditionTypeValidated ,
132154 Status : metav1 .ConditionTrue ,
133- Reason : "ValidateOpsRequestPassed" ,
155+ Reason : ReasonValidateOpsRequestPassed ,
134156 LastTransitionTime : metav1 .Now (),
135157 Message : fmt .Sprintf ("OpsRequest: %s is validated" , opsRequestName ),
136158 }
@@ -167,7 +189,7 @@ func NewSucceedCondition(ops *OpsRequest) *metav1.Condition {
167189 return & metav1.Condition {
168190 Type : ConditionTypeSucceed ,
169191 Status : metav1 .ConditionTrue ,
170- Reason : "OpsRequestProcessedSuccessfully" ,
192+ Reason : ReasonOpsRequestProcessedSuccessfully ,
171193 LastTransitionTime : metav1 .Now (),
172194 Message : fmt .Sprintf ("Successfully processed the OpsRequest: %s in Cluster: %s" ,
173195 ops .Name , ops .Spec .GetClusterName ()),
@@ -179,7 +201,7 @@ func NewRestartingCondition(ops *OpsRequest) *metav1.Condition {
179201 return & metav1.Condition {
180202 Type : ConditionTypeRestarting ,
181203 Status : metav1 .ConditionTrue ,
182- Reason : "RestartStarted" ,
204+ Reason : ReasonRestartStarted ,
183205 LastTransitionTime : metav1 .Now (),
184206 Message : fmt .Sprintf ("Start to restart database in Cluster: %s" , ops .Spec .GetClusterName ()),
185207 }
@@ -190,7 +212,7 @@ func NewInstancesRebuildingCondition(ops *OpsRequest) *metav1.Condition {
190212 return & metav1.Condition {
191213 Type : ConditionTypeInstanceRebuilding ,
192214 Status : metav1 .ConditionTrue ,
193- Reason : "StartToRebuildInstances" ,
215+ Reason : ReasonStartToRebuildInstances ,
194216 LastTransitionTime : metav1 .Now (),
195217 Message : fmt .Sprintf ("Start to rebuild the instances in Cluster: %s" , ops .Spec .GetClusterName ()),
196218 }
@@ -201,7 +223,7 @@ func NewSwitchoveringCondition(generation int64, message string) *metav1.Conditi
201223 return & metav1.Condition {
202224 Type : ConditionTypeSwitchover ,
203225 Status : metav1 .ConditionTrue ,
204- Reason : "SwitchoverStarted" ,
226+ Reason : ReasonSwitchoverStarted ,
205227 LastTransitionTime : metav1 .Now (),
206228 Message : message ,
207229 ObservedGeneration : generation ,
@@ -213,7 +235,7 @@ func NewVerticalScalingCondition(ops *OpsRequest) *metav1.Condition {
213235 return & metav1.Condition {
214236 Type : ConditionTypeVerticalScaling ,
215237 Status : metav1 .ConditionTrue ,
216- Reason : "VerticalScalingStarted" ,
238+ Reason : ReasonVerticalScalingStarted ,
217239 LastTransitionTime : metav1 .Now (),
218240 Message : fmt .Sprintf ("Start to vertical scale resources in Cluster: %s" , ops .Spec .GetClusterName ()),
219241 }
@@ -224,7 +246,7 @@ func NewHorizontalScalingCondition(ops *OpsRequest) *metav1.Condition {
224246 return & metav1.Condition {
225247 Type : ConditionTypeHorizontalScaling ,
226248 Status : metav1 .ConditionTrue ,
227- Reason : "HorizontalScalingStarted" ,
249+ Reason : ReasonHorizontalScalingStarted ,
228250 LastTransitionTime : metav1 .Now (),
229251 Message : fmt .Sprintf ("Start to horizontal scale replicas in Cluster: %s" , ops .Spec .GetClusterName ()),
230252 }
@@ -235,7 +257,7 @@ func NewVolumeExpandingCondition(ops *OpsRequest) *metav1.Condition {
235257 return & metav1.Condition {
236258 Type : ConditionTypeVolumeExpanding ,
237259 Status : metav1 .ConditionTrue ,
238- Reason : "VolumeExpansionStarted" ,
260+ Reason : ReasonVolumeExpansionStarted ,
239261 LastTransitionTime : metav1 .Now (),
240262 Message : fmt .Sprintf ("Start to expand the volumes in Cluster: %s" , ops .Spec .GetClusterName ()),
241263 }
@@ -245,7 +267,7 @@ func NewExposingCondition(ops *OpsRequest) *metav1.Condition {
245267 return & metav1.Condition {
246268 Type : ConditionTypeExpose ,
247269 Status : metav1 .ConditionTrue ,
248- Reason : "ExposeStarted" ,
270+ Reason : ReasonExposeStarted ,
249271 LastTransitionTime : metav1 .Now (),
250272 Message : fmt .Sprintf ("Start to expose the services in Cluster: %s" , ops .Spec .GetClusterName ()),
251273 }
@@ -256,7 +278,7 @@ func NewUpgradingCondition(ops *OpsRequest) *metav1.Condition {
256278 return & metav1.Condition {
257279 Type : ConditionTypeVersionUpgrading ,
258280 Status : metav1 .ConditionTrue ,
259- Reason : "VersionUpgradeStarted" ,
281+ Reason : ReasonVersionUpgradeStarted ,
260282 LastTransitionTime : metav1 .Now (),
261283 Message : fmt .Sprintf ("Start to upgrade the version in Cluster: %s" , ops .Spec .GetClusterName ()),
262284 }
@@ -267,7 +289,7 @@ func NewStopCondition(ops *OpsRequest) *metav1.Condition {
267289 return & metav1.Condition {
268290 Type : ConditionTypeStop ,
269291 Status : metav1 .ConditionTrue ,
270- Reason : "StopStarted" ,
292+ Reason : ReasonStopStarted ,
271293 LastTransitionTime : metav1 .Now (),
272294 Message : fmt .Sprintf ("Start to stop the Cluster: %s" , ops .Spec .GetClusterName ()),
273295 }
@@ -278,7 +300,7 @@ func NewStartCondition(ops *OpsRequest) *metav1.Condition {
278300 return & metav1.Condition {
279301 Type : ConditionTypeStart ,
280302 Status : metav1 .ConditionTrue ,
281- Reason : "StartCluster" ,
303+ Reason : ReasonStartCluster ,
282304 LastTransitionTime : metav1 .Now (),
283305 Message : fmt .Sprintf ("Start the Cluster: %s" , ops .Spec .GetClusterName ()),
284306 }
@@ -289,7 +311,7 @@ func NewReconfigureCondition(ops *OpsRequest) *metav1.Condition {
289311 return & metav1.Condition {
290312 Type : ConditionTypeReconfigure ,
291313 Status : metav1 .ConditionTrue ,
292- Reason : "ReconfigureStarted" ,
314+ Reason : ReasonReconfigureStarted ,
293315 LastTransitionTime : metav1 .Now (),
294316 Message : fmt .Sprintf ("Start to reconfigure in Cluster: %s, Component: %s" ,
295317 ops .Spec .GetClusterName (),
@@ -338,7 +360,7 @@ func NewReconfigureFailedCondition(ops *OpsRequest, err error) *metav1.Condition
338360 return & metav1.Condition {
339361 Type : appsv1alpha1 .ReasonReconfigureFailed ,
340362 Status : metav1 .ConditionFalse ,
341- Reason : "ReconfigureFailed" ,
363+ Reason : ReasonReconfigureFailed ,
342364 LastTransitionTime : metav1 .Now (),
343365 Message : msg ,
344366 }
@@ -349,7 +371,7 @@ func NewBackupCondition(ops *OpsRequest) *metav1.Condition {
349371 return & metav1.Condition {
350372 Type : ConditionTypeBackup ,
351373 Status : metav1 .ConditionTrue ,
352- Reason : "BackupStarted" ,
374+ Reason : ReasonBackupStarted ,
353375 LastTransitionTime : metav1 .Now (),
354376 Message : fmt .Sprintf ("Start to backup the Cluster: %s" , ops .Spec .GetClusterName ()),
355377 }
@@ -360,7 +382,7 @@ func NewRestoreCondition(ops *OpsRequest) *metav1.Condition {
360382 return & metav1.Condition {
361383 Type : ConditionTypeBackup ,
362384 Status : metav1 .ConditionTrue ,
363- Reason : "RestoreStarted" ,
385+ Reason : ReasonRestoreStarted ,
364386 LastTransitionTime : metav1 .Now (),
365387 Message : fmt .Sprintf ("Start to restore the Cluster: %s" , ops .Spec .GetClusterName ()),
366388 }
0 commit comments