diff --git a/apis/condition_set.go b/apis/condition_set.go index 7f1917e89..eba01e94b 100644 --- a/apis/condition_set.go +++ b/apis/condition_set.go @@ -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