From 28c30808719a806f1ec25e3430a7c7cd926d69f0 Mon Sep 17 00:00:00 2001 From: xificurC Date: Thu, 16 Aug 2018 16:07:37 +0200 Subject: [PATCH] adds --images-like - select images with regexp --- registry.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/registry.py b/registry.py index 0218528..f90033f 100755 --- a/registry.py +++ b/registry.py @@ -457,6 +457,13 @@ for more detail on garbage collection read here: nargs='+', metavar="IMAGE:[TAG]") + parser.add_argument( + '--images-like', + nargs='+', + help="List of images (regexp check) that will be handled", + required=False, + default=[]) + parser.add_argument( '--keep-tags', nargs='+', @@ -636,6 +643,17 @@ def get_newer_tags(registry, image_name, hours, tags_list): return newer_tags +def keep_images_like(image_list, regexp_list): + result = [] + regexp_list = list(map(re.compile, regexp_list)) + for image in image_list: + for regexp in regexp_list: + if re.search(regexp, image): + result.append(image) + break + return result + + def main_loop(args): global DEBUG @@ -685,6 +703,8 @@ def main_loop(args): image_list = args.image else: image_list = registry.list_images() + if args.images_like: + image_list = keep_images_like(image_list, args.images_like) # loop through registry's images # or through the ones given in command line