Skip to content

Commit

Permalink
Fixing external authed users migration (#11)
Browse files Browse the repository at this point in the history
Signed-off-by: galal-hussein <hussein.galal.ahmed.11@gmail.com>
  • Loading branch information
galal-hussein authored Dec 23, 2024
1 parent e107c5e commit 424ca22
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pkg/cluster/projectroletemplatebinding.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,20 @@ func (p *ProjectRoleTemplateBinding) Mutate(clusterName, projectName string) {
}

func (p *ProjectRoleTemplateBinding) SetDescription(ctx context.Context, client *client.Clients) error {
if p.Obj.UserName == "" && p.Obj.UserPrincipalName == "" {
groupName := p.Obj.GroupName
if groupName == "" {
// handling external auth providers
groupName = p.Obj.GroupPrincipalName
}
p.Description = fmt.Sprintf("%s permission for group %s", p.Obj.RoleTemplateName, groupName)
return nil
}
// setting description for external users
if p.Obj.UserPrincipalName != "" {
p.Description = fmt.Sprintf("%s permission for user %s", p.Obj.RoleTemplateName, p.Obj.UserPrincipalName)
return nil
}
var user v3.User
userID := p.Obj.UserName
if err := client.Users.Get(ctx, "", userID, &user, v1.GetOptions{}); err != nil {
Expand Down

0 comments on commit 424ca22

Please sign in to comment.