-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathlock_versions
More file actions
executable file
·53 lines (41 loc) · 1.32 KB
/
lock_versions
File metadata and controls
executable file
·53 lines (41 loc) · 1.32 KB
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
#!/usr/bin/env python3
import sys
import re
def show_help():
print(f"Usage: {sys.argv[0]} <version_tag>")
print("")
print(
"Updates container image tags in braintrust/values.yaml to the specified version"
)
print("")
print("Arguments:")
print(" version_tag The version tag to set for both API and Brainstore images")
print("")
print("Examples:")
print(f" {sys.argv[0]} v1.2.3")
print(f" {sys.argv[0]} 0.9.0")
print(f" {sys.argv[0]} latest")
def main():
if len(sys.argv) > 1 and sys.argv[1] in ["-h", "--help"]:
show_help()
return
if len(sys.argv) < 2:
print("Error: Please provide a version tag as the first argument")
print("")
show_help()
sys.exit(1)
version_tag = sys.argv[1]
values_file = "braintrust/values.yaml"
print(f"Updating container image tags to version: {version_tag}")
try:
with open(values_file, "r") as f:
content = f.read()
# This is naive and will replace all tag values with the new version
content = re.sub(r"(tag: ).*", r"\1" + version_tag, content)
with open(values_file, "w") as f:
f.write(content)
except Exception as e:
print(f"Error updating file: {e}")
sys.exit(1)
if __name__ == "__main__":
main()