Skip to content

Commit 998c1c3

Browse files
Per G. da Silvaclaude
andcommitted
🌱 Address lint findings in ClusterObjectSet Ready condition work
Convert ceConditionsFromReady to unnamed returns (nonamedreturns) and drop the unused bool return from setReadyProgressing (unparam). Also document that ceProgressingFromReady's Archived reason has no meaningful Progressing mapping and must be guarded by callers. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Per G. da Silva <pegoncal@redhat.com>
1 parent 35d12e5 commit 998c1c3

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

‎internal/object-controller/controllers/clusterobjectset_controller.go‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -651,13 +651,14 @@ func setReady(cos *ocv1.ClusterObjectSet, status metav1.ConditionStatus, reason,
651651
// progress deadline. When the deadline is exceeded it overrides the given
652652
// (status, reason) with False/ProgressDeadlineExceeded. Callers that must take
653653
// precedence over the deadline (Blocked, Archived) call setReady directly.
654-
func setReadyProgressing(l logr.Logger, cos *ocv1.ClusterObjectSet, status metav1.ConditionStatus, reason, message string, isDeadlineExceeded bool) bool {
654+
func setReadyProgressing(l logr.Logger, cos *ocv1.ClusterObjectSet, status metav1.ConditionStatus, reason, message string, isDeadlineExceeded bool) {
655655
if isDeadlineExceeded {
656656
l.V(1).Info("progress deadline exceeded", "priorReason", reason)
657-
return setReady(cos, metav1.ConditionFalse, ocv1.ClusterObjectSetReasonProgressDeadlineExceeded,
657+
setReady(cos, metav1.ConditionFalse, ocv1.ClusterObjectSetReasonProgressDeadlineExceeded,
658658
fmt.Sprintf("Revision has not rolled out for %d minute(s). Last status: %s", cos.Spec.ProgressDeadlineMinutes, message))
659+
return
659660
}
660-
return setReady(cos, status, reason, message)
661+
setReady(cos, status, reason, message)
661662
}
662663

663664
// computePhaseDigest computes a deterministic SHA-256 digest of a phase's

‎internal/operator-controller/controllers/boxcutter_reconcile_steps.go‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ const ceAvailableConditionType = "Available"
107107

108108
// ceProgressingFromReady maps a revision's Ready condition reason onto the
109109
// ClusterExtension's Progressing (status, reason).
110+
//
111+
// The Archived reason has no meaningful Progressing mapping: callers must not
112+
// apply the returned value when ready.Reason is ClusterObjectSetReasonArchived
113+
// (an archived revision leaves the ClusterExtension's Progressing condition
114+
// untouched). It therefore falls through to the default here.
110115
func ceProgressingFromReady(ready metav1.Condition) (metav1.ConditionStatus, string) {
111116
switch ready.Reason {
112117
case ocv1.ClusterObjectSetReasonReady:
@@ -126,13 +131,13 @@ func ceProgressingFromReady(ready metav1.Condition) (metav1.ConditionStatus, str
126131

127132
// ceConditionsFromReady returns the ClusterExtension Available (Ready retyped)
128133
// and Progressing (derived) conditions for a revision's Ready condition.
129-
func ceConditionsFromReady(ready metav1.Condition, generation int64) (available, progressing metav1.Condition) {
130-
available = ready
134+
func ceConditionsFromReady(ready metav1.Condition, generation int64) (metav1.Condition, metav1.Condition) {
135+
available := ready
131136
available.Type = ceAvailableConditionType
132137
available.ObservedGeneration = generation
133138

134139
ps, pr := ceProgressingFromReady(ready)
135-
progressing = metav1.Condition{
140+
progressing := metav1.Condition{
136141
Type: ocv1.TypeProgressing,
137142
Status: ps,
138143
Reason: pr,

0 commit comments

Comments
 (0)