Maybe this comes from an intent to have the default behavior pick all images for removal if the `delete_pattern` is empty?
Either way, it needs to be adjusted so delete_pattern is applied correctly when present - I would recommend actually using re here and actually accept a pattern string. Using just startswith will immediately limit the use and dictate that any teams wanting to use this tool have to prefix image names.
re.compile can be used to create the regex pattern object (and to parse the pattern from config), and then you can use Pattern.search function in the list comprehension to indicate whether the given pattern is anywhere in the string. match can be used too, but will be more explicit and will require the caller to specify .* in their pattern to match anywhere in the string. I think either function is fine here, but the docblock/readme/config comment should explain which is in use.
Either way, it needs to be adjusted so
delete_pattern
is applied correctly when present - I would recommend actually usingre
here and actually accept a pattern string. Using juststartswith
will immediately limit the use and dictate that any teams wanting to use this tool have to prefix image names.re.compile
can be used to create the regex pattern object (and to parse the pattern from config), and then you can usePattern.search
function in the list comprehension to indicate whether the given pattern is anywhere in the string.match
can be used too, but will be more explicit and will require the caller to specify.*
in their pattern to match anywhere in the string. I think either function is fine here, but the docblock/readme/config comment should explain which is in use._Originally posted by @mshriver in https://github.com/RedHatQE/cloudwash/pull/101#discussion_r1279358830_