Skip to content

Commit

Permalink
Fix construction of repo-policy-compliance from config
Browse files Browse the repository at this point in the history
  • Loading branch information
yhaliaw committed Aug 27, 2024
1 parent 895206e commit 81815c4
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
3 changes: 1 addition & 2 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1243,8 +1243,7 @@ def _get_runner_scaler(
proxy_config=state.proxy_config,
dockerhub_mirror=state.charm_config.dockerhub_mirror,
ssh_debug_connections=state.ssh_debug_connections,
repo_policy_url=state.charm_config.repo_policy_compliance.url,
repo_policy_token=state.charm_config.repo_policy_compliance.token,
repo_policy_compliance=state.charm_config.repo_policy_compliance,
)
openstack_runner_manager = OpenStackRunnerManager(
app_name,
Expand Down
8 changes: 3 additions & 5 deletions src/manager/cloud_runner_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from enum import Enum, auto
from typing import Iterator, Sequence, Tuple

from charm_state import GitHubPath, ProxyConfig, SSHDebugConnection
from charm_state import GitHubPath, ProxyConfig, RepoPolicyComplianceConfig, SSHDebugConnection
from metrics.runner import RunnerMetrics

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -110,15 +110,13 @@ class SupportServiceConfig:
proxy_config: The proxy configuration.
dockerhub_mirror: The dockerhub mirror to use for runners.
ssh_debug_connections: The information on the ssh debug services.
repo_policy_url: The URL of the repo policy service.
repo_policy_token: The token to access the repo policy service.
repo_policy_compliance: The configuration of the repo policy compliance service.
"""

proxy_config: ProxyConfig | None
dockerhub_mirror: str | None
ssh_debug_connections: list[SSHDebugConnection] | None
repo_policy_url: str | None
repo_policy_token: str | None
repo_policy_compliance: RepoPolicyComplianceConfig | None


@dataclass
Expand Down
5 changes: 3 additions & 2 deletions src/openstack_cloud/openstack_runner_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,9 +460,10 @@ def _get_repo_policy_compliance_client(self) -> RepoPolicyComplianceClient | Non
Returns:
The repo policy compliance client.
"""
if self._service_config.repo_policy_url and self._service_config.repo_policy_token:
if self._service_config.repo_policy_compliance is not None:
return RepoPolicyComplianceClient(
self._service_config.repo_policy_url, self._service_config.repo_policy_token
self._service_config.repo_policy_compliance.url,
self._service_config.repo_policy_compliance.token,
)
return None

Expand Down
3 changes: 1 addition & 2 deletions tests/integration/test_runner_manager_openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ async def openstack_runner_manager_fixture(
proxy_config=proxy_config,
dockerhub_mirror=None,
ssh_debug_connections=None,
repo_policy_url=None,
repo_policy_token=None,
repo_policy_compliance=None,
)
return OpenStackRunnerManager(
app_name, cloud_config, server_config, runner_config, service_config
Expand Down

0 comments on commit 81815c4

Please sign in to comment.