adds --images-like - select images with regexp
This commit is contained in:
20
registry.py
20
registry.py
@@ -457,6 +457,13 @@ for more detail on garbage collection read here:
|
|||||||
nargs='+',
|
nargs='+',
|
||||||
metavar="IMAGE:[TAG]")
|
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(
|
parser.add_argument(
|
||||||
'--keep-tags',
|
'--keep-tags',
|
||||||
nargs='+',
|
nargs='+',
|
||||||
@@ -636,6 +643,17 @@ def get_newer_tags(registry, image_name, hours, tags_list):
|
|||||||
return newer_tags
|
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):
|
def main_loop(args):
|
||||||
global DEBUG
|
global DEBUG
|
||||||
|
|
||||||
@@ -685,6 +703,8 @@ def main_loop(args):
|
|||||||
image_list = args.image
|
image_list = args.image
|
||||||
else:
|
else:
|
||||||
image_list = registry.list_images()
|
image_list = registry.list_images()
|
||||||
|
if args.images_like:
|
||||||
|
image_list = keep_images_like(image_list, args.images_like)
|
||||||
|
|
||||||
# loop through registry's images
|
# loop through registry's images
|
||||||
# or through the ones given in command line
|
# or through the ones given in command line
|
||||||
|
|||||||
Reference in New Issue
Block a user