diff --git a/CHANGELOG.rst b/CHANGELOG.rst index ae373c3d..5ab8d9cc 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,7 @@ Brewtils Changelog TBD - Apply MD5 Check Sum of chunked files to ensure files are loaded into memory properly +- Updated SystemClient to utilize the local Garden name for default Namespace if none can be determined 3.27.2 ------ diff --git a/brewtils/rest/system_client.py b/brewtils/rest/system_client.py index cb2a1b3f..374f673f 100644 --- a/brewtils/rest/system_client.py +++ b/brewtils/rest/system_client.py @@ -239,14 +239,14 @@ def __init__(self, *args, **kwargs): self._system_name = brewtils.plugin.CONFIG.name self._version_constraint = brewtils.plugin.CONFIG.version self._default_instance = brewtils.plugin.CONFIG.instance_name - self._system_namespace = brewtils.plugin.CONFIG.namespace or "" + self._system_namespace = brewtils.plugin.CONFIG.namespace or None else: self._system_name = kwargs.get("system_name") self._version_constraint = kwargs.get("version_constraint", "latest") self._default_instance = kwargs.get("default_instance", "default") self._system_namespace = kwargs.get( - "system_namespace", brewtils.plugin.CONFIG.namespace or "" + "system_namespace", brewtils.plugin.CONFIG.namespace or None ) self._system_namespaces = kwargs.get("system_namespaces", []) @@ -278,6 +278,10 @@ def __init__(self, *args, **kwargs): kwargs.setdefault("stacklevel", 5) self._easy_client = EasyClient(*args, **kwargs) + + if self._system_namespace is None: + self._system_namespace = self._easy_client.get_config()["garden_name"] + self._resolver = ResolutionManager(easy_client=self._easy_client) self.local_request_handler = LocalRequestProcessor( system=self._system, diff --git a/test/rest/system_client_test.py b/test/rest/system_client_test.py index b1411caf..036c76b7 100644 --- a/test/rest/system_client_test.py +++ b/test/rest/system_client_test.py @@ -38,6 +38,7 @@ def easy_client(monkeypatch, bg_system): mock = Mock(name="easy_client") mock.find_unique_system.return_value = bg_system mock.find_systems.return_value = [bg_system] + mock.get_config.return_value = {"garden_name": bg_system.namespace} mock.client.bg_host = "localhost" mock.client.bg_port = 3000 @@ -104,7 +105,7 @@ def test_latest(self, client, easy_client, bg_system, bg_system_2): assert client.bg_system == bg_system_2 assert client.bg_default_instance == "default" easy_client.find_systems.assert_called_once_with( - name=bg_system.name, namespace="", filter_latest=True + name=bg_system.name, namespace="ns", filter_latest=True ) @pytest.mark.parametrize( @@ -120,7 +121,7 @@ def test_non_latest(self, client, easy_client, bg_system, constraint, systems): assert client.bg_system == bg_system easy_client.find_unique_system.assert_called_once_with( - name=bg_system.name, version=constraint, namespace="" + name=bg_system.name, version=constraint, namespace="ns" ) def test_failure_with_constraint(self, client, easy_client): @@ -219,7 +220,7 @@ def test_non_plugin(self): assert client._system_name is None assert client._version_constraint == "latest" assert client._default_instance == "default" - assert client._system_namespace == "" + assert client._system_namespace == "ns" class TestCreateRequest(object):