Skip to content

Commit

Permalink
Handle no longer exist user in lightdash_space (#156)
Browse files Browse the repository at this point in the history
Signed-off-by: Yu Ishikawa <[email protected]>
  • Loading branch information
yu-iskw authored Jul 23, 2024
1 parent 656ada0 commit eab3196
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions internal/provider/resource_lightdash_space.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,15 @@ func (r *spaceResource) Update(ctx context.Context, req resource.UpdateRequest,
// NOTE: Manually added users will be removed
organizationMembersService := services.NewOrganizationMembersService(r.client)
for _, existingAccess := range space.SpaceAccess {
// Skip if the user no longer exists in the organization
_, err := organizationMembersService.GetOrganizationMemberByUserUuid(existingAccess.UserUUID)
if err != nil {
resp.Diagnostics.AddWarning(
"User no longer exists in the organization",
fmt.Sprintf("User %s no longer exists in the organization. Skipping revoking access to the space.", existingAccess.UserUUID),
)
continue
}
// Check if the user is an organization admin
// It is not possible to revoke space access from organization admins
isOrganizationAdmin, err := organizationMembersService.IsOrganizationAdmin(existingAccess.UserUUID)
Expand Down

0 comments on commit eab3196

Please sign in to comment.