Skip to content

Commit ae0e77f

Browse files
committed
fix role Grant()
contains duplicate roles for env
1 parent 3f236d0 commit ae0e77f

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

pkg/connector/role.go

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -211,15 +211,6 @@ func (o *roleBuilder) Grant(ctx context.Context, principal *v2.Resource, entitle
211211
return nil, nil, err
212212
}
213213

214-
grants := make([]*v2.Grant, 0)
215-
216-
collaborator, err := o.client.GetCollaboratorPrivileges(ctx, userID)
217-
if err != nil {
218-
return nil, nil, err
219-
}
220-
221-
roles := toSimpleRole(collaborator)
222-
223214
roleTrait, err := rs.GetRoleTrait(entitlement.Resource)
224215
if err != nil {
225216
return nil, nil, err
@@ -237,10 +228,12 @@ func (o *roleBuilder) Grant(ctx context.Context, principal *v2.Resource, entitle
237228
return nil, nil, fmt.Errorf("environment value is missing or invalid")
238229
}
239230

240-
roles = append(roles, client.SimpleRole{
241-
RoleName: roleName,
242-
EnvironmentType: environmentType,
243-
})
231+
roles := []client.SimpleRole{
232+
{
233+
RoleName: roleName,
234+
EnvironmentType: environmentType,
235+
},
236+
}
244237

245238
l := ctxzap.Extract(ctx)
246239
rolesJSON, err := json.Marshal(roles)
@@ -262,9 +255,7 @@ func (o *roleBuilder) Grant(ctx context.Context, principal *v2.Resource, entitle
262255
}),
263256
)
264257

265-
grants = append(grants, newGrant)
266-
267-
return grants, nil, nil
258+
return []*v2.Grant{newGrant}, nil, nil
268259
}
269260

270261
func (o *roleBuilder) Revoke(_ context.Context, grant *v2.Grant) (annotations.Annotations, error) {

0 commit comments

Comments
 (0)