mirror of
https://github.com/hanzoai/deploy.git
synced 2026-10-07 08:44:50 +00:00
* feat(custom healthchecks): add healthchecks for Gloo resources Signed-off-by: Ilya Gorban <[email protected]> * fix(gloo custom healthchecks): fix healthcheck and add older cases Signed-off-by: Ilya Gorban <[email protected]> * feat(custom healthchecks): fix tabulation in Gloo resources lua files Signed-off-by: Ilya Gorban <[email protected]> --------- Signed-off-by: Ilya Gorban <[email protected]> Co-authored-by: Michael Crenshaw <[email protected]>
55 lines
1.1 KiB
Lua
55 lines
1.1 KiB
Lua
hs = {
|
|
status = "Progressing",
|
|
message = "Update in progress"
|
|
}
|
|
|
|
function getStatus(status)
|
|
-- Accepted
|
|
if status.state == "Accepted" or status.state == 1 then
|
|
hs.status = "Healthy"
|
|
hs.message = "The resource has been validated"
|
|
return hs
|
|
end
|
|
|
|
-- Warning
|
|
if status.state == "Warning" or status.state == 3 then
|
|
hs.status = "Degraded"
|
|
hs.message = status.reason
|
|
return hs
|
|
end
|
|
|
|
-- Pending
|
|
if status.state == "Pending" or status.state == 0 then
|
|
hs.status = "Suspended"
|
|
hs.message = "The resource has not yet been validated"
|
|
return hs
|
|
end
|
|
|
|
-- Rejected
|
|
if status.state == "Rejected" or status.state == 2 then
|
|
hs.status = "Degraded"
|
|
hs.message = status.reason
|
|
return hs
|
|
end
|
|
|
|
return hs
|
|
end
|
|
|
|
if obj.status ~= nil then
|
|
-- Namespaced version of status
|
|
if obj.status.statuses ~= nil then
|
|
for i, namespace in pairs(obj.status.statuses) do
|
|
hs = getStatus(namespace)
|
|
if hs.status ~= "Progressing" then
|
|
return hs
|
|
end
|
|
end
|
|
end
|
|
|
|
-- Older non-namespaced version of status
|
|
if obj.status.state ~= nil then
|
|
hs = getStatus(obj.status)
|
|
end
|
|
end
|
|
return hs
|