@@ -96,12 +96,13 @@ type Condition struct {
9696}
9797
9898// Equal returns true if the condition is identical to the supplied condition,
99- // ignoring the LastTransitionTime and ObservedGeneration .
99+ // ignoring the LastTransitionTime.
100100func (c Condition ) Equal (other Condition ) bool {
101101 return c .Type == other .Type &&
102102 c .Status == other .Status &&
103103 c .Reason == other .Reason &&
104- c .Message == other .Message
104+ c .Message == other .Message &&
105+ c .ObservedGeneration == other .ObservedGeneration
105106}
106107
107108// WithMessage returns a condition by adding the provided message to existing
@@ -167,28 +168,24 @@ func (s *ConditionedStatus) GetCondition(ct ConditionType) Condition {
167168// SetConditions sets the supplied conditions, replacing any existing conditions
168169// of the same type. This is a no-op if all supplied conditions are identical,
169170// ignoring the last transition time, to those already set.
170- // Observed generation is updated if higher than the existing one.
171171func (s * ConditionedStatus ) SetConditions (c ... Condition ) {
172- for _ , new := range c {
172+ for _ , cond := range c {
173173 exists := false
174174 for i , existing := range s .Conditions {
175- if existing .Type != new .Type {
175+ if existing .Type != cond .Type {
176176 continue
177177 }
178178
179- if existing .Equal (new ) {
179+ if existing .Equal (cond ) {
180180 exists = true
181- if existing .ObservedGeneration < new .ObservedGeneration {
182- existing .ObservedGeneration = new .ObservedGeneration
183- }
184181 continue
185182 }
186183
187- s .Conditions [i ] = new
184+ s .Conditions [i ] = cond
188185 exists = true
189186 }
190187 if ! exists {
191- s .Conditions = append (s .Conditions , new )
188+ s .Conditions = append (s .Conditions , cond )
192189 }
193190 }
194191}
0 commit comments