@@ -1489,7 +1489,7 @@ func (kc *Catalog) RestoreRBAC(ctx context.Context, tenant string, meta *milvusp
1489
1489
log .Ctx (ctx ).Warn ("failed to restore rbac, try to rollback" , zap .Error (err ))
1490
1490
// roll back role
1491
1491
for _ , role := range needRollbackRole {
1492
- err = kc .DropRole (ctx , tenant , role .Name )
1492
+ err = kc .DropRole (ctx , tenant , role .GetName () )
1493
1493
if err != nil {
1494
1494
log .Ctx (ctx ).Warn ("failed to rollback roles after restore failed" , zap .Error (err ))
1495
1495
}
@@ -1505,15 +1505,15 @@ func (kc *Catalog) RestoreRBAC(ctx context.Context, tenant string, meta *milvusp
1505
1505
1506
1506
for _ , user := range needRollbackUser {
1507
1507
// roll back user
1508
- err = kc .DropCredential (ctx , user .User )
1508
+ err = kc .DropCredential (ctx , user .GetUser () )
1509
1509
if err != nil {
1510
1510
log .Ctx (ctx ).Warn ("failed to rollback users after restore failed" , zap .Error (err ))
1511
1511
}
1512
1512
}
1513
1513
1514
1514
// roll back privilege group
1515
1515
for _ , group := range needRollbackPrivilegeGroups {
1516
- err = kc .DropPrivilegeGroup (ctx , group .GroupName )
1516
+ err = kc .DropPrivilegeGroup (ctx , group .GetGroupName () )
1517
1517
if err != nil {
1518
1518
log .Ctx (ctx ).Warn ("failed to rollback privilege groups after restore failed" , zap .Error (err ))
1519
1519
}
@@ -1527,7 +1527,7 @@ func (kc *Catalog) RestoreRBAC(ctx context.Context, tenant string, meta *milvusp
1527
1527
return err
1528
1528
}
1529
1529
existRoleMap := lo .SliceToMap (existRoles , func (entity * milvuspb.RoleResult ) (string , struct {}) { return entity .GetRole ().GetName (), struct {}{} })
1530
- for _ , role := range meta .Roles {
1530
+ for _ , role := range meta .GetRoles () {
1531
1531
if _ , ok := existRoleMap [role .GetName ()]; ok {
1532
1532
log .Ctx (ctx ).Warn ("failed to restore, role already exists" , zap .String ("role" , role .GetName ()))
1533
1533
err = errors .Newf ("role [%s] already exists" , role .GetName ())
@@ -1545,11 +1545,11 @@ func (kc *Catalog) RestoreRBAC(ctx context.Context, tenant string, meta *milvusp
1545
1545
if err != nil {
1546
1546
return err
1547
1547
}
1548
- existPrivGroupMap := lo .SliceToMap (existPrivGroups , func (entity * milvuspb.PrivilegeGroupInfo ) (string , struct {}) { return entity .GroupName , struct {}{} })
1549
- for _ , group := range meta .PrivilegeGroups {
1550
- if _ , ok := existPrivGroupMap [group .GroupName ]; ok {
1551
- log .Ctx (ctx ).Warn ("failed to restore, privilege group already exists" , zap .String ("group" , group .GroupName ))
1552
- err = errors .Newf ("privilege group [%s] already exists" , group .GroupName )
1548
+ existPrivGroupMap := lo .SliceToMap (existPrivGroups , func (entity * milvuspb.PrivilegeGroupInfo ) (string , struct {}) { return entity .GetGroupName () , struct {}{} })
1549
+ for _ , group := range meta .GetPrivilegeGroups () {
1550
+ if _ , ok := existPrivGroupMap [group .GetGroupName () ]; ok {
1551
+ log .Ctx (ctx ).Warn ("failed to restore, privilege group already exists" , zap .String ("group" , group .GetGroupName () ))
1552
+ err = errors .Newf ("privilege group [%s] already exists" , group .GetGroupName () )
1553
1553
return err
1554
1554
}
1555
1555
err = kc .SavePrivilegeGroup (ctx , group )
@@ -1564,9 +1564,9 @@ func (kc *Catalog) RestoreRBAC(ctx context.Context, tenant string, meta *milvusp
1564
1564
if err != nil {
1565
1565
return err
1566
1566
}
1567
- existPrivGroupMap = lo .SliceToMap (existPrivGroups , func (entity * milvuspb.PrivilegeGroupInfo ) (string , struct {}) { return entity .GroupName , struct {}{} })
1568
- for _ , grant := range meta .Grants {
1569
- privName := grant .Grantor . Privilege . Name
1567
+ existPrivGroupMap = lo .SliceToMap (existPrivGroups , func (entity * milvuspb.PrivilegeGroupInfo ) (string , struct {}) { return entity .GetGroupName () , struct {}{} })
1568
+ for _ , grant := range meta .GetGrants () {
1569
+ privName := grant .GetGrantor (). GetPrivilege (). GetName ()
1570
1570
if util .IsPrivilegeNameDefined (privName ) {
1571
1571
grant .Grantor .Privilege .Name = util .PrivilegeNameForMetastore (privName )
1572
1572
} else if _ , ok := existPrivGroupMap [privName ]; ok {
@@ -1589,16 +1589,16 @@ func (kc *Catalog) RestoreRBAC(ctx context.Context, tenant string, meta *milvusp
1589
1589
return err
1590
1590
}
1591
1591
existUserMap := lo .SliceToMap (existUser , func (entity * milvuspb.UserResult ) (string , struct {}) { return entity .GetUser ().GetName (), struct {}{} })
1592
- for _ , user := range meta .Users {
1592
+ for _ , user := range meta .GetUsers () {
1593
1593
if _ , ok := existUserMap [user .GetUser ()]; ok {
1594
1594
log .Ctx (ctx ).Info ("failed to restore, user already exists" , zap .String ("user" , user .GetUser ()))
1595
1595
err = errors .Newf ("user [%s] already exists" , user .GetUser ())
1596
1596
return err
1597
1597
}
1598
1598
// restore user
1599
1599
err = kc .CreateCredential (ctx , & model.Credential {
1600
- Username : user .User ,
1601
- EncryptedPassword : user .Password ,
1600
+ Username : user .GetUser () ,
1601
+ EncryptedPassword : user .GetPassword () ,
1602
1602
})
1603
1603
if err != nil {
1604
1604
return err
@@ -1607,9 +1607,9 @@ func (kc *Catalog) RestoreRBAC(ctx context.Context, tenant string, meta *milvusp
1607
1607
1608
1608
// restore user role mapping
1609
1609
entity := & milvuspb.UserEntity {
1610
- Name : user .User ,
1610
+ Name : user .GetUser () ,
1611
1611
}
1612
- for _ , role := range user .Roles {
1612
+ for _ , role := range user .GetRoles () {
1613
1613
err = kc .AlterUserRole (ctx , tenant , entity , role , milvuspb .OperateUserRoleType_AddUserToRole )
1614
1614
if err != nil {
1615
1615
return err
0 commit comments