Skip to content

Commit

Permalink
Fix to provision/deprovision to repos
Browse files Browse the repository at this point in the history
  • Loading branch information
harikac1 committed Jan 13, 2025
1 parent 1ce0511 commit 140ddde
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/connector/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func (r *repoBuilder) Grant(ctx context.Context, principal *v2.Resource, entitle

switch principal.Id.ResourceType {
case resourceTypeUser.Id:
userName := principal.DisplayName
userName := principal.Id.Resource

userRepositoryPermissions, err := listUserRepositoryPermissions(ctx, r.client, projectKey, repoSlug)
if err != nil {
Expand Down Expand Up @@ -239,7 +239,7 @@ func (r *repoBuilder) Grant(ctx context.Context, principal *v2.Resource, entitle
zap.String("RepositorySlug", repoSlug),
)
case resourceTypeGroup.Id:
groupName := principal.DisplayName
groupName := principal.Id.Resource
groupRepositoryPermissions, err := listGroupRepositoryPermissions(ctx, r.client, projectKey, repoSlug)
if err != nil {
return nil, err
Expand Down Expand Up @@ -324,7 +324,7 @@ func (r *repoBuilder) Revoke(ctx context.Context, grant *v2.Grant) (annotations.
return annotations.New(&v2.GrantAlreadyRevoked{}), nil
}

err = r.client.RevokeUserRepositoryPermission(ctx, projectKey, repoSlug, principal.DisplayName)
err = r.client.RevokeUserRepositoryPermission(ctx, projectKey, repoSlug, principal.Id.Resource)
if err != nil {
return nil, fmt.Errorf("bitbucket(dc)-connector: failed to remove repository user permission: %w", err)
}
Expand All @@ -341,7 +341,7 @@ func (r *repoBuilder) Revoke(ctx context.Context, grant *v2.Grant) (annotations.
}

index := slices.IndexFunc(listGroups, func(c client.GroupsPermissions) bool {
return c.Group.Name == principal.DisplayName
return c.Group.Name == principal.Id.Resource
})
if index < 0 {
l.Info(
Expand All @@ -352,7 +352,7 @@ func (r *repoBuilder) Revoke(ctx context.Context, grant *v2.Grant) (annotations.
return annotations.New(&v2.GrantAlreadyRevoked{}), nil
}

err = r.client.RevokeGroupRepositoryPermission(ctx, projectKey, repoSlug, principal.DisplayName)
err = r.client.RevokeGroupRepositoryPermission(ctx, projectKey, repoSlug, principal.Id.Resource)
if err != nil {
return nil, fmt.Errorf("bitbucket(dc)-connector: failed to remove repository group permission: %w", err)
}
Expand Down

0 comments on commit 140ddde

Please sign in to comment.