Skip to content

Commit

Permalink
Merge pull request #265 from ImMin5/feature-service-accont-auto-sync
Browse files Browse the repository at this point in the history
Fix create workspace error when skip project group
  • Loading branch information
ImMin5 authored Apr 18, 2024
2 parents fb19e62 + 24857e4 commit d585b22
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions src/spaceone/identity/service/job_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,21 @@ def sync_service_accounts(self, params: dict) -> None:
)

if trusted_account_vo.resource_group == "DOMAIN":
if not sync_options.get("single_workspace_id"):
if sync_options.get("single_workspace_id"):
workspace_vo = self.workspace_mgr.get_workspace(
sync_options.get("single_workspace_id"), domain_id
)
elif location:
location_info = location.pop(0)
workspace_vo = self._create_workspace(
domain_id, trusted_account_id, location.pop(0)
domain_id, trusted_account_id, location_info
)
else:
workspace_vo = self.workspace_mgr.get_workspace(
sync_options.get("single_workspace_id"), domain_id
_LOGGER.debug(
f"[sync_service_accounts] location is empty => SKIP"
)
continue

sync_workspace_id = workspace_vo.workspace_id

else:
Expand Down Expand Up @@ -703,11 +710,21 @@ def _create_service_account(

@staticmethod
def _get_location(result: dict, resource_group: str, sync_options: dict) -> list:
location = []
if not sync_options.get("skip_project_group", False):
location = result.get("location", [])
location = result.get("location", [])
skip_project_group_option = sync_options.get("skip_project_group")

if skip_project_group_option:
if resource_group == "DOMAIN":
if location:
location = [location[0]]
else:
location = []

else:
if resource_group == "DOMAIN" and not location:
_LOGGER.debug(f"[_get_location] location is empty: {result} => SKIP")
_LOGGER.debug(
f"[_get_location] location is empty: {result} {sync_options} => SKIP"
)
# raise ERROR_REQUIRED_PARAMETER(
# key="location", reason="location is required"
# )
Expand Down

0 comments on commit d585b22

Please sign in to comment.