mirror of
https://github.com/truenas/charts.git
synced 2026-04-05 19:58:21 +08:00
add storj upgrade strategy
This commit is contained in:
1
charts/storj/upgrade_info.json
Normal file
1
charts/storj/upgrade_info.json
Normal file
@@ -0,0 +1 @@
|
||||
{"filename": "ix_values.yaml", "keys": ["image"], "test_filename": "test_values.yaml"}
|
||||
44
charts/storj/upgrade_strategy
Executable file
44
charts/storj/upgrade_strategy
Executable file
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/python3
|
||||
import json
|
||||
import sys
|
||||
import re
|
||||
|
||||
from catalog_update.upgrade_strategy import semantic_versioning
|
||||
from catalog_validation.exceptions import ValidationException
|
||||
|
||||
|
||||
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
|
||||
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
|
||||
if tags.get(app_version):
|
||||
tags.get(app_version).append(tag)
|
||||
else:
|
||||
tags[app_version] = [tag]
|
||||
version = semantic_versioning(list(tags))
|
||||
if not version:
|
||||
return {}
|
||||
|
||||
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
|
||||
if archi == 'amd64' or archi == '':
|
||||
version_tag = tag
|
||||
break
|
||||
return {
|
||||
'tags': {key: f'{version_tag}'},
|
||||
'app_version': f'{version_tag}',
|
||||
}
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
versions_json = json.loads(sys.stdin.read())
|
||||
except ValueError:
|
||||
raise ValidationException('Invalid JSON')
|
||||
|
||||
print(json.dumps(newer_mapping(versions_json)))
|
||||
1
test/storj/upgrade_info.json
Normal file
1
test/storj/upgrade_info.json
Normal file
@@ -0,0 +1 @@
|
||||
{"filename": "ix_values.yaml", "keys": ["image"], "test_filename": "test_values.yaml"}
|
||||
44
test/storj/upgrade_strategy
Executable file
44
test/storj/upgrade_strategy
Executable file
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/python3
|
||||
import json
|
||||
import sys
|
||||
import re
|
||||
|
||||
from catalog_update.upgrade_strategy import semantic_versioning
|
||||
from catalog_validation.exceptions import ValidationException
|
||||
|
||||
|
||||
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
|
||||
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
|
||||
if tags.get(app_version):
|
||||
tags.get(app_version).append(tag)
|
||||
else:
|
||||
tags[app_version] = [tag]
|
||||
version = semantic_versioning(list(tags))
|
||||
if not version:
|
||||
return {}
|
||||
|
||||
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
|
||||
if archi == 'amd64' or archi == '':
|
||||
version_tag = tag
|
||||
break
|
||||
return {
|
||||
'tags': {key: f'{version_tag}'},
|
||||
'app_version': f'{version_tag}',
|
||||
}
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
versions_json = json.loads(sys.stdin.read())
|
||||
except ValueError:
|
||||
raise ValidationException('Invalid JSON')
|
||||
|
||||
print(json.dumps(newer_mapping(versions_json)))
|
||||
Reference in New Issue
Block a user