-
Notifications
You must be signed in to change notification settings - Fork 0
/
upgrade_system.py
executable file
·39 lines (29 loc) · 1.24 KB
/
upgrade_system.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python3
# Upgrades system charts to highest available semver-compatible versions of our charts
from os import path
from yaml import load, dump
try:
from yaml import CLoader as Loader, CDumper as Dumper
except ImportError:
from yaml import Loader, Dumper
import glob
import semver
CHART_DIRECTORIES = "charts/*"
CHART_VERSIONS = {}
for dir in glob.glob(CHART_DIRECTORIES):
if path.exists(path.join(dir, "Chart.yaml")):
with open(path.join(dir, "Chart.yaml"), "r") as f:
chart = load(f, Loader)
CHART_VERSIONS[chart["name"]] = chart["version"]
upgraded = False
with open(path.join("charts/system/", "Chart.yaml"), "r") as f:
chart = load(f, Loader)
for i, dep in enumerate(chart["dependencies"]):
if "repository" in dep and dep["repository"] == "https://restorecommerce.github.io/charts/":
if CHART_VERSIONS[dep["name"]] != chart["dependencies"][i]["version"]:
upgraded = True
chart["dependencies"][i]["version"] = CHART_VERSIONS[dep["name"]]
if upgraded:
chart["version"] = str(semver.VersionInfo.parse(chart["version"]).bump_patch())
with open(path.join("charts/system/", "Chart.yaml"), "w") as f:
dump(chart, f, Dumper)