Skip to content

Commit

Permalink
return role provision in add role
Browse files Browse the repository at this point in the history
Signed-off-by: Arvindh <[email protected]>
  • Loading branch information
arvindh123 committed Dec 26, 2024
1 parent c32d406 commit 1fe7708
Show file tree
Hide file tree
Showing 21 changed files with 96 additions and 97 deletions.
10 changes: 5 additions & 5 deletions channels/mocks/repository.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions channels/mocks/service.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions clients/mocks/repository.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions clients/mocks/service.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions domains/mocks/repository.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions domains/mocks/service.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions groups/mocks/repository.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions groups/mocks/service.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions pkg/roles/mocks/rolemanager.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions pkg/roles/mocks/rolesRepo.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 12 additions & 11 deletions pkg/roles/provisionmanage.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,23 +210,24 @@ func (r ProvisionManageService) AddNewEntitiesRoles(ctx context.Context, domainI
}()
}

if _, err := r.repo.AddRoles(ctx, newRolesProvision); err != nil {
nprs, err := r.repo.AddRoles(ctx, newRolesProvision)
if err != nil {
return []RoleProvision{}, errors.Wrap(svcerr.ErrCreateEntity, err)
}

return newRolesProvision, nil
return nprs, nil
}

func (r ProvisionManageService) AddRole(ctx context.Context, session authn.Session, entityID string, roleName string, optionalActions []string, optionalMembers []string) (retRole Role, retErr error) {
func (r ProvisionManageService) AddRole(ctx context.Context, session authn.Session, entityID string, roleName string, optionalActions []string, optionalMembers []string) (retRoleProvision RoleProvision, retErr error) {
sid, err := r.sidProvider.ID()
if err != nil {
return Role{}, errors.Wrap(svcerr.ErrCreateEntity, err)
return RoleProvision{}, errors.Wrap(svcerr.ErrCreateEntity, err)
}

id := r.entityType + "_" + sid

if err := r.validateActions(toRolesActions(optionalActions)); err != nil {
return Role{}, errors.Wrap(svcerr.ErrMalformedEntity, err)
return RoleProvision{}, errors.Wrap(svcerr.ErrMalformedEntity, err)
}

newRoleProvisions := []RoleProvision{
Expand Down Expand Up @@ -267,7 +268,7 @@ func (r ProvisionManageService) AddRole(ctx context.Context, session authn.Sessi

if len(prs) > 0 {
if err := r.policy.AddPolicies(ctx, prs); err != nil {
return Role{}, errors.Wrap(svcerr.ErrCreateEntity, err)
return RoleProvision{}, errors.Wrap(svcerr.ErrCreateEntity, err)
}

defer func() {
Expand All @@ -279,16 +280,16 @@ func (r ProvisionManageService) AddRole(ctx context.Context, session authn.Sessi
}()
}

newRoles, err := r.repo.AddRoles(ctx, newRoleProvisions)
nrps, err := r.repo.AddRoles(ctx, newRoleProvisions)
if err != nil {
return Role{}, errors.Wrap(svcerr.ErrCreateEntity, err)
return RoleProvision{}, errors.Wrap(svcerr.ErrCreateEntity, err)
}

if len(newRoles) == 0 {
return Role{}, svcerr.ErrCreateEntity
if len(nrps) == 0 {
return RoleProvision{}, svcerr.ErrCreateEntity
}

return newRoles[0], nil
return nrps[0], nil
}

func (r ProvisionManageService) RemoveRole(ctx context.Context, session authn.Session, entityID, roleID string) error {
Expand Down
Loading

0 comments on commit 1fe7708

Please sign in to comment.