-
Notifications
You must be signed in to change notification settings - Fork 5.7k
/
Copy pathhealth.lua
41 lines (39 loc) · 1.22 KB
/
health.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
local hs = {}
if obj.status ~= nil then
if obj.status.conditions ~= nil then
local ready = false
local synced = false
local suspended = false
for i, condition in ipairs(obj.status.conditions) do
if condition.type == "Ready" then
ready = condition.status == "True"
ready_message = condition.reason
elseif condition.type == "Synced" then
synced = condition.status == "True"
if condition.reason == "ReconcileError" then
synced_message = condition.message
elseif condition.reason == "ReconcilePaused" then
suspended = true
suspended_message = condition.reason
end
end
end
if ready and synced then
hs.status = "Healthy"
hs.message = ready_message
elseif synced == false and suspended == true then
hs.status = "Suspended"
hs.message = suspended_message
elseif ready == false and synced == true and suspended == false then
hs.status = "Progressing"
hs.message = "Waiting for Bucket to be available"
else
hs.status = "Degraded"
hs.message = synced_message
end
return hs
end
end
hs.status = "Progressing"
hs.message = "Waiting for Bucket to be created"
return hs