-
-
Notifications
You must be signed in to change notification settings - Fork 2k
/
generate_helm_notes.py
72 lines (55 loc) · 1.94 KB
/
generate_helm_notes.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# stdlib
import json
import os
from pathlib import Path
import sys
def add_notes(helm_chart_template_dir: str) -> None:
"""Add notes or information post helm install or upgrade."""
notes = """
Thank you for installing {{ .Chart.Name }}.
Your release is named {{ .Release.Name }}.
To learn more about the release, try:
$ helm status {{ .Release.Name }} -n {{ .Release.Namespace }}
$ helm get all {{ .Release.Name }}
"""
notes_path = os.path.join(helm_chart_template_dir, "NOTES.txt")
protocol_changelog = get_protocol_changes()
notes += "\n" + protocol_changelog
with open(notes_path, "w") as fp:
fp.write(notes)
def get_protocol_changes() -> str:
"""Generate change log of the dev protocol state."""
script_path = os.path.dirname(os.path.realpath(__file__))
protocol_path = Path(
os.path.normpath(
os.path.join(
script_path,
"../../",
"syft/src/syft/protocol",
"protocol_version.json",
)
)
)
protocol_changes = ""
if protocol_path.exists():
dev_protocol_changes = json.loads(protocol_path.read_text()).get("dev", {})
protocol_changes = json.dumps(
dev_protocol_changes.get("object_versions", {}), indent=4
)
protocol_changelog = f"""
Following class versions are either added/removed.
{protocol_changes}
This means the existing data will be automatically be migrated to
their latest class versions during the upgrade.
"""
return protocol_changelog
if __name__ == "__main__":
# write code to path from user and pass to generate notes
if len(sys.argv) != 2:
print("Please provide helm chart template directory path")
sys.exit(1)
helm_chart_template_dir = sys.argv[1]
add_notes(helm_chart_template_dir)
print("=" * 50)
print("Notes Generated Successfully")
print("=" * 50)