mirror of
https://github.com/argoproj/argo-cd.git
synced 2026-02-20 01:28:45 +01:00
Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
This commit is contained in:
@@ -7,8 +7,18 @@ if obj.status == nil or obj.status.conditions == nil then
|
||||
end
|
||||
|
||||
-- Sort conditions by lastTransitionTime, from old to new.
|
||||
-- Ensure that conditions with nil lastTransitionTime are always sorted after those with non-nil values.
|
||||
table.sort(obj.status.conditions, function(a, b)
|
||||
return a.lastTransitionTime < b.lastTransitionTime
|
||||
-- Nil values are considered "less than" non-nil values.
|
||||
-- This means that conditions with nil lastTransitionTime will be sorted to the end.
|
||||
if a.lastTransitionTime == nil then
|
||||
return false
|
||||
elseif b.lastTransitionTime == nil then
|
||||
return true
|
||||
else
|
||||
-- If both have non-nil lastTransitionTime, compare them normally.
|
||||
return a.lastTransitionTime < b.lastTransitionTime
|
||||
end
|
||||
end)
|
||||
|
||||
for _, condition in ipairs(obj.status.conditions) do
|
||||
|
||||
@@ -14,4 +14,8 @@ tests:
|
||||
- healthStatus:
|
||||
status: Degraded
|
||||
message: "Has Errors: Waiting for foo/keycloak-1 due to CrashLoopBackOff: back-off 10s"
|
||||
inputPath: testdata/degraded.yaml
|
||||
inputPath: testdata/degraded.yaml
|
||||
- healthStatus:
|
||||
status: Healthy
|
||||
message: ""
|
||||
inputPath: testdata/nil_last_transition_time.yaml
|
||||
13
resource_customizations/k8s.keycloak.org/Keycloak/testdata/nil_last_transition_time.yaml
vendored
Normal file
13
resource_customizations/k8s.keycloak.org/Keycloak/testdata/nil_last_transition_time.yaml
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
apiVersion: k8s.keycloak.org/v1alpha1
|
||||
kind: Keycloak
|
||||
metadata:
|
||||
name: keycloak-23
|
||||
namespace: keycloak
|
||||
status:
|
||||
conditions:
|
||||
- type: Ready
|
||||
status: "True"
|
||||
lastTransitionTime: "2025-05-06T12:00:00Z" # Non-nil lastTransitionTime
|
||||
- type: HasErrors
|
||||
status: "False"
|
||||
lastTransitionTime: null # Nil lastTransitionTime
|
||||
Reference in New Issue
Block a user