Skip to content

Commit

Permalink
add-status-output-details (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielsoltz authored Nov 19, 2023
1 parent 66f7fc2 commit 727176d
Showing 1 changed file with 29 additions and 13 deletions.
42 changes: 29 additions & 13 deletions lib/impact/status.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,36 @@
from lib.impact.helpers import check_key, get_config_key

class Status:
def __init__(self, logger):
self.logger = logger

def get_status(self, resource_arn, resource_values):
self.logger.info("Calculating status for resource: %s", resource_arn)

config = resource_values.get("config", {})
if config:
if config.get("status"):
if config.get("status") == "running":
return {"running": config.get("status")}
else:
return {"not-running": config.get("status")}
if config.get("attached") is True:
return {"attached": config.get("attached")}
if config.get("attached") is False:
return {"not-attached": config.get("attached")}

return {"unknown": {}}
status = get_config_key(resource_values, "status")
attached = get_config_key(resource_values, "attached")

status_checks = {
"status": status,
"attached": attached,
}

# If no config and no associations, return unknown
if not check_key(resource_values, "config") and not check_key(
resource_values, "associations"
):
return {"unknown": status_checks}

if attached is not None:
if attached is True:
return {"attached": status_checks}
if attached is False:
return {"not-attached": status_checks}

if status is not None:
if status == "running":
return {"running": status_checks}
if status != "running":
return {"not-running": status_checks}

return {"unknown": status_checks}

0 comments on commit 727176d

Please sign in to comment.