Skip to content

Commit

Permalink
Minor changes to remove redundant names in logs
Browse files Browse the repository at this point in the history
  • Loading branch information
msajidmansoori12 committed Oct 1, 2024
1 parent fbde185 commit b9af1d1
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions cloudwash/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,23 @@ def echo_dry(dry_data=None) -> None:
"deletable_resources": dry_data["RESOURCES"]["delete"],
"deletable_stacks": dry_data["STACKS"]["delete"] if "STACKS" in dry_data else None,
}
if any(value for key, value in resource_data.items() if key != 'provider'):
logger.info("Resources eligible for cleanup:")
for key, value in resource_data.items():
if value and key != "provider":
logger.info(
f"{key.replace('_', ' ').title()}:\n\t{key.split('_')[0].title()}: {value}"
)

# Group the same resource type under the same section for logging
grouped_resources = {}
for key, value in resource_data.items():
if key != 'provider' and value:
suffix = key.split('_')[1].upper()
action = key.split('_')[0].title()

if suffix not in grouped_resources.keys():
grouped_resources[suffix] = {}
grouped_resources[suffix][action] = value

if any(value for key, value in resource_data.items() if key != 'provider'):
for suffix, actions in grouped_resources.items():
logger.info(f"{suffix}:")
for action, value in actions.items():
logger.info(f"\t{action}: {value}")
logger.info("\n====================================\n")

create_html(**resource_data)
Expand Down

0 comments on commit b9af1d1

Please sign in to comment.