Files
Josh SorefandGitHub 6d4327e486 chore(action): minor lua changes (#15580)
* chore(action): add newlines at eof

Signed-off-by: Josh Soref <[email protected]>

* chore(action): fix whitespace indentation

Signed-off-by: Josh Soref <[email protected]>

* chore(action): use local annotations

Signed-off-by: Josh Soref <[email protected]>

---------

Signed-off-by: Josh Soref <[email protected]>
2023-09-21 09:20:42 -04:00

30 lines
990 B
Lua

local adopted = { status = "Unknown" }
local advertised = { status = "Unknown" }
local discovered = { status = "Unknown" }
if obj.status ~= nil then
if obj.status.conditions ~= nil then
for i, c in ipairs(obj.status.conditions) do
if c.type == "Adopted" then
adopted = c
elseif c.type == "Advertised" then
advertised = c
elseif c.type == "Discoverable" then
discovered = c
end
end
end
end
if adopted.status == "False" then
return { status = "Degraded", message = adopted.message }
elseif advertised.reason == "AdvertiseError" or advertised.reason == "UnadvertiseError" then
return { status = "Degraded", message = advertised.message }
elseif discovered.reason == "DiscoveryError" then
return { status = "Unknown", message = discovered.message }
elseif discovered.status == "True" then
return { status = "Healthy", message = discovered.message }
else
return { status = "Progressing", message = discovered.message }
end