Refactor branching logic when using an early return

This commit is contained in:
Joshua Casey
2024-08-07 12:23:11 -05:00
parent 4a9136040c
commit 4bd5db14b4

View File

@@ -67,11 +67,12 @@ func mergeCondition(existingConditionsToUpdate *[]metav1.Condition, newCondition
// If there is no existing condition of this type, append this one and we're done.
*existingConditionsToUpdate = append(*existingConditionsToUpdate, *newCondition)
return true
} else {
existingCondition = &(*existingConditionsToUpdate)[index]
}
// Set the LastTransitionTime depending on whether the status has changed.
// Get a pointer to the existing condition
existingCondition = &(*existingConditionsToUpdate)[index]
// If the status has not changed, preserve the original lastTransitionTime
if newCondition.Status == existingCondition.Status {
newCondition.LastTransitionTime = existingCondition.LastTransitionTime
}