Skip to content

Commit 3942069

Browse files
authored
Added group members difference to the output of validate-groups-membership cli command (#995)
The `validate-groups-membership` command has been updated to include a comparison of group memberships at both the account and workspace levels, displaying the difference in members between the two levels in a new column. This enhancement allows for a more detailed analysis of group memberships, with the added functionality implemented in the `validate_group_membership` function in the `groups.py` file located in the `databricks/labs/ucx/workspace_access` directory. A new output field, "group\_members\_difference," has been added to represent the difference in the number of members between a workspace group and an associated account group. The corresponding unit test file, "test\_groups.py," has been updated to include a new test case that verifies the calculation of the "group\_members\_difference" value. This change provides users with a more comprehensive view of their group memberships and allows them to easily identify any discrepancies between the account and workspace levels. The functionality of the other commands remains unchanged.
1 parent df6ccb2 commit 3942069

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

labs.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ commands:
109109
description: AWS Profile to use for authentication
110110

111111
- name: validate-groups-membership
112-
description: Validate the groups to see if the groups at account level and workspace level have different membership
112+
description: Validate groups to check if the groups at account level and workspace level have different memberships
113113
table_template: |-
114-
Workspace Group Name\tMembers Count\tAccount Group Name\tMembers Count
115-
{{range .}}{{.wf_group_name}}\t{{.wf_group_members_count}}\t{{.acc_group_name}}\t{{.acc_group_members_count}}
114+
Workspace Group Name\tMembers Count\tAccount Group Name\tMembers Count\tDifference
115+
{{range .}}{{.wf_group_name}}\t{{.wf_group_members_count}}\t{{.acc_group_name}}\t{{.acc_group_members_count}}\t{{.group_members_difference}}
116116
{{end}}
117117
118118
- name: migrate_credentials

src/databricks/labs/ucx/workspace_access/groups.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ def validate_group_membership(self) -> list[dict]:
456456
"wf_group_members_count": len(ws_members_set),
457457
"acc_group_name": ws_group.name_in_account,
458458
"acc_group_members_count": len(acc_members_set),
459+
"group_members_difference": len(ws_members_set) - len(acc_members_set),
459460
}
460461
)
461462
if not mismatch_group:

tests/unit/workspace_access/test_groups.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,7 @@ def do_api_side_effect(*args, **_):
866866
"wf_group_members_count": 2,
867867
"acc_group_name": "ac_test_1234",
868868
"acc_group_members_count": 1,
869+
"group_members_difference": 1,
869870
}
870871
]
871872

0 commit comments

Comments
 (0)