Skip to content

Commit

Permalink
fix compile
Browse files Browse the repository at this point in the history
Signed-off-by: shaoting-huang <[email protected]>
  • Loading branch information
shaoting-huang committed Nov 13, 2024
1 parent 696bc2e commit 31cd8df
Showing 1 changed file with 26 additions and 19 deletions.
45 changes: 26 additions & 19 deletions client/rbac.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"github.com/milvus-io/milvus-proto/go-api/v2/commonpb"
"github.com/milvus-io/milvus-proto/go-api/v2/milvuspb"
"github.com/milvus-io/milvus-sdk-go/v2/entity"
"github.com/samber/lo"
)

// CreateRole creates a role entity in Milvus.
Expand Down Expand Up @@ -581,11 +580,13 @@ func (c *GrpcClient) ListPrivilegeGroups(ctx context.Context) ([]*entity.Privile
}

for _, pg := range results {
privs := make([]string, 0, len(pg.Privileges))
for _, p := range pg.Privileges {
privs = append(privs, p.GetName())
}
PrivilegeGroup := &entity.PrivilegeGroup{
GroupName: pg.GroupName,
Privileges: lo.Map(pg.Privileges, func(p *milvuspb.PrivilegeEntity, _ int) string {
return p.Name
}),
GroupName: pg.GroupName,
Privileges: privs,
}
PrivilegeGroupList = append(PrivilegeGroupList, PrivilegeGroup)
}
Expand All @@ -598,14 +599,17 @@ func (c *GrpcClient) AddPrivilegesToGroup(ctx context.Context, groupName string,
return ErrClientNotReady
}

privs := make([]*milvuspb.PrivilegeEntity, 0, len(privileges))
for _, p := range privileges {
privs = append(privs, &milvuspb.PrivilegeEntity{
Name: p,
})
}

req := &milvuspb.OperatePrivilegeGroupRequest{
GroupName: groupName,
Privileges: lo.Map(privileges, func(p string, _ int) *milvuspb.PrivilegeEntity {
return &milvuspb.PrivilegeEntity{
Name: p,
}
}),
Type: milvuspb.OperatePrivilegeGroupType_AddPrivilegesToGroup,
GroupName: groupName,
Privileges: privs,
Type: milvuspb.OperatePrivilegeGroupType_AddPrivilegesToGroup,
}

resp, err := c.Service.OperatePrivilegeGroup(ctx, req)
Expand All @@ -621,14 +625,17 @@ func (c *GrpcClient) RemovePrivilegesFromGroup(ctx context.Context, groupName st
return ErrClientNotReady
}

privs := make([]*milvuspb.PrivilegeEntity, 0, len(privileges))
for _, p := range privileges {
privs = append(privs, &milvuspb.PrivilegeEntity{
Name: p,
})
}

req := &milvuspb.OperatePrivilegeGroupRequest{
GroupName: groupName,
Privileges: lo.Map(privileges, func(p string, _ int) *milvuspb.PrivilegeEntity {
return &milvuspb.PrivilegeEntity{
Name: p,
}
}),
Type: milvuspb.OperatePrivilegeGroupType_RemovePrivilegesFromGroup,
GroupName: groupName,
Privileges: privs,
Type: milvuspb.OperatePrivilegeGroupType_RemovePrivilegesFromGroup,
}

resp, err := c.Service.OperatePrivilegeGroup(ctx, req)
Expand Down

0 comments on commit 31cd8df

Please sign in to comment.