github.com/argoproj/argo-cd/v3@v3.2.1/resource_customizations/_.upbound.io/_/health.lua (about)

     1  -- Health check copied from here: https://github.com/crossplane/docs/blob/709889c5dbe6e5a2ea3dffd66fe276cf465b47b5/content/master/guides/crossplane-with-argo-cd.md
     2  
     3  health_status = {
     4    status = "Progressing",
     5    message = "Provisioning ..."
     6  }
     7  
     8  local function contains (table, val)
     9    for i, v in ipairs(table) do
    10      if v == val then
    11        return true
    12      end
    13    end
    14    return false
    15  end
    16  
    17  local has_no_status = {
    18    "ClusterProviderConfig",
    19    "ProviderConfig",
    20    "ProviderConfigUsage"
    21  }
    22  
    23  if obj.status == nil or next(obj.status) == nil and contains(has_no_status, obj.kind) then
    24    health_status.status = "Healthy"
    25    health_status.message = "Resource is up-to-date."
    26    return health_status
    27  end
    28  
    29  if obj.status == nil or next(obj.status) == nil or obj.status.conditions == nil then
    30    if (obj.kind == "ProviderConfig" or obj.kind == "ClusterProviderConfig") and obj.status.users ~= nil then
    31      health_status.status = "Healthy"
    32      health_status.message = "Resource is in use."
    33      return health_status
    34    end
    35    return health_status
    36  end
    37  
    38  for i, condition in ipairs(obj.status.conditions) do
    39    if condition.type == "LastAsyncOperation" then
    40      if condition.status == "False" then
    41        health_status.status = "Degraded"
    42        health_status.message = condition.message
    43        return health_status
    44      end
    45    end
    46  
    47    if condition.type == "Synced" then
    48      if condition.status == "False" then
    49        health_status.status = "Degraded"
    50        health_status.message = condition.message
    51        return health_status
    52      end
    53    end
    54  
    55    if condition.type == "Ready" then
    56      if condition.status == "True" then
    57        health_status.status = "Healthy"
    58        health_status.message = "Resource is up-to-date."
    59        return health_status
    60      end
    61    end
    62  end
    63  
    64  return health_status