You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2021/02/18 05:39:10 UTC

[GitHub] [servicecomb-service-center] DFSOrange opened a new pull request #862: unified account ut and fix account bugs.

DFSOrange opened a new pull request #862:
URL: https://github.com/apache/servicecomb-service-center/pull/862


   1. move account_test.go to datasource
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-service-center] tianxiaoliang commented on a change in pull request #862: unified account ut and fix account bugs.

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on a change in pull request #862:
URL: https://github.com/apache/servicecomb-service-center/pull/862#discussion_r578176819



##########
File path: datasource/mongo/account.go
##########
@@ -146,11 +148,12 @@ func (ds *DataSource) UpdateAccount(ctx context.Context, key string, account *rb
 			ColumnStatus:              account.Status,
 		},
 	}
-	result, err := client.GetMongoClient().Update(ctx, CollectionAccount, filter, update)
+	result, err := client.GetMongoClient().Update(ctx, CollectionAccount, filter, update, options.Update().SetUpsert(true))
 	if err != nil {
 		return err
 	}
-	if result.ModifiedCount == 0 {
+	//fmt.Println("")

Review comment:
       不要注释

##########
File path: datasource/mongo/util.go
##########
@@ -56,6 +56,10 @@ func BuildIndexDoc(keys ...string) mongo.IndexModel {
 	return index
 }
 
+func BuildPrefixFilter(key string) string {

Review comment:
       StartWith准确些,更好理解




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-service-center] tianxiaoliang commented on a change in pull request #862: unified account ut and fix account bugs

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on a change in pull request #862:
URL: https://github.com/apache/servicecomb-service-center/pull/862#discussion_r579605775



##########
File path: datasource/mongo/account.go
##########
@@ -131,26 +130,25 @@ func (ds *DataSource) DeleteAccount(ctx context.Context, key string) (bool, erro
 	return true, nil
 }
 
-func (ds *DataSource) UpdateAccount(ctx context.Context, key string, account *rbac.Account) error {
+func (ds *DataSource) UpdateAccount(ctx context.Context, name string, account *rbac.Account) error {
 	filter := bson.M{
-		ColumnAccountName: key,
+		ColumnAccountName: name,
 	}
 	update := bson.M{
 		"$set": bson.M{
 			ColumnID:                  account.ID,
-			ColumnAccountName:         account.Name,
 			ColumnPassword:            account.Password,
 			ColumnRoles:               account.Roles,
 			ColumnTokenExpirationTime: account.TokenExpirationTime,
 			ColumnCurrentPassword:     account.CurrentPassword,
 			ColumnStatus:              account.Status,
 		},
 	}
-	result, err := client.GetMongoClient().Update(ctx, CollectionAccount, filter, update)
+	res, err := client.GetMongoClient().Update(ctx, CollectionAccount, filter, update, options.Update().SetUpsert(true))

Review comment:
       Update().SetUpsert(true) 会导致自动新增吧?如果是的话就不合理了




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-service-center] DFSOrange commented on a change in pull request #862: unified account ut and fix account bugs

Posted by GitBox <gi...@apache.org>.
DFSOrange commented on a change in pull request #862:
URL: https://github.com/apache/servicecomb-service-center/pull/862#discussion_r579606668



##########
File path: datasource/mongo/account.go
##########
@@ -131,26 +130,25 @@ func (ds *DataSource) DeleteAccount(ctx context.Context, key string) (bool, erro
 	return true, nil
 }
 
-func (ds *DataSource) UpdateAccount(ctx context.Context, key string, account *rbac.Account) error {
+func (ds *DataSource) UpdateAccount(ctx context.Context, name string, account *rbac.Account) error {
 	filter := bson.M{
-		ColumnAccountName: key,
+		ColumnAccountName: name,
 	}
 	update := bson.M{
 		"$set": bson.M{
 			ColumnID:                  account.ID,
-			ColumnAccountName:         account.Name,
 			ColumnPassword:            account.Password,
 			ColumnRoles:               account.Roles,
 			ColumnTokenExpirationTime: account.TokenExpirationTime,
 			ColumnCurrentPassword:     account.CurrentPassword,
 			ColumnStatus:              account.Status,
 		},
 	}
-	result, err := client.GetMongoClient().Update(ctx, CollectionAccount, filter, update)
+	res, err := client.GetMongoClient().Update(ctx, CollectionAccount, filter, update, options.Update().SetUpsert(true))

Review comment:
       > Update().SetUpsert(true) 会导致自动新增吧?如果是的话就不合理了
   
   etcd的实现,put也会新增的.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-service-center] tianxiaoliang merged pull request #862: unified account ut and fix account bugs

Posted by GitBox <gi...@apache.org>.
tianxiaoliang merged pull request #862:
URL: https://github.com/apache/servicecomb-service-center/pull/862


   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-service-center] tianxiaoliang commented on a change in pull request #862: unified account ut and fix account bugs

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on a change in pull request #862:
URL: https://github.com/apache/servicecomb-service-center/pull/862#discussion_r579585583



##########
File path: datasource/account.go
##########
@@ -32,9 +32,9 @@ var (
 // AccountManager contains the RBAC CRUD
 type AccountManager interface {
 	CreateAccount(ctx context.Context, a *rbac.Account) error
-	AccountExist(ctx context.Context, key string) (bool, error)
-	GetAccount(ctx context.Context, key string) (*rbac.Account, error)
-	ListAccount(ctx context.Context, key string) ([]*rbac.Account, int64, error)
-	DeleteAccount(ctx context.Context, key string) (bool, error)
-	UpdateAccount(ctx context.Context, key string, account *rbac.Account) error
+	AccountExist(ctx context.Context, name string) (bool, error)
+	GetAccount(ctx context.Context, name string) (*rbac.Account, error)
+	ListAccount(ctx context.Context) ([]*rbac.Account, int64, error)
+	DeleteAccount(ctx context.Context, name string) (bool, error)

Review comment:
       delete里的name先改成slice,为了以后能够支持批量删除,现在不必实现




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-service-center] DFSOrange closed pull request #862: unified account ut and fix account bugs.

Posted by GitBox <gi...@apache.org>.
DFSOrange closed pull request #862:
URL: https://github.com/apache/servicecomb-service-center/pull/862


   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org