zqfang666 commented on code in PR #1355:
URL:
https://github.com/apache/servicecomb-service-center/pull/1355#discussion_r1017556014
##########
datasource/etcd/role.go:
##########
@@ -156,3 +156,27 @@ func (rm *RbacDAO) UpdateRole(ctx context.Context, name
string, role *crbac.Role
opts = append(opts, syncOpts...)
return etcdadpt.Txn(ctx, opts)
}
+func (rm *RbacDAO) IsMigrated(ctx context.Context) (bool, error) {
+ exist, err := etcdadpt.Exist(ctx, datasource.IsMigrated)
+ if err != nil {
+ return false, err
+ }
+ if !exist {
+ opts := []etcdadpt.OpOptions{
+
etcdadpt.OpPut(etcdadpt.WithStrKey(datasource.IsMigrated),
etcdadpt.WithValue([]byte("true"))),
+ }
+ syncOpts, err := esync.GenCreateOpts(ctx,
datasource.ResourceRole, datasource.IsMigrated)
+ if err != nil {
+ log.Error("fail to create sync opts", err)
+ return false, err
+ }
+ opts = append(opts, syncOpts...)
+ err = etcdadpt.Txn(ctx, opts)
Review Comment:
done
##########
server/service/rbac/init.go:
##########
@@ -81,3 +81,12 @@ func createBuildInRole(r *rbac.Role) {
}
log.Fatal(fmt.Sprintf("create role [%s] failed", r.Name), err)
}
+
+func migrateOldRole() {
+ _, err := MigrateRole(context.Background())
Review Comment:
done
##########
server/service/rbac/permission.go:
##########
@@ -59,3 +59,12 @@ func DevPerms() []*rbac.Permission {
}
return perm
}
+
+// ConfigPerms allocate all config resource
+func ConfigPerms() *rbac.Permission {
Review Comment:
done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]