@@ -22,7 +22,7 @@ package v1
2222
2323import (
2424 "github.com/arangodb/kube-arangodb/pkg/util"
25- v1 "k8s.io/api/core/v1"
25+ core "k8s.io/api/core/v1"
2626 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2727)
2828
@@ -102,7 +102,7 @@ type Condition struct {
102102 // Type of condition.
103103 Type ConditionType `json:"type"`
104104 // Status of the condition, one of True, False, Unknown.
105- Status v1 .ConditionStatus `json:"status"`
105+ Status core .ConditionStatus `json:"status"`
106106 // The last time this condition was updated.
107107 LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty"`
108108 // Last time the condition transitioned from one status to another.
@@ -116,7 +116,18 @@ type Condition struct {
116116}
117117
118118func (c Condition ) IsTrue () bool {
119- return c .Status == v1 .ConditionTrue
119+ return c .Status == core .ConditionTrue
120+ }
121+
122+ // Equal checks for equality
123+ func (c Condition ) Equal (other Condition ) bool {
124+ return c .Type == other .Type &&
125+ c .Status == other .Status &&
126+ util .TimeCompareEqual (c .LastUpdateTime , other .LastUpdateTime ) &&
127+ util .TimeCompareEqual (c .LastTransitionTime , other .LastTransitionTime ) &&
128+ c .Reason == other .Reason &&
129+ c .Message == other .Message &&
130+ c .Hash == other .Hash
120131}
121132
122133// ConditionList is a list of conditions.
@@ -143,30 +154,20 @@ func (list ConditionList) Equal(other ConditionList) bool {
143154 return true
144155}
145156
146- // Equal checks for equality
147- func (c Condition ) Equal (other Condition ) bool {
148- return c .Type == other .Type &&
149- c .Status == other .Status &&
150- util .TimeCompareEqual (c .LastUpdateTime , other .LastUpdateTime ) &&
151- util .TimeCompareEqual (c .LastTransitionTime , other .LastTransitionTime ) &&
152- c .Reason == other .Reason &&
153- c .Message == other .Message &&
154- c .Hash == other .Hash
155- }
156-
157157// IsTrue return true when a condition with given type exists and its status is `True`.
158158func (list ConditionList ) IsTrue (conditionType ConditionType ) bool {
159159 c , found := list .Get (conditionType )
160160 return found && c .IsTrue ()
161161}
162162
163- // GetValue returns *bool value in case if condition exists, nil otherwise
164- func (list ConditionList ) GetValue (conditionType ConditionType ) * bool {
165- c , found := list .Get (conditionType )
166- if found {
167- return util .NewBool (c .IsTrue ())
163+ // Check create a condition checker.
164+ func (list ConditionList ) Check (conditionType ConditionType ) ConditionCheck {
165+ c , ok := list .Get (conditionType )
166+
167+ return conditionCheck {
168+ condition : c ,
169+ exists : ok ,
168170 }
169- return nil
170171}
171172
172173// Get a condition by type.
@@ -211,9 +212,9 @@ func (list ConditionList) Index(conditionType ConditionType) int {
211212
212213func (list * ConditionList ) update (conditionType ConditionType , status bool , reason , message , hash string ) bool {
213214 src := * list
214- statusX := v1 .ConditionFalse
215+ statusX := core .ConditionFalse
215216 if status {
216- statusX = v1 .ConditionTrue
217+ statusX = core .ConditionTrue
217218 }
218219
219220 index := list .Index (conditionType )
0 commit comments