Regex match nextcloud version to avoid pulling versions like 26 or 26.0 (#1067)

This commit is contained in:
Stavros Kois
2023-04-12 15:30:25 +03:00
committed by GitHub
parent 0173cb81cb
commit 3634834a16

View File

@@ -1,19 +1,23 @@
#!/usr/bin/python3
import json
import re
import sys
from catalog_update.upgrade_strategy import semantic_versioning
RE_STABLE_VERSION = re.compile(r'^[0-9]+\.[0-9]+\.[0-9]+$')
def newer_mapping(image_tags):
key = list(image_tags.keys())[0]
# 21.1 is greater then 21.1.0 so we reverse sort bfeore doing semantic versioning
version = semantic_versioning(sorted(image_tags[key], reverse=True))
tags = {t: t for t in image_tags[key] if RE_STABLE_VERSION.fullmatch(t)}
version = semantic_versioning(list(tags))
if not version:
return {}
return {
'tags': {key: version},
'tags': {key: tags[version]},
'app_version': version,
}