Skip to content

Commit fc16c95

Browse files
committed
refactor(config,cli,sdk): remove ConfigurationPort provider_name and provider_type overrides
Delete override_provider_name(), override_provider_type(), get_active_provider_name_override(), and get_active_provider_type_override() from ConfigurationPort, ConfigurationManager, and ConfigurationAdapter. CLI main.py: remove the two container.get(ConfigurationPort) blocks that called the now-deleted override methods. The args.provider_name and args.provider_type values already flow end-to-end through Input DTOs. SDK client.py: remove the initialize() block that called override_provider_type and override_provider_name on the config port. SDKConfig.provider_name / provider_type already reach Input DTOs via the existing pattern in each explicit SDK method (e.g. provider_name=kwargs.get("provider_name") or self._config.provider_name). Tests for the deleted methods removed; docstring stale references updated.
1 parent d4087f7 commit fc16c95

11 files changed

Lines changed: 30 additions & 151 deletions

File tree

src/orb/application/queries/provider_handlers.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,27 +57,22 @@ async def execute_query(self, query: GetProviderHealthQuery) -> dict[str, Any]:
5757
provider_name = query.provider_name
5858
if not provider_name:
5959
try:
60-
selection_result = self._provider_registry_service.select_active_provider()
61-
candidate_name = selection_result.provider_name
62-
# When provider_type is set, only return health if types match
63-
if query.provider_type:
64-
candidate_type = getattr(selection_result, "provider_type", None)
65-
if candidate_type and candidate_type != query.provider_type:
66-
return {
67-
"provider_name": None,
68-
"status": "not_found",
69-
"health": "unknown",
70-
"message": f"No active provider of type '{query.provider_type}' found",
71-
}
72-
provider_name = candidate_name
60+
selection_result = self._provider_registry_service.select_active_provider(
61+
provider_type=query.provider_type,
62+
)
63+
provider_name = selection_result.provider_name
7364
self.logger.debug("Using active provider: %s", provider_name)
7465
except Exception as e:
7566
self.logger.warning("Failed to get active provider: %s", e, exc_info=True)
7667
return {
7768
"provider_name": None,
7869
"status": "not_found",
7970
"health": "unknown",
80-
"message": "No active provider found",
71+
"message": (
72+
f"No active provider of type '{query.provider_type}' found"
73+
if query.provider_type
74+
else "No active provider found"
75+
),
8176
}
8277

8378
# Get health information from registry service

src/orb/cli/main.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -125,28 +125,6 @@ async def main() -> None:
125125
except Exception as e:
126126
logger.warning("Failed to override scheduler strategy: %s", e, exc_info=True)
127127

128-
if hasattr(args, "provider_name") and args.provider_name:
129-
try:
130-
from orb.domain.base.ports.configuration_port import ConfigurationPort
131-
from orb.infrastructure.di.container import get_container
132-
133-
container = get_container()
134-
config = container.get(ConfigurationPort)
135-
config.override_provider_name(args.provider_name)
136-
except Exception as e:
137-
logger.warning("Failed to override provider name: %s", e, exc_info=True)
138-
139-
if hasattr(args, "provider_type") and args.provider_type:
140-
try:
141-
from orb.domain.base.ports.configuration_port import ConfigurationPort
142-
from orb.infrastructure.di.container import get_container
143-
144-
container = get_container()
145-
config = container.get(ConfigurationPort)
146-
config.override_provider_type(args.provider_type)
147-
except Exception as e:
148-
logger.warning("Failed to override provider type: %s", e, exc_info=True)
149-
150128
# Skip application initialization for init command
151129
if args.resource == "init":
152130
from orb.interface.init_command_handler import handle_init

src/orb/config/managers/configuration_manager.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ def __init__(
7373

7474
# Scheduler override support
7575
self._scheduler_override: Optional[str] = None
76-
self._provider_name_override: Optional[str] = None
77-
self._provider_type_override: Optional[str] = None
7876

7977
@property
8078
def loader(self) -> ConfigurationLoader:
@@ -283,22 +281,6 @@ def restore_scheduler_strategy(self) -> None:
283281
"""Restore original scheduler strategy."""
284282
self._scheduler_override = None
285283

286-
def override_provider_name(self, provider_name: str) -> None:
287-
"""Temporarily override provider instance by exact name."""
288-
self._provider_name_override = provider_name
289-
290-
def override_provider_type(self, provider_type: str) -> None:
291-
"""Temporarily restrict selection to a provider type."""
292-
self._provider_type_override = provider_type
293-
294-
def get_active_provider_name_override(self) -> Optional[str]:
295-
"""Get current provider name override."""
296-
return self._provider_name_override
297-
298-
def get_active_provider_type_override(self) -> Optional[str]:
299-
"""Get current provider type override."""
300-
return self._provider_type_override
301-
302284
def get_loaded_config_file(self) -> str | None:
303285
"""Get the actual config file that was loaded."""
304286
# If a config file path is already stored (set in __init__ or reload), use it

src/orb/domain/base/ports/configuration_port.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,6 @@ def get_native_spec_config(self) -> dict[str, Any]:
7171
def get_metrics_config(self) -> dict[str, Any]:
7272
"""Get metrics configuration."""
7373

74-
@abstractmethod
75-
def get_active_provider_name_override(self) -> str | None:
76-
"""Get current provider name override from CLI (exact instance name)."""
77-
78-
@abstractmethod
79-
def get_active_provider_type_override(self) -> str | None:
80-
"""Get current provider type override from CLI (type filter)."""
81-
82-
@abstractmethod
83-
def override_provider_name(self, provider_name: str) -> None:
84-
"""Override the active provider by exact instance name."""
85-
86-
@abstractmethod
87-
def override_provider_type(self, provider_type: str) -> None:
88-
"""Restrict selection to a provider type."""
89-
9074
# get_provider_instance_config inherited from ProviderConfigPort
9175

9276
@abstractmethod

src/orb/infrastructure/adapters/configuration_adapter.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -380,14 +380,6 @@ def override_scheduler_strategy(self, strategy: str) -> None: # type: ignore[ov
380380
"""Override scheduler strategy - delegate to ConfigurationManager."""
381381
self._config_manager.override_scheduler_strategy(strategy)
382382

383-
def override_provider_name(self, provider_name: str) -> None:
384-
"""Override provider instance by exact name - delegate to ConfigurationManager."""
385-
self._config_manager.override_provider_name(provider_name)
386-
387-
def override_provider_type(self, provider_type: str) -> None:
388-
"""Restrict selection to a provider type - delegate to ConfigurationManager."""
389-
self._config_manager.override_provider_type(provider_type)
390-
391383
def get_resource_prefix(self, resource_type: str) -> str:
392384
"""Get resource naming prefix for the given resource type."""
393385
try:
@@ -401,14 +393,6 @@ def get_resource_prefix(self, resource_type: str) -> str:
401393
)
402394
return ""
403395

404-
def get_active_provider_name_override(self) -> str | None:
405-
"""Get current provider name override from CLI."""
406-
return self._config_manager.get_active_provider_name_override()
407-
408-
def get_active_provider_type_override(self) -> str | None:
409-
"""Get current provider type override from CLI."""
410-
return self._config_manager.get_active_provider_type_override()
411-
412396
def get_configuration_value(self, key: str, default: Any = None) -> Any:
413397
"""Get configuration value."""
414398
return self._config_manager.get(key, default)

src/orb/interface/infrastructure_command_handler.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,10 @@ def _get_active_providers() -> List[Dict[str, Any]]:
229229
def _get_active_providers_with_overrides() -> List[Dict[str, Any]]:
230230
"""Get active providers with provider-name and provider-type overrides applied.
231231
232-
The provider-name and provider-type overrides are already handled by the
233-
caller via ``ConfigurationPort.get_active_provider_name_override()`` and
234-
``get_active_provider_type_override()``. Provider-specific config key
235-
overrides (e.g. AWS region, AWS profile) are not applied here because
236-
they are provider-scoped and do not belong in the provider-agnostic
237-
interface layer.
232+
Provider-name and provider-type filtering is a per-operation concern handled
233+
by each orchestrator's Input DTO. Provider-specific config key overrides
234+
(e.g. AWS region, AWS profile) are not applied here because they are
235+
provider-scoped and do not belong in the provider-agnostic interface layer.
238236
"""
239237
return _get_active_providers()
240238

src/orb/sdk/client.py

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
from orb.bootstrap import Application
1414
from orb.config.managers.configuration_manager import ConfigurationManager
15-
from orb.domain.base.ports.configuration_port import ConfigurationPort
1615
from orb.infrastructure.di.container import create_container
1716

1817
from .config import SDKConfig
@@ -73,11 +72,12 @@ def __init__(
7372
app_config: Application config dict — replaces config.json on disk.
7473
Pass the same structure as config.json to run without filesystem.
7574
scheduler: Scheduler strategy override (e.g. ``"default"`` or ``"hostfactory"``).
76-
provider_type: Provider type filter applied via ConfigurationPort on initialise.
77-
Narrows which provider is selected when multiple providers are
78-
registered (e.g. ``"k8s"``).
79-
provider_name: Provider instance name applied via ConfigurationPort on initialise.
80-
Selects a specific named provider instance (e.g. ``"my-k8s-cluster"``).
75+
provider_type: Provider type filter. Narrows which provider is selected when
76+
multiple providers are registered (e.g. ``"k8s"``). Passed
77+
through to Input DTOs on each operation.
78+
provider_name: Provider instance name. Selects a specific named provider
79+
instance (e.g. ``"my-k8s-cluster"``). Passed through to
80+
Input DTOs on each operation.
8181
provider_config: Provider-specific key/value pairs (e.g. ``{"region": "us-east-1"}``).
8282
region: **Deprecated.** Use ``provider_config={"region": ...}`` instead.
8383
profile: **Deprecated.** Use ``provider_config={"profile": ...}`` instead.
@@ -201,19 +201,6 @@ async def initialize(self) -> bool:
201201
provider=self._config.provider,
202202
)
203203

204-
# Apply provider-name and provider-type overrides from SDK config.
205-
# Use self._container (the per-client isolated container), not the
206-
# module-level singleton returned by get_container(), so that overrides
207-
# from one ORBClient instance never bleed into another.
208-
# provider_config is stored for future use; pushing arbitrary provider
209-
# key/value pairs through a provider-agnostic port is a follow-up task.
210-
if self._config.provider_type or self._config.provider_name:
211-
config_port = self._container.get(ConfigurationPort)
212-
if self._config.provider_type:
213-
config_port.override_provider_type(self._config.provider_type)
214-
if self._config.provider_name:
215-
config_port.override_provider_name(self._config.provider_name)
216-
217204
# Get CQRS buses directly from the initialized application
218205
self._query_bus = self._app.get_query_bus()
219206
self._command_bus = self._app.get_command_bus()

tests/unit/infrastructure/test_configuration_manager.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -217,24 +217,6 @@ def test_no_aws_prefixed_methods_on_configuration_manager(self, tmp_path):
217217
f"Found AWS-specific methods that should be renamed: {aws_methods}"
218218
)
219219

220-
def test_override_provider_name(self, tmp_path):
221-
"""Test overriding provider by exact instance name."""
222-
config_file = tmp_path / "config.json"
223-
config_file.write_text(json.dumps({}))
224-
225-
manager = ConfigurationManager(config_file=str(config_file))
226-
manager.override_provider_name("aws-us-east-1")
227-
assert manager.get_active_provider_name_override() == "aws-us-east-1"
228-
229-
def test_override_provider_type(self, tmp_path):
230-
"""Test overriding provider type filter."""
231-
config_file = tmp_path / "config.json"
232-
config_file.write_text(json.dumps({}))
233-
234-
manager = ConfigurationManager(config_file=str(config_file))
235-
manager.override_provider_type("k8s")
236-
assert manager.get_active_provider_type_override() == "k8s"
237-
238220
def test_override_scheduler_strategy(self, tmp_path):
239221
"""Test overriding scheduler strategy."""
240222
config_file = tmp_path / "config.json"

tests/unit/providers/test_provider_interface.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,21 @@ def test_provider_configuration_validation(self):
5858
# Test base configuration
5959
config = ProviderConfig(provider_type="test")
6060
assert config.provider_type == "test"
61-
assert config.region is None
6261

63-
# Test with region
64-
config_with_region = ProviderConfig(provider_type="test", region="test-region")
65-
assert config_with_region.region == "test-region"
62+
# Test provider-specific fields flow through the opaque provider_config
63+
# dict rather than a typed base-level field.
64+
config_with_provider_config = ProviderConfig(
65+
provider_type="test",
66+
provider_config={"region": "test-region", "profile": "test-profile"}, # type: ignore[call-arg]
67+
)
68+
assert getattr(config_with_provider_config, "provider_config") == {
69+
"region": "test-region",
70+
"profile": "test-profile",
71+
}
6672

6773
# Test extra fields are allowed
6874
config_with_extras = ProviderConfig(
6975
provider_type="test",
70-
region="test-region",
7176
custom_field="custom_value", # type: ignore[call-arg]
7277
)
7378
assert getattr(config_with_extras, "custom_field") == "custom_value"

tests/unit/providers/test_provider_registry.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,9 +399,7 @@ def test_name_override_takes_precedence_over_type_override(self):
399399
aws2 = self._make_provider("aws-eu-west-1", "aws")
400400
registry = _make_registry_multi([aws1, aws2])
401401

402-
result = registry.select_active_provider(
403-
provider_name="aws-eu-west-1", provider_type="aws"
404-
)
402+
result = registry.select_active_provider(provider_name="aws-eu-west-1", provider_type="aws")
405403

406404
assert result.provider_name == "aws-eu-west-1"
407405
assert "name override" in result.selection_reason

0 commit comments

Comments
 (0)