truenas / charts

TrueNAS SCALE Apps Catalogs & Charts
BSD 3-Clause "New" or "Revised" License
258 stars 253 forks source link

tdarr: handle version numbers with leading zeros (e.g. 2.21.01) #2604

Closed swensorm closed 1 week ago

swensorm commented 2 weeks ago

This is a followup PR to https://github.com/truenas/charts/pull/2583 that I missed the python script needs to handle version numbers with leading zeros in the digit groups (e.g 2.21.01) with how the upgrade_strategy semantic_versioning works.

Using compiled regex to strip leading zeros in front of other digits.

I really don't know python well so please let me know if there's a better way to do this. Thank you for the review and sorry about the extra PR!

swensorm commented 2 weeks ago

I created a test json file with an array of the latest version numbers to test this. The first command I added printing the tags array after it's creation. The 2nd run is solely what is in the PR.

root@1ae80329d208:/app# cat test.json | python3 upgrade_strategy
{'2.21.1': '2.21.01', '2.20.1': '2.20.01', '2.19.1': '2.19.01', '2.18.2': '2.18.02', '2.18.1': '2.18.01', '2.17.1': '2.17.01', '2.16.1': '2.16.01', '2.15.1': '2.15.01', '2.14.2': '2.14.02', '2.14.1': '2.14.01', '2.13.1': '2.13.01'}
{"tags": {"image": "2.21.01"}, "app_version": "2.21.1"}
root@1ae80329d208:/app# cat test.json | python3 upgrade_strategy
{"tags": {"image": "2.21.01"}, "app_version": "2.21.1"}
root@1ae80329d208:/app#

P.S. This is running in an ixsystems/catalog_update container.