|
@@ -6,15 +6,21 @@ import re
|
|
|
from catalog_update.upgrade_strategy import semantic_versioning
|
|
|
from catalog_validation.exceptions import ValidationException
|
|
|
|
|
|
+version_regx = r'[\w]*-v[0-9]+.[0-9]+.[0-9]+-go[0-9]+.[0-9].+[0-9]+'
|
|
|
+version_with_arch = version_regx + r'[-\w]*'
|
|
|
+sub_go_version = r'-go[0-9]+.[0-9].+[0-9]+[-\w]*'
|
|
|
+version_hash = r'[\w]*-v'
|
|
|
+app_version_regx = 'v[0-9]+.[0-9]+.[0-9]'
|
|
|
+
|
|
|
|
|
|
def newer_mapping(image_tags):
|
|
|
key = list(image_tags.keys())[0]
|
|
|
tags = {}
|
|
|
for tag in image_tags[key]:
|
|
|
- match = re.fullmatch('[\w]*-v[0-9]+.[0-9]+.[0-9]+-go[0-9]+.[0-9].+[0-9]+[-\w]*', tag) # noqa
|
|
|
+ match = re.fullmatch(version_with_arch, tag)
|
|
|
if match:
|
|
|
- removed_go_arch_version = re.sub('-go[0-9]+.[0-9].+[0-9]+[-\w]*','', tag) # noqa
|
|
|
- app_version = re.sub('[\w]*-v', '', removed_go_arch_version) # noqa
|
|
|
+ removed_go_arch_version = re.sub(sub_go_version, '', tag)
|
|
|
+ app_version = re.sub(version_hash, '', removed_go_arch_version)
|
|
|
if tags.get(app_version):
|
|
|
tags.get(app_version).append(tag)
|
|
|
else:
|
|
@@ -25,13 +31,14 @@ def newer_mapping(image_tags):
|
|
|
|
|
|
version_tag = tags[version][0]
|
|
|
for tag in tags.get(version):
|
|
|
- archi = re.sub('[\w]*-v[0-9]+.[0-9]+.[0-9]+-go[0-9]+.[0-9].+[0-9]+', '', tag) # noqa
|
|
|
+ archi = re.sub(version_regx, '', tag)
|
|
|
if archi == 'amd64' or archi == '':
|
|
|
version_tag = tag
|
|
|
break
|
|
|
+ app_version = re.findall(app_version_regx, version_tag)
|
|
|
return {
|
|
|
'tags': {key: f'{version_tag}'},
|
|
|
- 'app_version': f'{version_tag}',
|
|
|
+ 'app_version': f'{app_version}',
|
|
|
}
|
|
|
|
|
|
|