@@ -77,7 +77,7 @@ func (c ConditionSet) List() []Condition {
77
77
return c .object .GetConditions ()
78
78
}
79
79
80
- // GetCondition finds and returns the Condition that matches the ConditionType
80
+ // Get finds and returns the Condition that matches the ConditionType
81
81
// previously set on Conditions.
82
82
func (c ConditionSet ) Get (t string ) * Condition {
83
83
if c .object == nil {
@@ -89,7 +89,7 @@ func (c ConditionSet) Get(t string) *Condition {
89
89
return nil
90
90
}
91
91
92
- // True returns true if all condition types are true.
92
+ // IsTrue returns true if all condition types are true.
93
93
func (c ConditionSet ) IsTrue (conditionTypes ... string ) bool {
94
94
for _ , conditionType := range conditionTypes {
95
95
if ! c .Get (conditionType ).IsTrue () {
@@ -126,7 +126,7 @@ func (c ConditionSet) Set(condition Condition) (modified bool) {
126
126
return true
127
127
}
128
128
129
- // RemoveCondition removes the non normal condition that matches the ConditionType
129
+ // Clear removes the abnormal condition that matches the ConditionType
130
130
// Not implemented for normal conditions
131
131
func (c ConditionSet ) Clear (t string ) error {
132
132
var conditions []Condition
@@ -155,13 +155,13 @@ func (c ConditionSet) Clear(t string) error {
155
155
return nil
156
156
}
157
157
158
- // SetTrue sets the status of t to true with the reason, and then marks the root condition to
158
+ // SetTrue sets the status of conditionType to true with the reason, and then marks the root condition to
159
159
// true if all other dependents are also true.
160
160
func (c ConditionSet ) SetTrue (conditionType string ) (modified bool ) {
161
161
return c .SetTrueWithReason (conditionType , conditionType , "" )
162
162
}
163
163
164
- // SetTrueWithReason sets the status of t to true with the reason, and then marks the root condition to
164
+ // SetTrueWithReason sets the status of conditionType to true with the reason, and then marks the root condition to
165
165
// true if all other dependents are also true.
166
166
func (c ConditionSet ) SetTrueWithReason (conditionType string , reason , message string ) (modified bool ) {
167
167
return c .Set (Condition {
@@ -174,19 +174,24 @@ func (c ConditionSet) SetTrueWithReason(conditionType string, reason, message st
174
174
175
175
// SetUnknown sets the status of conditionType to Unknown and also sets the root condition
176
176
// to Unknown if no other dependent condition is in an error state.
177
- func (r ConditionSet ) SetUnknown (conditionType string ) (modified bool ) {
178
- // set the specified condition
179
- return r .Set (Condition {
177
+ func (c ConditionSet ) SetUnknown (conditionType string ) (modified bool ) {
178
+ return c .SetUnknownWithReason (conditionType , "AwaitingReconciliation" , "object is awaiting reconciliation" )
179
+ }
180
+
181
+ // SetUnknownWithReason sets the status of conditionType to Unknown with the reason, and also sets the root condition
182
+ // to Unknown if no other dependent condition is in an error state.
183
+ func (c ConditionSet ) SetUnknownWithReason (conditionType string , reason , message string ) (modified bool ) {
184
+ return c .Set (Condition {
180
185
Type : conditionType ,
181
186
Status : metav1 .ConditionUnknown ,
182
- Reason : "AwaitingReconciliation" ,
183
- Message : "object is awaiting reconciliation" ,
187
+ Reason : reason ,
188
+ Message : message ,
184
189
})
185
190
}
186
191
187
- // SetFalse sets the status of t and the root condition to False.
188
- func (r ConditionSet ) SetFalse (conditionType string , reason , message string ) (modified bool ) {
189
- return r .Set (Condition {
192
+ // SetFalse sets the status of conditionType and the root condition to False.
193
+ func (c ConditionSet ) SetFalse (conditionType string , reason , message string ) (modified bool ) {
194
+ return c .Set (Condition {
190
195
Type : conditionType ,
191
196
Status : metav1 .ConditionFalse ,
192
197
Reason : reason ,
@@ -195,15 +200,15 @@ func (r ConditionSet) SetFalse(conditionType string, reason, message string) (mo
195
200
}
196
201
197
202
// recomputeRootCondition marks the root condition to true if all other dependents are also true.
198
- func (r ConditionSet ) recomputeRootCondition (conditionType string ) {
199
- if conditionType == r .root {
203
+ func (c ConditionSet ) recomputeRootCondition (conditionType string ) {
204
+ if conditionType == c .root {
200
205
return
201
206
}
202
- if conditions := r .findUnhealthyDependents (); len (conditions ) == 0 {
203
- r .SetTrue (r .root )
207
+ if conditions := c .findUnhealthyDependents (); len (conditions ) == 0 {
208
+ c .SetTrue (c .root )
204
209
} else {
205
- r .Set (Condition {
206
- Type : r .root ,
210
+ c .Set (Condition {
211
+ Type : c .root ,
207
212
// The root condition is no longer unknown as soon as any are false
208
213
Status : lo .Ternary (
209
214
lo .ContainsBy (conditions , func (condition Condition ) bool { return condition .IsFalse () }),
0 commit comments