Skip to content

Commit fd95800

Browse files
tangboxuanagaudreault
authored andcommitted
refactor: Improve checkResourceStatus readability (argoproj#21260)
Signed-off-by: Boxuan Tang <tangboxuan@google.com> Signed-off-by: Alexandre Gaudreault <alexandre_gaudreault@intuit.com> Co-authored-by: Alexandre Gaudreault <alexandre_gaudreault@intuit.com> Signed-off-by: dsuhinin <suhinin.dmitriy@gmail.com>
1 parent 89710ff commit fd95800

1 file changed

Lines changed: 13 additions & 21 deletions

File tree

cmd/argocd/commands/app.go

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2520,29 +2520,21 @@ func checkResourceStatus(watch watchOpts, healthStatus string, syncStatus string
25202520
if watch.delete {
25212521
return false
25222522
}
2523+
2524+
healthBeingChecked := watch.suspended || watch.health || watch.degraded
25232525
healthCheckPassed := true
25242526

2525-
switch {
2526-
case watch.suspended && watch.health && watch.degraded:
2527-
healthCheckPassed = healthStatus == string(health.HealthStatusHealthy) ||
2528-
healthStatus == string(health.HealthStatusSuspended) ||
2529-
healthStatus == string(health.HealthStatusDegraded)
2530-
case watch.suspended && watch.degraded:
2531-
healthCheckPassed = healthStatus == string(health.HealthStatusDegraded) ||
2532-
healthStatus == string(health.HealthStatusSuspended)
2533-
case watch.degraded && watch.health:
2534-
healthCheckPassed = healthStatus == string(health.HealthStatusHealthy) ||
2535-
healthStatus == string(health.HealthStatusDegraded)
2536-
// below are good
2537-
case watch.suspended && watch.health:
2538-
healthCheckPassed = healthStatus == string(health.HealthStatusHealthy) ||
2539-
healthStatus == string(health.HealthStatusSuspended)
2540-
case watch.suspended:
2541-
healthCheckPassed = healthStatus == string(health.HealthStatusSuspended)
2542-
case watch.health:
2543-
healthCheckPassed = healthStatus == string(health.HealthStatusHealthy)
2544-
case watch.degraded:
2545-
healthCheckPassed = healthStatus == string(health.HealthStatusDegraded)
2527+
if healthBeingChecked {
2528+
healthCheckPassed = false
2529+
if watch.health {
2530+
healthCheckPassed = healthCheckPassed || healthStatus == string(health.HealthStatusHealthy)
2531+
}
2532+
if watch.suspended {
2533+
healthCheckPassed = healthCheckPassed || healthStatus == string(health.HealthStatusSuspended)
2534+
}
2535+
if watch.degraded {
2536+
healthCheckPassed = healthCheckPassed || healthStatus == string(health.HealthStatusDegraded)
2537+
}
25462538
}
25472539

25482540
synced := !watch.sync || syncStatus == string(argoappv1.SyncStatusCodeSynced)

0 commit comments

Comments
 (0)