github.com/argoproj/argo-cd/v3@v3.2.1/resource_customizations/_.crossplane.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    "Composition",
    19    "CompositionRevision",
    20    "DeploymentRuntimeConfig",
    21    "ClusterProviderConfig",
    22    "ProviderConfig",
    23    "ProviderConfigUsage",
    24    "ControllerConfig" -- Added to ensure that healthcheck is backwards-compatible with Crossplane v1
    25  }
    26  if obj.status == nil or next(obj.status) == nil and contains(has_no_status, obj.kind) then
    27      health_status.status = "Healthy"
    28      health_status.message = "Resource is up-to-date."
    29    return health_status
    30  end
    31  
    32  if obj.status == nil or next(obj.status) == nil or obj.status.conditions == nil then
    33    if (obj.kind == "ProviderConfig" or obj.kind == "ClusterProviderConfig") and obj.status.users ~= nil then
    34      health_status.status = "Healthy"
    35      health_status.message = "Resource is in use."
    36      return health_status
    37    end
    38    return health_status
    39  end
    40  
    41  for i, condition in ipairs(obj.status.conditions) do
    42    if condition.type == "LastAsyncOperation" then
    43      if condition.status == "False" then
    44        health_status.status = "Degraded"
    45        health_status.message = condition.message
    46        return health_status
    47      end
    48    end
    49  
    50    if condition.type == "Synced" then
    51      if condition.status == "False" then
    52        health_status.status = "Degraded"
    53        health_status.message = condition.message
    54        return health_status
    55      end
    56    end
    57  
    58    if contains({"Ready", "Healthy", "Offered", "Established", "ValidPipeline", "RevisionHealthy"}, condition.type) then
    59      if condition.status == "True" then
    60        health_status.status = "Healthy"
    61        health_status.message = "Resource is up-to-date."
    62        return health_status
    63      end
    64    end
    65  end
    66  
    67  return health_status