Change deleteRole to deleteRoleKeys
[ZITADOPER-1]
This commit is contained in:
@@ -186,7 +186,7 @@ func (wr *wrappedProjectReconciler) reconcileRoles(ctx context.Context, ztdClien
|
||||
return fmt.Errorf("Could not list project roles: %v", err)
|
||||
}
|
||||
roles := map[string]*pb.BulkAddProjectRolesRequest_Role{}
|
||||
deleteRoles := []*pb.BulkAddProjectRolesRequest_Role{}
|
||||
deleteRolesKeys := []string{}
|
||||
for _, role := range wr.project.Spec.Roles {
|
||||
roles[role.Key] = &pb.BulkAddProjectRolesRequest_Role{
|
||||
Key: role.Key,
|
||||
@@ -198,20 +198,20 @@ func (wr *wrappedProjectReconciler) reconcileRoles(ctx context.Context, ztdClien
|
||||
for _, role := range resp.Result {
|
||||
if r, ok := roles[role.Key]; ok {
|
||||
if r.DisplayName != role.DisplayName || r.Group != role.Group {
|
||||
deleteRoles = append(deleteRoles, r)
|
||||
deleteRolesKeys = append(deleteRolesKeys, role.Key)
|
||||
} else {
|
||||
delete(roles, role.Key)
|
||||
}
|
||||
} else {
|
||||
deleteRoles = append(deleteRoles, r)
|
||||
deleteRolesKeys = append(deleteRolesKeys, role.Key)
|
||||
}
|
||||
}
|
||||
|
||||
if len(deleteRoles) > 0 {
|
||||
for _, dRole := range deleteRoles {
|
||||
if len(deleteRolesKeys) > 0 {
|
||||
for _, key := range deleteRolesKeys {
|
||||
if _, err = ztdClient.RemoveProjectRole(middleware.SetOrgID(ctx, org.Status.OrgId), &pb.RemoveProjectRoleRequest{
|
||||
ProjectId: wr.project.Status.ProjectId,
|
||||
RoleKey: dRole.Key,
|
||||
RoleKey: key,
|
||||
}); err != nil {
|
||||
return fmt.Errorf("Error removing project role: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user