@@ -205,7 +205,9 @@ def generate_migrated_groups(self):
205205 temporary_name = f"{ self .renamed_groups_prefix } { group .display_name } "
206206 account_group = self .account_groups_in_account .get (group .display_name )
207207 if not account_group :
208- logger .info (f"Couldn't find a matching account group for { group .display_name } group" )
208+ logger .info (
209+ f"Couldn't find a matching account group for { group .display_name } group using name matching"
210+ )
209211 continue
210212 yield MigratedGroup (
211213 id_in_workspace = group .id ,
@@ -241,21 +243,19 @@ def generate_migrated_groups(self):
241243 for group in workspace_groups .values ():
242244 temporary_name = f"{ self .renamed_groups_prefix } { group .display_name } "
243245 account_group = account_groups_by_id .get (group .external_id )
244- if account_group :
245- yield MigratedGroup (
246- id_in_workspace = group .id ,
247- name_in_workspace = group .display_name ,
248- name_in_account = account_group .display_name ,
249- temporary_name = temporary_name ,
250- external_id = account_group .external_id ,
251- members = json .dumps ([gg .as_dict () for gg in group .members ]) if group .members else None ,
252- roles = json .dumps ([gg .as_dict () for gg in group .roles ]) if group .roles else None ,
253- entitlements = (
254- json .dumps ([gg .as_dict () for gg in group .entitlements ]) if group .entitlements else None
255- ),
256- )
257- else :
246+ if not account_group :
258247 logger .info (f"Couldn't find a matching account group for { group .display_name } group with external_id" )
248+ continue
249+ yield MigratedGroup (
250+ id_in_workspace = group .id ,
251+ name_in_workspace = group .display_name ,
252+ name_in_account = account_group .display_name ,
253+ temporary_name = temporary_name ,
254+ external_id = account_group .external_id ,
255+ members = json .dumps ([gg .as_dict () for gg in group .members ]) if group .members else None ,
256+ roles = json .dumps ([gg .as_dict () for gg in group .roles ]) if group .roles else None ,
257+ entitlements = (json .dumps ([gg .as_dict () for gg in group .entitlements ]) if group .entitlements else None ),
258+ )
259259
260260
261261class RegexSubStrategy (GroupMigrationStrategy ):
@@ -285,12 +285,18 @@ def generate_migrated_groups(self):
285285 name_in_account = self ._safe_sub (
286286 group .display_name , self .workspace_group_regex , self .workspace_group_replace
287287 )
288+ account_group = self .account_groups_in_account .get (name_in_account )
289+ if not account_group :
290+ logger .info (
291+ f"Couldn't find a matching account group for { group .display_name } group with regex substitution"
292+ )
293+ continue
288294 yield MigratedGroup (
289295 id_in_workspace = group .id ,
290296 name_in_workspace = group .display_name ,
291297 name_in_account = name_in_account ,
292298 temporary_name = temporary_name ,
293- external_id = self . account_groups_in_account [ name_in_account ] .external_id ,
299+ external_id = account_group .external_id ,
294300 members = json .dumps ([gg .as_dict () for gg in group .members ]) if group .members else None ,
295301 roles = json .dumps ([gg .as_dict () for gg in group .roles ]) if group .roles else None ,
296302 entitlements = json .dumps ([gg .as_dict () for gg in group .entitlements ]) if group .entitlements else None ,
@@ -329,21 +335,23 @@ def generate_migrated_groups(self):
329335 for group_match , ws_group in workspace_groups_by_match .items ():
330336 temporary_name = f"{ self .renamed_groups_prefix } { ws_group .display_name } "
331337 account_group = account_groups_by_match .get (group_match )
332- if account_group :
333- yield MigratedGroup (
334- id_in_workspace = ws_group .id ,
335- name_in_workspace = ws_group .display_name ,
336- name_in_account = account_group .display_name ,
337- temporary_name = temporary_name ,
338- external_id = account_group .external_id ,
339- members = json .dumps ([gg .as_dict () for gg in ws_group .members ]) if ws_group .members else None ,
340- roles = json .dumps ([gg .as_dict () for gg in ws_group .roles ]) if ws_group .roles else None ,
341- entitlements = (
342- json .dumps ([gg .as_dict () for gg in ws_group .entitlements ]) if ws_group .entitlements else None
343- ),
338+ if not account_group :
339+ logger .info (
340+ f"Couldn't find a matching account group for { ws_group .display_name } group with regex matching"
344341 )
345- else :
346- logger .info (f"Couldn't find a match for group { ws_group .display_name } " )
342+ continue
343+ yield MigratedGroup (
344+ id_in_workspace = ws_group .id ,
345+ name_in_workspace = ws_group .display_name ,
346+ name_in_account = account_group .display_name ,
347+ temporary_name = temporary_name ,
348+ external_id = account_group .external_id ,
349+ members = json .dumps ([gg .as_dict () for gg in ws_group .members ]) if ws_group .members else None ,
350+ roles = json .dumps ([gg .as_dict () for gg in ws_group .roles ]) if ws_group .roles else None ,
351+ entitlements = (
352+ json .dumps ([gg .as_dict () for gg in ws_group .entitlements ]) if ws_group .entitlements else None
353+ ),
354+ )
347355
348356
349357class GroupManager (CrawlerBase [MigratedGroup ]):
0 commit comments