Add helper methods in conditon_set (#965)

* added isUnknown in condition_set

* added IsFalse for condition set

* added GetHappyCondition

* modified comments

* modified the code based on cr

* renamed the method and removed isXXX() methods

* modified comments
This commit is contained in:
capri-xiyue 2020-01-06 08:00:49 -08:00 committed by Knative Prow Robot
parent ce9dfe90d1
commit fa1c639c93
1 changed files with 10 additions and 5 deletions

View File

@ -52,6 +52,9 @@ type ConditionManager interface {
// set to true.
IsHappy() bool
// GetTopLevelCondition finds and returns the top level Condition (happy Condition).
GetTopLevelCondition() *Condition
// GetCondition finds and returns the Condition that matches the ConditionType
// previously set on Conditions.
GetCondition(t ConditionType) *Condition
@ -139,13 +142,15 @@ func (r ConditionSet) Manage(status ConditionsAccessor) ConditionManager {
}
}
// IsHappy looks at the happy condition and returns true if that condition is
// IsHappy looks at the top level Condition (happy Condition) and returns true if that condition is
// set to true.
func (r conditionsImpl) IsHappy() bool {
if c := r.GetCondition(r.happy); c == nil || !c.IsTrue() {
return false
}
return true
return r.GetTopLevelCondition().IsTrue()
}
// GetTopLevelCondition finds and returns the top level Condition (happy Condition).
func (r conditionsImpl) GetTopLevelCondition() *Condition {
return r.GetCondition(r.happy)
}
// GetCondition finds and returns the Condition that matches the ConditionType