in src/package_report.py [0:0]
def get_image_size(image_tag, staging_repo_name, staging_account):
try:
ecr_client = boto3.client("ecr", region_name="us-east-1")
response = ecr_client.describe_images(
registryId=staging_account, repositoryName=staging_repo_name, imageIds=[{"imageTag": image_tag}]
)
image_details = response.get("imageDetails", [])
if image_details:
image_size_bytes = image_details[0].get("imageSizeInBytes")
if image_size_bytes:
image_size_gb = image_size_bytes / (1024**3)
return image_size_gb
else:
print(f"Image size not found for {staging_repo_name}:{image_tag}")
else:
print(f"No image details found for {staging_repo_name}:{image_tag}")
except Exception as e:
print(f"Error retrieving image size: {str(e)}")
return None