Created
August 28, 2024 17:17
-
-
Save MaxAnderson95/e73648c12a5d8ebadb374bf5c7ff7c93 to your computer and use it in GitHub Desktop.
Revisions
-
MaxAnderson95 created this gist
Aug 28, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,37 @@ -- Create a table to store the health status of the object local hs = {} -- Check if the object has any status at all if obj.status ~= nil then -- Check if the object has any conditions at all if obj.status.conditions ~= nil then -- Loop through each condition for i, condition in ipairs(obj.status.conditions) do -- If the "Ready" condition is False if condition.type == "Ready" and condition.status == "False" then -- Check the severity. If "Error" return a status of "Degraded" if condition.severity == "Error" then hs.status = "Degraded" hs.message = condition.message return hs -- For any other severity return a status of "Progressing" else hs.status = "Progressing" hs.message = condition.message return hs end end -- Once the "Ready" condition is "True", return status of "Healthy" if condition.type == "Ready" and condition.status == "True" then hs.status = "Healthy" hs.message = condition.message return hs end end end end -- If object status is nil or status.conditions are nil, return Degraded hs.status = "Degraded" hs.message = "Waiting for ASO Operator to begin reconsiling the object" return hs