Skip to content

Commit

Permalink
And now nightlies are passing (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
nfx authored Aug 11, 2023
1 parent 8d6b487 commit b9886ef
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 23 deletions.
28 changes: 7 additions & 21 deletions src/uc_migration_toolkit/managers/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,6 @@ def _find_eligible_groups(self) -> list[str]:
logger.info(f"Found {len(eligible_groups)} eligible groups")
return [g.display_name for g in eligible_groups]

@staticmethod
def _get_clean_group_info(group: Group, cleanup_keys: list[str] | None = None) -> dict:
"""
Returns a dictionary with group information, excluding some keys
:param group: Group object from SDK
:param cleanup_keys: default (with None) ["id", "externalId", "displayName"]
:return: dictionary with group information
"""

cleanup_keys = cleanup_keys or ["id", "externalId", "displayName"]
group_info = group.as_dict()

for key in cleanup_keys:
if key in group_info:
group_info.pop(key)

return group_info

def _get_group(self, group_name, level: GroupLevel) -> Group | None:
# TODO: calling this can cause issues for SCIM backend, cache groups instead
method = self._ws.groups.list if level == GroupLevel.WORKSPACE else self._ws.list_account_level_groups
Expand All @@ -76,9 +58,13 @@ def _get_or_create_backup_group(self, source_group_name: str, source_group: Grou
logger.info(f"Backup group {backup_group_name} already exists, no action required")
else:
logger.info(f"Creating backup group {backup_group_name}")
new_group_payload = self._get_clean_group_info(source_group)
new_group_payload["displayName"] = backup_group_name
backup_group = self._ws.groups.create(**new_group_payload)
backup_group = self._ws.groups.create(
display_name=backup_group_name,
meta=source_group.meta,
entitlements=source_group.entitlements,
roles=source_group.roles,
members=source_group.members,
)
logger.info(f"Backup group {backup_group_name} successfully created")

return backup_group
Expand Down
10 changes: 8 additions & 2 deletions src/uc_migration_toolkit/managers/inventory/inventorizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,21 @@ def __init__(self, ws: ImprovedWorkspaceClient):

def _preload_tokens(self):
try:
return self._ws.token_management.get_token_permissions().access_control_list
# TODO: rewrite with self._ws.token_management.get_token_permissions().access_control_list
return self._ws.api_client.do("GET", "/api/2.0/preview/permissions/authorization/tokens").get(
"access_control_list", []
)
except DatabricksError as e:
logger.warning("Cannot load token permissions due to error:")
logger.warning(e)
return []

def _preload_passwords(self):
try:
return self._ws.users.get_password_permissions().access_control_list
# TODO: rewrite with return self._ws.users.get_password_permissions().access_control_list
return self._ws.api_client.do("GET", "/api/2.0/preview/permissions/authorization/passwords").get(
"access_control_list", []
)
except DatabricksError as e:
logger.error("Cannot load password permissions due to error:")
logger.error(e)
Expand Down

0 comments on commit b9886ef

Please sign in to comment.