argo-cd/resource_customizations/work.karmada.io/ResourceBinding/health.lua
Josh Soref 491b3898ac
chore(action): minor lua changes (#15580)
* chore(action): add newlines at eof

Signed-off-by: Josh Soref <jsoref@gmail.com>

* chore(action): fix whitespace indentation

Signed-off-by: Josh Soref <jsoref@gmail.com>

* chore(action): use local annotations

Signed-off-by: Josh Soref <jsoref@gmail.com>

---------

Signed-off-by: Josh Soref <jsoref@gmail.com>
2023-09-21 09:20:42 -04:00

37 lines
1.1 KiB
Lua

local health_status = {}
if obj.status == nil then
health_status.status = "Progressing"
health_status.message = "Current resource status is insufficient"
return health_status
end
if obj.spec.clusters == nil or #obj.spec.clusters == 0 then
health_status.status = "Progressing"
health_status.message = "Current resource status is insufficient"
return health_status
end
if obj.status.aggregatedStatus == nil or #obj.spec.clusters ~= #obj.status.aggregatedStatus then
health_status.status = "Progressing"
health_status.message = "Current resource status is insufficient"
return health_status
end
for i, status in ipairs(obj.status.aggregatedStatus) do
if status.health == "Unhealthy" then
health_status.status = "Degraded"
health_status.message = "Current resource status is unhealthy"
return health_status
end
if status.health == "Unknown" then
if status.applied ~= true then
health_status.status = "Degraded"
health_status.message = "Current resource status is unhealthy"
return health_status
end
end
end
health_status.status = "Healthy"
return health_status