From 2f4a5aa47955f6391f37b814d331b8f827861cb9 Mon Sep 17 00:00:00 2001 From: "M. Rehan" Date: Wed, 12 Oct 2022 15:08:31 +0500 Subject: [PATCH] fix app version --- charts/storj/upgrade_strategy | 17 ++++++++++++----- test/storj/upgrade_strategy | 17 ++++++++++++----- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/charts/storj/upgrade_strategy b/charts/storj/upgrade_strategy index 14386ed4bf..dd94805e0f 100755 --- a/charts/storj/upgrade_strategy +++ b/charts/storj/upgrade_strategy @@ -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}', } diff --git a/test/storj/upgrade_strategy b/test/storj/upgrade_strategy index 14386ed4bf..dd94805e0f 100755 --- a/test/storj/upgrade_strategy +++ b/test/storj/upgrade_strategy @@ -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}', }