artifactory-cleanup
artifactory-cleanup copied to clipboard
Formatting Question - Possible Bug
We have docker images tagged with numerous tag patterns. Examples:
- v1
- v1.2
- v1.2.3
- v1.2.3.4
- 1
- 1.2
- 1.2.3
- 1.2.3.4
- 1.2.3_2023-14
- v1.2.3_2023-14
I attempted to configure a rule as follows:
- rule: KeepLatestNVersionImagesByProperty
count: 2
custom_regexp: "(^v?(\\d+)+(\\.\\d+)*|(_\\d{4}\\-\\d{2})*$)"
In my regex tester, all tags match. However, when running this in artifactory-cleanup I get this error:
Filter artifacts - rule: KeepLatestNVersionImagesByProperty - Leaves ``count`` Docker images with the same major.
artifacts = rule.filter(artifacts)
File "/usr/local/lib/python3.9/site-packages/artifactory_cleanup/rules/docker.py", line 238, in filter
grouped = pydash.group_by(artifacts, iteratee=_groupby)
File "/usr/local/lib/python3.9/site-packages/pydash/collections.py", line 397, in group_by
key = cbk(value)
File "/usr/local/lib/python3.9/site-packages/artifactory_cleanup/rules/docker.py", line 234, in _groupby
self.get_version(artifact)[: self.number_of_digits_in_version],
File "/usr/local/lib/python3.9/site-packages/artifactory_cleanup/rules/docker.py", line 224, in get_version
version = tuple(map(int, version_str.split(".")))
ValueError: invalid literal for int() with base 10: 'v1'
Tags with a preceding 'v' in the tag fail. Is my RegEx incorrect (if so, what would be correct?) or is this a bug in the code?
is this a bug in the code?
It's likely this one :)