@@ -300,3 +300,45 @@ def _create_helm_args(helm_args: Dict[str, str], helm_options: Optional[List[str
300300
301301def _helm_chart_dir (default : Optional [str ] = "helm_chart" ) -> str :
302302 return os .environ .get ("HELM_CHART_DIR" , default )
303+
304+
305+ # helm_chart_path_and_version returns the chart path and version that we would like to install to run the E2E tests.
306+ # for local tests it returns early with local helm chart dir and for other scenarios it figure out the chart and version
307+ # based on the caller. In most of the cases we will install chart from OCI registry but for the tests where we would like
308+ # to install MEKO's specific version or MCK's specific version, we would expec `helm_chart_path` to set already.
309+ def helm_chart_path_and_version (helm_chart_path : str , operator_version : str ) -> tuple [str , str ]:
310+ # these are imported here to resolve import cycle issue
311+ from tests .conftest import local_operator
312+ from tests .conftest import LOCAL_HELM_CHART_DIR
313+
314+ if local_operator ():
315+ return LOCAL_HELM_CHART_DIR , ""
316+
317+ # if operator_version is not specified and we are not installing the MCK or MEKO chart
318+ # it would mean we want to install OCI published helm chart. Figure out respective version,
319+ # it is set in env var `OPERATOR_VERSION` based on build_scenario.
320+ if not operator_version and helm_chart_path not in (
321+ MCK_HELM_CHART ,
322+ LEGACY_OPERATOR_CHART ,
323+ ):
324+ non_semver_operator_version = os .environ .get (OPERATOR_VERSION_ENV_VAR_NAME )
325+ # when we publish the helm chart we append `0.0.0+` in the chart version, details are
326+ # here https://docs.google.com/document/d/1eJ8iKsI0libbpcJakGjxcPfbrTn8lmcZDbQH1UqMR_g/edit?tab=t.gg5ble8qlesq
327+ operator_version = f"0.0.0+{ non_semver_operator_version } "
328+
329+
330+ # helm_chart_path not being passed would mean we are on evg env and would like to
331+ # install helm chart from OCI registry.
332+ if not helm_chart_path :
333+ # login to the OCI container registry
334+ registry , repository , region = oci_chart_info ()
335+ try :
336+ oci_helm_registry_login (registry , region )
337+ except Exception as e :
338+ raise e
339+
340+ # figure out the registry URI, based on dev/staging scenario
341+ chart_uri = f"oci://{ registry } /{ repository } "
342+ helm_chart_path = chart_uri
343+
344+ return helm_chart_path , operator_version
0 commit comments