mirror of https://github.com/knative/pkg.git
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:
parent
ce9dfe90d1
commit
fa1c639c93
|
@ -52,6 +52,9 @@ type ConditionManager interface {
|
||||||
// set to true.
|
// set to true.
|
||||||
IsHappy() bool
|
IsHappy() bool
|
||||||
|
|
||||||
|
// GetTopLevelCondition finds and returns the top level Condition (happy Condition).
|
||||||
|
GetTopLevelCondition() *Condition
|
||||||
|
|
||||||
// GetCondition finds and returns the Condition that matches the ConditionType
|
// GetCondition finds and returns the Condition that matches the ConditionType
|
||||||
// previously set on Conditions.
|
// previously set on Conditions.
|
||||||
GetCondition(t ConditionType) *Condition
|
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.
|
// set to true.
|
||||||
func (r conditionsImpl) IsHappy() bool {
|
func (r conditionsImpl) IsHappy() bool {
|
||||||
if c := r.GetCondition(r.happy); c == nil || !c.IsTrue() {
|
return r.GetTopLevelCondition().IsTrue()
|
||||||
return false
|
}
|
||||||
}
|
|
||||||
return true
|
// 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
|
// GetCondition finds and returns the Condition that matches the ConditionType
|
||||||
|
|
Loading…
Reference in New Issue