From 17635b740e8976831005c550ac60560448091cac Mon Sep 17 00:00:00 2001 From: sonicaj Date: Fri, 6 Aug 2021 18:56:53 +0500 Subject: [PATCH] Define upgrade strategy for automated updates for machinaris --- test/machinaris/upgrade_info.json | 1 + test/machinaris/upgrade_strategy | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 test/machinaris/upgrade_info.json create mode 100755 test/machinaris/upgrade_strategy diff --git a/test/machinaris/upgrade_info.json b/test/machinaris/upgrade_info.json new file mode 100644 index 0000000000..f22ddd1aee --- /dev/null +++ b/test/machinaris/upgrade_info.json @@ -0,0 +1 @@ +{"filename": "ix_values.yaml", "keys": ["image"], "test_filename": "test_values.yaml"} diff --git a/test/machinaris/upgrade_strategy b/test/machinaris/upgrade_strategy new file mode 100755 index 0000000000..6b95867d8d --- /dev/null +++ b/test/machinaris/upgrade_strategy @@ -0,0 +1,25 @@ +#!/usr/bin/python3 +import json +import sys + +from catalog_update.upgrade_strategy import semantic_versioning + + +def newer_mapping(image_tags): + key = list(image_tags.keys())[0] + tags = {t.strip('v').replace('_', '.'): t for t in image_tags[key]} + version = semantic_versioning(image_tags[key]) + if not version: + return {} + + return { + 'tags': {key: tags[version]}, + 'app_version': tags[version], + } + + +if __name__ == '__main__': + if len(sys.argv) != 2: + exit(1) + + print(json.dumps(newer_mapping(json.loads(sys.argv[1]))))