Apply pep8

This commit is contained in:
Stefan Reimer 2023-08-11 12:51:46 +00:00
parent 5819ded812
commit 955afa71ee

View File

@ -3,7 +3,8 @@
import argparse
import boto3
parser = argparse.ArgumentParser(description='Implement basic public ECR lifecycle policy')
parser = argparse.ArgumentParser(
description='Implement basic public ECR lifecycle policy')
parser.add_argument('--repo', dest='repositoryName', action='store', required=True,
help='Name of the public ECR repository')
parser.add_argument('--keep', dest='keep', action='store', default=10, type=int,
@ -15,7 +16,8 @@ args = parser.parse_args()
client = boto3.client('ecr-public', region_name='us-east-1')
images = client.describe_images(repositoryName=args.repositoryName)["imageDetails"]
images = client.describe_images(repositoryName=args.repositoryName)[
"imageDetails"]
untagged = []
kept = 0
@ -54,7 +56,8 @@ for image in sorted(images, key=lambda d: d['imagePushedAt'], reverse=True):
print("Deleting tagged image {}".format(image["imageTags"]))
untagged.append({"imageDigest": image['imageDigest']})
deleted_images = client.batch_delete_image(repositoryName=args.repositoryName, imageIds=untagged)
deleted_images = client.batch_delete_image(
repositoryName=args.repositoryName, imageIds=untagged)
if deleted_images["imageIds"]:
print("Deleted images: {}".format(deleted_images["imageIds"]))