diff --git a/paasta_tools/cli/utils.py b/paasta_tools/cli/utils.py index e77a4d8b24..979fbff996 100644 --- a/paasta_tools/cli/utils.py +++ b/paasta_tools/cli/utils.py @@ -1104,10 +1104,13 @@ def get_paasta_oapi_api_clustername(cluster: str, is_eks: bool) -> str: def get_current_ecosystem() -> str: - """Infer ecosystem from local-run configuration""" - local_run_config = load_system_paasta_config().get_local_run_config() - ecosystem = local_run_config["default_cluster"].split("-", 1)[-1] - return f"{ecosystem}prod" if ecosystem == "corp" else ecosystem + """Get current ecosystem from host configs, defaults to dev if no config is found""" + try: + with open("/nail/etc/ecosystem") as f: + return f.read().strip() + except IOError: + pass + return "devc" def get_service_auth_token() -> str: diff --git a/tests/cli/test_utils.py b/tests/cli/test_utils.py index 012d35cf8e..8379c245e6 100644 --- a/tests/cli/test_utils.py +++ b/tests/cli/test_utils.py @@ -17,7 +17,6 @@ import ephemeral_port_reserve import mock -import pytest from mock import call from mock import patch from pytest import mark @@ -25,7 +24,6 @@ from paasta_tools.cli import utils from paasta_tools.cli.utils import extract_tags -from paasta_tools.cli.utils import get_current_ecosystem from paasta_tools.cli.utils import get_service_auth_token from paasta_tools.cli.utils import select_k8s_secret_namespace from paasta_tools.cli.utils import verify_instances @@ -481,18 +479,6 @@ def test_select_k8s_secret_namespace(): assert select_k8s_secret_namespace(namespaces) in {"a", "b"} -@pytest.mark.parametrize( - "default_cluster,expected", - (("whatever-dev", "dev"), ("something-corp", "corpprod")), -) -@patch("paasta_tools.cli.utils.load_system_paasta_config", autospec=True) -def test_get_current_ecosystem(mock_config, default_cluster, expected): - mock_config.return_value.get_local_run_config.return_value = { - "default_cluster": default_cluster - } - assert get_current_ecosystem() == expected - - @patch("paasta_tools.cli.utils.load_system_paasta_config", autospec=True) @patch("paasta_tools.cli.utils.get_current_ecosystem", autospec=True) @patch("paasta_tools.cli.utils.InstanceMetadataProvider", autospec=True)