argo-cd/resource_customizations/source.toolkit.fluxcd.io/HelmRepository/health.lua
Adrian Berger 91b8bba570
fix(health): custom resource health for flux helm repository of type oci (#24294)
Signed-off-by: Adrian Berger <adrian.berger@bedag.ch>
2025-08-28 14:39:44 -04:00

52 lines
1.7 KiB
Lua

local hs = {}
if obj.spec.suspend ~= nil and obj.spec.suspend == true then
hs.message = obj.kind .. " is suspended"
hs.status = "Suspended"
return hs
end
-- Helm repositories of type "oci" do not contain any information in the status
-- https://fluxcd.io/flux/components/source/helmrepositories/#helmrepository-status
if obj.spec.type ~= nil and obj.spec.type == "oci" then
hs.message = "Helm repositories of type 'oci' do not contain any information in the status."
hs.status = "Healthy"
return hs
end
if obj.status ~= nil then
if obj.status.conditions ~= nil then
local numProgressing = 0
local numSucceeded = 0
local message = ""
for _, condition in ipairs(obj.status.conditions) do
if condition.type == "Ready" then
if condition.status == "True" then
numSucceeded = numSucceeded + 1
elseif condition.status == "Unknown" then
numProgressing = numProgressing + 1
end
message = condition.reason
elseif condition.type == "Reconciling" and condition.status == "True" then
numProgressing = numProgressing + 1
elseif condition.type == "ArtifactOutdated" and condition.status == "True" then
message = message .. " " .. condition.reason
elseif condition.type == "ArtifactInStorage" and condition.status == "True" then
numSucceeded = numSucceeded + 1
end
end
if(numProgressing == 2) then
hs.message = message
hs.status = "Progressing"
return hs
elseif(numSucceeded == 2) then
hs.message = message
hs.status = "Healthy"
return hs
else
hs.message = message
hs.status = "Degraded"
return hs
end
end
end
hs.message = "Status unknown"
hs.status = "Progressing"
return hs