Add upgrade logic for ipfs chart

This commit is contained in:
sonicaj
2021-06-14 21:52:20 +05:00
parent 5628324e3f
commit a55db161fe
4 changed files with 33 additions and 2 deletions

View File

@@ -11,7 +11,7 @@ def newer_mapping(image_tags):
if not image_tags[key]:
return {}
versions = [v for v in map(parse_version, image_tags[key]) if isinstance(v, Version)]
versions = [v for v in map(parse_version, image_tags[key]) if isinstance(v, Version) and not v.is_prerelease]
if not versions:
return {}

View File

@@ -0,0 +1 @@
{"filename": "ix_values.yaml", "keys": ["image"]}

30
charts/ipfs/upgrade_strategy Executable file
View File

@@ -0,0 +1,30 @@
#!/usr/bin/python3
import json
import sys
from pkg_resources import parse_version
from pkg_resources.extern.packaging.version import Version
def newer_mapping(image_tags):
key = list(image_tags.keys())[0]
if not image_tags[key]:
return {}
versions = [v for v in map(parse_version, image_tags[key]) if isinstance(v, Version) and not v.is_prerelease]
if not versions:
return {}
versions.sort()
version = str(versions[-1])
return {
'tags': {key: version},
'app_version': version,
}
if __name__ == '__main__':
if len(sys.argv) != 2:
exit(1)
print(json.dumps(newer_mapping(json.loads(sys.argv[1]))))

View File

@@ -13,7 +13,7 @@ def newer_mapping(image_tags):
tags = {t.rsplit('-', 1)[0]: t for t in image_tags[key]}
versions = [v for v in map(parse_version, tags) if isinstance(v, Version)]
versions = [v for v in map(parse_version, tags) if isinstance(v, Version) and not v.is_prerelease]
if not versions:
return {}