11import argparse
22import os
33import subprocess
4- import sys
54
65import yaml
76
@@ -28,7 +27,7 @@ def run_command(command: list[str]):
2827
2928# update_chart_and_get_metadata updates the helm chart's Chart.yaml and sets the version
3029# to either evg patch id or commit which is set in OPERATOR_VERSION.
31- def update_chart_and_get_metadata (chart_dir : str , build_scenario ) -> tuple [str , str ]:
30+ def update_chart_and_get_metadata (chart_dir : str , version_prefix : str = None ) -> tuple [str , str ]:
3231 chart_path = os .path .join (chart_dir , "Chart.yaml" )
3332 version = os .environ .get ("OPERATOR_VERSION" )
3433 if not version :
@@ -50,13 +49,15 @@ def update_chart_and_get_metadata(chart_dir: str, build_scenario) -> tuple[str,
5049 if not chart_name :
5150 raise ValueError ("Chart.yaml is missing required 'name' field." )
5251 except Exception as e :
53- raise Exception (f"Unable to load Chart.yaml from dir { chart_path } " )
52+ raise Exception (f"Unable to load Chart.yaml from dir { chart_path } : { e } " )
5453
55- # if build_scenario is release , the chart.yaml would already have correct chart version
56- if build_scenario == BuildScenario . RELEASE :
54+ # If version_prefix is not specified , the chart.yaml would already have correct chart version
55+ if version_prefix is None :
5756 return chart_name , version
5857
59- new_version = f"0.0.0+{ version } "
58+ # When we publish the helm chart to dev and staging we append `0.0.0+` in the chart version, details are
59+ # here https://docs.google.com/document/d/1eJ8iKsI0libbpcJakGjxcPfbrTn8lmcZDbQH1UqMR_g/edit?tab=t.gg5ble8qlesq
60+ new_version = f"{ version_prefix } { version } "
6061 logger .info (f"New helm chart version will be: { new_version } " )
6162
6263 try :
@@ -79,7 +80,7 @@ def get_oci_registry(chart_info: HelmChartInfo) -> str:
7980 raise ValueError ("Error: registry doesn't seem to be set in HelmChartInfo." )
8081
8182 if not repo :
82- raise ValueError ("Error: reposiotry doesn't seem to be set in HelmChartInfo." )
83+ raise ValueError ("Error: repository doesn't seem to be set in HelmChartInfo." )
8384
8485 oci_registry = f"oci://{ registry } /{ repo } "
8586 logger .info (f"Determined OCI Registry: { oci_registry } " )
@@ -89,7 +90,7 @@ def get_oci_registry(chart_info: HelmChartInfo) -> str:
8990def publish_helm_chart (chart_info : HelmChartInfo , build_scenario ):
9091 try :
9192 oci_registry = get_oci_registry (chart_info )
92- chart_name , chart_version = update_chart_and_get_metadata (CHART_DIR , build_scenario )
93+ chart_name , chart_version = update_chart_and_get_metadata (CHART_DIR , chart_info . version_prefix )
9394 tgz_filename = f"{ chart_name } -{ chart_version } .tgz"
9495
9596 logger .info (f"Packaging chart: { chart_name } with Version: { chart_version } " )
@@ -121,6 +122,5 @@ def main():
121122if __name__ == "__main__" :
122123 try :
123124 main ()
124- except Exception as e :
125- logger .error (f"Failure in the helm publishing process { e } " )
126- sys .exit (1 )
125+ except Exception as main_err :
126+ raise Exception (f"Failure in the helm publishing process { main_err } " )
0 commit comments