Files
chart/library/ix-dev/community/castopod/upgrade_strategy
Stavros Kois f4a842b162 Add castopod to incubator train (#1598)
* initial commit

* add some templates

* add common and templates

* update strategy

* fix tempaltes

* fix host

* add metadata

* add readme

* fix probe

* add questiosn

* typo

* quote

* disable by default the redirect

* add another test

* rename service

* remove todo

* fix backend url and questions
2023-10-05 15:12:05 +03:00

52 lines
1.2 KiB
Python
Executable File

#!/usr/bin/python3
import json
import re
import sys
from catalog_update.upgrade_strategy import semantic_versioning
RE_STABLE_VERSION_BASE = r'\d+\.\d+\.\d+'
ENUMS = {
'image': {
'RE_STABLE_VERSION': re.compile(rf'{RE_STABLE_VERSION_BASE}'),
},
'webImage': {
'RE_STABLE_VERSION': re.compile(rf'{RE_STABLE_VERSION_BASE}'),
},
}
def newer_mapping(image_tags):
output = {
"tags": {},
"app_version": ""
}
for key in image_tags.keys():
RE_STABLE_VERSION = ENUMS[key].get('RE_STABLE_VERSION', None) if key in ENUMS else None
if (RE_STABLE_VERSION is None):
continue
tags = {t: t for t in image_tags[key] if RE_STABLE_VERSION.fullmatch(t)}
version = semantic_versioning(list(tags))
if not version:
continue
if key == 'image':
output['app_version'] = version
output['tags'][key] = tags[version]
return output
if __name__ == '__main__':
try:
versions_json = json.loads(sys.stdin.read())
except ValueError:
raise ValueError('Invalid json specified')
print(json.dumps(newer_mapping(versions_json)))