Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleting images by tag regex with --keep-by-hours doesn't work when --num is 0 #107

Open
SylvainKds opened this issue Nov 18, 2021 · 0 comments

Comments

@SylvainKds
Copy link

I have a scenario where I want to delete images with a tag matching a regex and keeping the ones for the last week.

The corresponding command is:

docker run --rm anoxis/registry-cli --no-validate-ssl -l ":" -r https://*** -i "my-image" --dry-run --delete --tags-like "^my-regex$" --num 0 --keep-by-hours 168

In that case however nothing is deleted, even tags which are older than one week.

As per my understanding this is because when computing the tags to delete there is an issue if the number of tags to keep is 0 (https://github.com/andrey-pohilko/registry-cli/blob/master/registry.py#L835):
tags_list_to_delete = ordered_tags_list[:-keep_last_versions]

Here when 'keep_last_versions' is 0, instead of taking the full list, it returns an empty list.
Should we have a specific case when '--num' is 0 and have something like:
if keep_last_versions == 0:
tags_list_to_delete = ordered_tags_list
else:
tags_list_to_delete = ordered_tags_list[:-keep_last_versions]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant