github.com/argoproj/argo-cd/v3@v3.2.1/resource_customizations/gateway.networking.k8s.io/GRPCRoute/health.lua (about) 1 local hs = {} 2 3 function checkConditions(conditions, conditionType) 4 for _, condition in ipairs(conditions) do 5 if condition.type == conditionType and condition.status == "False" then 6 return false, condition.message or ("Failed condition: " .. conditionType) 7 end 8 end 9 return true 10 end 11 12 if obj.status ~= nil then 13 if obj.status.parents ~= nil then 14 for _, parent in ipairs(obj.status.parents) do 15 if parent.conditions ~= nil then 16 local resolvedRefsFalse, resolvedRefsMsg = checkConditions(parent.conditions, "ResolvedRefs") 17 local acceptedFalse, acceptedMsg = checkConditions(parent.conditions, "Accepted") 18 19 if not resolvedRefsFalse then 20 hs.status = "Degraded" 21 hs.message = "Parent " .. (parent.parentRef.name or "") .. ": " .. resolvedRefsMsg 22 return hs 23 end 24 25 if not acceptedFalse then 26 hs.status = "Degraded" 27 hs.message = "Parent " .. (parent.parentRef.name or "") .. ": " .. acceptedMsg 28 return hs 29 end 30 31 local isProgressing = false 32 local progressingMsg = "" 33 34 for _, condition in ipairs(parent.conditions) do 35 if condition.type == "Programmed" and condition.status ~= "True" then 36 isProgressing = true 37 progressingMsg = condition.message or "Route is still being programmed" 38 break 39 end 40 end 41 42 if isProgressing then 43 hs.status = "Progressing" 44 hs.message = "Parent " .. (parent.parentRef.name or "") .. ": " .. progressingMsg 45 return hs 46 end 47 end 48 end 49 50 if #obj.status.parents > 0 then 51 for _, parent in ipairs(obj.status.parents) do 52 if parent.conditions ~= nil and #parent.conditions > 0 then 53 hs.status = "Healthy" 54 hs.message = "GRPCRoute is healthy" 55 return hs 56 end 57 end 58 end 59 end 60 end 61 62 hs.status = "Progressing" 63 hs.message = "Waiting for GRPCRoute status" 64 return hs