Skip to content

Commit

Permalink
read ecosystem from filesystem
Browse files Browse the repository at this point in the history
  • Loading branch information
piax93 committed Jul 19, 2024
1 parent a93571e commit 3f93d70
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
11 changes: 7 additions & 4 deletions paasta_tools/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 0 additions & 14 deletions tests/cli/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@

import ephemeral_port_reserve
import mock
import pytest
from mock import call
from mock import patch
from pytest import mark
from pytest import raises

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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 3f93d70

Please sign in to comment.