|
5 | 5 | import uuid |
6 | 6 | from typing import Dict, List, Optional, Tuple |
7 | 7 |
|
8 | | -from kubetester.consts import ( |
| 8 | +from tests import test_logger |
| 9 | +from tests.constants import ( |
| 10 | + DEFAULT_HELM_CHART_PATH_ENV_VAR_NAME, |
9 | 11 | OCI_HELM_REGION_ENV_VAR_NAME, |
10 | 12 | OCI_HELM_REGISTRY_ENV_VAR_NAME, |
11 | | - OCI_HELM_REPOSITORY_ENV_VAR_NAME, |
12 | | - OCI_HELM_VERSION, |
| 13 | + OCI_HELM_VERSION_ENV_VAR_NAME, |
13 | 14 | ) |
14 | | -from tests import test_logger |
15 | 15 |
|
16 | 16 | logger = test_logger.get_test_logger(__name__) |
17 | 17 |
|
@@ -241,19 +241,6 @@ def helm_upgrade( |
241 | 241 | process_run_and_check(command, check=True, capture_output=True, shell=True) |
242 | 242 |
|
243 | 243 |
|
244 | | -# oci_chart_info returns the respective registry/repo and region information |
245 | | -# based on the build scenario (dev/staging) tests are being run in. These are |
246 | | -# read from build_info.json and then set to the tests image as env vars. |
247 | | -def oci_chart_info(): |
248 | | - registry = os.environ.get(OCI_HELM_REGISTRY_ENV_VAR_NAME) |
249 | | - repository = os.environ.get(OCI_HELM_REPOSITORY_ENV_VAR_NAME) |
250 | | - region = os.environ.get(OCI_HELM_REGION_ENV_VAR_NAME) |
251 | | - |
252 | | - logger.info(f"oci chart details in test image is registry {registry}, repo {repository}, region {region}") |
253 | | - |
254 | | - return registry, f"{repository}/mongodb-kubernetes", region |
255 | | - |
256 | | - |
257 | 244 | def apply_crds_from_chart(crds_dir: str): |
258 | 245 | crd_files = glob.glob(os.path.join(crds_dir, "*.yaml")) |
259 | 246 |
|
@@ -308,28 +295,22 @@ def _create_helm_args(helm_args: Dict[str, str], helm_options: Optional[List[str |
308 | 295 | # based on the caller. In most of the cases we will install chart from OCI registry but for the tests where we would like |
309 | 296 | # to install MEKO's specific version or MCK's specific version, we would expect `helm_chart_path` to set already. |
310 | 297 | def helm_chart_path_and_version(helm_chart_path: str, operator_version: str) -> tuple[str, str]: |
311 | | - # these are imported here to resolve import cycle issue |
312 | | - from tests.conftest import LOCAL_HELM_CHART_DIR, local_operator |
313 | | - |
314 | | - if local_operator(): |
315 | | - return LOCAL_HELM_CHART_DIR, "" |
316 | | - |
317 | | - # helm_chart_path not being passed would mean we would like to install helm chart from OCI registry. |
| 298 | + # if helm_chart_path is not passed, use the default value from DEFAULT_HELM_CHART_PATH |
318 | 299 | if not helm_chart_path: |
| 300 | + helm_chart_path = os.getenv(DEFAULT_HELM_CHART_PATH_ENV_VAR_NAME) |
| 301 | + |
| 302 | + if helm_chart_path.startswith("oci://"): |
319 | 303 | # If operator_version is not passed, we want to install the current version. |
320 | 304 | if not operator_version: |
321 | | - operator_version = os.environ.get(OCI_HELM_VERSION) |
| 305 | + operator_version = os.environ.get(OCI_HELM_VERSION_ENV_VAR_NAME) |
322 | 306 |
|
323 | | - registry, repository, region = oci_chart_info() |
| 307 | + registry = os.environ.get(OCI_HELM_REGISTRY_ENV_VAR_NAME) |
324 | 308 | # If ECR we need to login first to the OCI container registry |
325 | 309 | if registry == OCI_HELM_REGISTRY_ECR: |
| 310 | + region = os.environ.get(OCI_HELM_REGION_ENV_VAR_NAME) |
326 | 311 | try: |
327 | 312 | helm_registry_login_to_ecr(registry, region) |
328 | 313 | except Exception as e: |
329 | 314 | raise Exception(f"Failed to login to ECR helm registry {registry}. Error: {e}") |
330 | 315 |
|
331 | | - # figure out the registry URI, based on dev/staging scenario |
332 | | - chart_uri = f"oci://{registry}/{repository}" |
333 | | - helm_chart_path = chart_uri |
334 | | - |
335 | 316 | return helm_chart_path, operator_version |
0 commit comments