fix app version

This commit is contained in:
M. Rehan
2022-10-12 15:08:31 +05:00
parent f6fa6ce495
commit 2f4a5aa479
2 changed files with 24 additions and 10 deletions

View File

@@ -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}',
}

View File

@@ -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}',
}