Skip to content

Commit 40bce7c

Browse files
author
Victor Machado
committed
Delete all froster-unittest buckets function
1 parent d51865f commit 40bce7c

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

froster/froster.py

+14-2
Original file line numberDiff line numberDiff line change
@@ -1789,12 +1789,24 @@ def delete_bucket(self, bucket_name):
17891789

17901790
s3_buckets = self.get_buckets()
17911791

1792-
# Delete the buckets if they exists
1792+
# Delete the bucket if its exists
17931793
if bucket_name in s3_buckets:
17941794
self.s3_client.delete_bucket(Bucket=bucket_name)
17951795
log(f'Bucket {bucket_name} deleted\n')
1796+
1797+
# This is here in case there is a mistake and the S3 buckets are not deleted
1798+
# This will erase all the froster-unittest* buckets at once
1799+
elif bucket_name == "froster-unittest":
1800+
for bucket in s3_buckets:
1801+
if bucket.startswith(bucket_name):
1802+
try:
1803+
self.s3_client.delete_bucket(Bucket=bucket)
1804+
except Exception as e:
1805+
print(f'Error: {e}')
1806+
continue
1807+
log(f'\nBucket {bucket} deleted\n')
17961808
else:
1797-
log(f'Bucket {bucket_name} not found\n')
1809+
log(f'\nBucket {bucket_name} not found\n')
17981810

17991811
return True
18001812

0 commit comments

Comments
 (0)