From b1fd515620c5a1d948e276a3ce2712d73a277518 Mon Sep 17 00:00:00 2001 From: TheBurchLog <5104941+TheBurchLog@users.noreply.github.com> Date: Fri, 13 Sep 2024 09:10:11 -0400 Subject: [PATCH 1/4] Default namespace to None for System Client and use Garden Name --- CHANGELOG.rst | 6 ++++++ brewtils/rest/system_client.py | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index e0c7bd9b..2c6e03ea 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,12 @@ Brewtils Changelog ================== +3.27.3 +------ +9/12/24 + +- Updated SystemClient to utilize the local Garden name for default Namespace if none can be determine + 3.27.2 ------ 9/12/24 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, From ec68587891080503544323c2a6d8c2c649a8c861 Mon Sep 17 00:00:00 2001 From: TheBurchLog <5104941+TheBurchLog@users.noreply.github.com> Date: Fri, 13 Sep 2024 09:32:57 -0400 Subject: [PATCH 2/4] Update Testing --- test/rest/system_client_test.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/rest/system_client_test.py b/test/rest/system_client_test.py index b1411caf..c835d491 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): From d4b11fb256aa2134180fff5fc8d60fad467bbe8d Mon Sep 17 00:00:00 2001 From: TheBurchLog <5104941+TheBurchLog@users.noreply.github.com> Date: Fri, 13 Sep 2024 09:34:15 -0400 Subject: [PATCH 3/4] formatting --- test/rest/system_client_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/rest/system_client_test.py b/test/rest/system_client_test.py index c835d491..036c76b7 100644 --- a/test/rest/system_client_test.py +++ b/test/rest/system_client_test.py @@ -38,7 +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.get_config.return_value = {"garden_name": bg_system.namespace} mock.client.bg_host = "localhost" mock.client.bg_port = 3000 From 85e35f5239ab2a62371b73ec87fcb3c8cb84daad Mon Sep 17 00:00:00 2001 From: TheBurchLog <5104941+TheBurchLog@users.noreply.github.com> Date: Tue, 17 Sep 2024 06:19:50 -0400 Subject: [PATCH 4/4] Update CHANGELOG.rst --- CHANGELOG.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 2c6e03ea..9ca8b8f7 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -3,9 +3,9 @@ Brewtils Changelog 3.27.3 ------ -9/12/24 +TBD -- Updated SystemClient to utilize the local Garden name for default Namespace if none can be determine +- Updated SystemClient to utilize the local Garden name for default Namespace if none can be determined 3.27.2 ------