-
Notifications
You must be signed in to change notification settings - Fork 469
/
RbacRoleService.go
47 lines (43 loc) · 1.49 KB
/
RbacRoleService.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package user
import (
"github.com/devtron-labs/devtron/pkg/user/bean"
"github.com/devtron-labs/devtron/pkg/user/repository"
"go.uber.org/zap"
)
type RbacRoleService interface {
GetAllDefaultRoles() ([]*bean.RbacRoleDto, error)
}
type RbacRoleServiceImpl struct {
logger *zap.SugaredLogger
rbacRoleDataRepository repository.RbacRoleDataRepository
}
func NewRbacRoleServiceImpl(logger *zap.SugaredLogger,
rbacRoleDataRepository repository.RbacRoleDataRepository) *RbacRoleServiceImpl {
return &RbacRoleServiceImpl{
logger: logger,
rbacRoleDataRepository: rbacRoleDataRepository,
}
}
func (impl *RbacRoleServiceImpl) GetAllDefaultRoles() ([]*bean.RbacRoleDto, error) {
//getting all roles from default data repository
defaultRoles, err := impl.rbacRoleDataRepository.GetRoleDataForAllRoles()
if err != nil {
impl.logger.Errorw("error in getting all default roles data", "err", err)
return nil, err
}
defaultRolesResp := make([]*bean.RbacRoleDto, 0, len(defaultRoles))
for _, defaultRole := range defaultRoles {
defaultRoleResp := &bean.RbacRoleDto{
Id: defaultRole.Id,
RoleName: defaultRole.Role,
RoleDisplayName: defaultRole.RoleDisplayName,
RoleDescription: defaultRole.RoleDescription,
RbacPolicyEntityGroupDto: &bean.RbacPolicyEntityGroupDto{
Entity: defaultRole.Entity,
AccessType: defaultRole.AccessType,
},
}
defaultRolesResp = append(defaultRolesResp, defaultRoleResp)
}
return defaultRolesResp, nil
}