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

Formatting Question - Possible Bug #128

Open
ggolub opened this issue Feb 6, 2024 · 1 comment
Open

Formatting Question - Possible Bug #128

ggolub opened this issue Feb 6, 2024 · 1 comment
Labels
bug Something isn't working help wanted Extra attention is needed question Further information is requested

Comments

@ggolub
Copy link

ggolub commented Feb 6, 2024

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?

@allburov allburov added help wanted Extra attention is needed question Further information is requested labels Feb 10, 2024
@allburov
Copy link
Member

is this a bug in the code?

It's likely this one :)

@allburov allburov added the bug Something isn't working label Feb 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed question Further information is requested
Development

No branches or pull requests

2 participants