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

40 lines
1.2 KiB
Lua

local hs = {}
function messageOrDefault(field, default)
if field ~= nil then
return field
end
return default
end
if obj.status ~= nil then
if obj.status.phase == "Pending" then
hs.status = "Progressing"
hs.message = "Analysis run is running"
end
if obj.status.phase == "Running" then
hs.status = "Progressing"
hs.message = "Analysis run is running"
end
if obj.status.phase == "Successful" then
hs.status = "Healthy"
hs.message = messageOrDefault(obj.status.message, "Analysis run completed successfully")
end
if obj.status.phase == "Failed" then
hs.status = "Degraded"
hs.message = messageOrDefault(obj.status.message, "Analysis run failed")
end
if obj.status.phase == "Error" then
hs.status = "Degraded"
hs.message = messageOrDefault(obj.status.message, "Analysis run had an error")
end
if obj.status.phase == "Inconclusive" then
hs.status = "Unknown"
hs.message = messageOrDefault(obj.status.message, "Analysis run was inconclusive")
end
return hs
end
hs.status = "Progressing"
hs.message = "Waiting for analysis run to finish: status has not been reconciled."
return hs