in main.py [0:0]
def delete_images(ecr_client, deletesha, deletetag, repo_id, name):
if len(deletesha) >= 1:
## spliting list of images to delete on chunks with 100 images each
## http://docs.aws.amazon.com/AmazonECR/latest/APIReference/API_BatchDeleteImage.html#API_BatchDeleteImage_RequestSyntax
i = 0
for deletesha_chunk in chunks(deletesha, 100):
i += 1
if not DRYRUN:
delete_response = ecr_client.batch_delete_image(
registryId=repo_id,
repositoryName=name,
imageIds=deletesha_chunk
)
print(delete_response)
else:
print("registryId:" + repo_id)
print("repositoryName:" + name)
print("Deleting {} chank of images".format(i))
print("imageIds:", end='')
print(deletesha_chunk)
if deletetag:
print("Image URLs that are marked for deletion:")
for ids in deletetag:
print("- {} - {}".format(ids["imageUrl"], ids["pushedAt"]))