[skip e2e]add script to get chart version by app version (#24954)

Signed-off-by: zhuwenxing <wenxing.zhu@zilliz.com>
This commit is contained in:
zhuwenxing 2023-06-16 16:34:39 +08:00 committed by GitHub
parent 9250423288
commit 969517f910
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,29 @@
import subprocess
import json
def get_chart_version(repo = "milvus/milvus", app_version="2.2.0"):
"""
Get helm chart version by app version
"""
cmd = f"helm search repo {repo} -l -o json"
result = subprocess.check_output(cmd, shell=True)
result = json.loads(result)
all_chart_versions = []
for item in result:
if item["app_version"] == app_version:
all_chart_versions.append(item["version"])
if len(all_chart_versions) == 0:
raise Exception(f"Cannot find helm chart version for app version {app_version}")
all_chart_versions.sort()
result = all_chart_versions[-1]
return result
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser(description="Get helm charts version by app version")
parser.add_argument("--app-version", type=str, default="2.2.0", help="app version")
parser.add_argument("--repo", type=str, default="milvus/milvus", help="helm repo")
args = parser.parse_args()
repo = args.repo
app_version = args.app_version
chart_version = get_chart_version(repo=repo, app_version=app_version)
print(chart_version)