Skip to content

Commit c172628

Browse files
author
Dylan Grafmyre
committed
Do the keep-regex check before tag grouping
1 parent 6488384 commit c172628

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

dockerrotate/main.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,16 @@ def clean_images(client, args):
171171
# group by name
172172
images_by_name = {}
173173
for image in images:
174+
if any(
175+
any([re.match(pattern, tag) for pattern in args.keep_regex])
176+
for tag in image["RepoTags"]
177+
):
178+
continue
179+
174180
for tag in image["RepoTags"]:
175181
image_name = normalize_tag_name(tag)
176182
if args.only and args.only != image_name:
177183
continue
178-
if any([re.match(pattern, tag) for pattern in args.keep_regex]):
179-
continue
180184

181185
images_by_name.setdefault(image_name, set()).add(image["Id"])
182186

0 commit comments

Comments
 (0)