Skip to content

Commit

Permalink
We need to create user before adding
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasBergmeier6176 committed Jun 22, 2023
1 parent 36b21a2 commit daa50c9
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions internal/controller/organization_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,29 @@ func (r *OrganizationReconciler) addMissingUsers(ctx context.Context, client *ga
for i, uc := range users {
go func(i int, uc *missingUserConfig) {
defer wg.Done()
err := client.AddOrgUser(uc.OrgID, string(uc.email), uc.role)
if err == nil {

_, err := client.CreateUser(gapi.User{
Email: string(uc.email),
Name: string(uc.email),
Login: string(uc.email),
})
if err != nil {
errs[i] = &orgUserAddError{
error: err,
Email: uc.email,
OrgID: uc.OrgID,
}
return
}
errs[i] = &orgUserAddError{
error: err,
Email: uc.email,
OrgID: uc.OrgID,

err = client.AddOrgUser(uc.OrgID, string(uc.email), uc.role)
if err != nil {
errs[i] = &orgUserAddError{
error: err,
Email: uc.email,
OrgID: uc.OrgID,
}
return
}
}(i, &uc)
}
Expand Down

0 comments on commit daa50c9

Please sign in to comment.