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/05/28 01:37:02 UTC

[GitHub] [servicecomb-service-center] ryaninvoker opened a new pull request #1016: 添加创建业务场景未对alias字段校验,将对methods校验修改为method

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


   Follow this checklist to help us incorporate your contribution quickly and easily:
   
    - [ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/SCB) filed for the change (usually before you start working on it).  Trivial changes like typos do not require a JIRA issue.  Your pull request should address just this issue, without pulling in other changes.
    - [ ] Each commit in the pull request should have a meaningful subject line and body.
    - [ ] Format the pull request title like `[SCB-XXX] Fixes bug in ApproximateQuantiles`, where you replace `SCB-XXX` with the appropriate JIRA issue.
    - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
    - [ ] Run `go build` `go test` `go fmt` `go vet` to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.
    - [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
    - [ ] Never comment source code, delete it.
    - [ ] UT should has "context, subject, expected result" result as test case name, when you call t.Run().
   ---
   


-- 
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] little-cui commented on a change in pull request #1016: 添加创建业务场景未对alias字段校验,将对methods校验修改为method

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



##########
File path: server/service/gov/kie/kie_distributor.go
##########
@@ -104,6 +105,7 @@ func (d *Distributor) Update(kind, id, project string, spec []byte) error {
 	if err != nil {
 		return err
 	}
+	setAlias(p.Spec, p.Name)

Review comment:
       逻辑有误,104行先validate通过才会走到此行,但在此场景validate已经失败




-- 
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] little-cui commented on a change in pull request #1016: 添加创建业务场景未对alias字段校验,将对methods校验修改为method

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



##########
File path: server/service/gov/kie/validate.go
##########
@@ -65,6 +65,9 @@ func matchValidate(val interface{}) error {
 	if spec["matches"] == nil {
 		return nil
 	}
+	if spec["alias"] == nil || spec["alias"] == "" {

Review comment:
       这个字段不建议必填,如果必须建议强类型校验:
   ```go
   if alias, ok := spec["alias"].(string); !ok || alias == "" {
       // err
   }
   ```




-- 
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 #1016: 添加创建业务场景未对alias字段校验,将对methods校验修改为method

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


   


-- 
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] little-cui commented on a change in pull request #1016: 添加创建业务场景未对alias字段校验,将对methods校验修改为method

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



##########
File path: server/service/gov/kie/kie_distributor.go
##########
@@ -104,6 +105,7 @@ func (d *Distributor) Update(kind, id, project string, spec []byte) error {
 	if err != nil {
 		return err
 	}
+	setAlias(p.Spec, p.Name)

Review comment:
       逻辑有误,104行先validate通过才会走到此行,但在此场景validate已经失败




-- 
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] little-cui commented on a change in pull request #1016: 添加创建业务场景未对alias字段校验,将对methods校验修改为method

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



##########
File path: server/service/gov/kie/validate.go
##########
@@ -81,8 +84,8 @@ func matchValidate(val interface{}) error {
 			return &ErrIllegalItem{"match must have a match item [apiPath/headers/methods]", match}

Review comment:
       漏改了一处




-- 
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 #1016: 添加创建业务场景未对alias字段校验,将对methods校验修改为method

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



##########
File path: server/service/gov/kie/kie_distributor.go
##########
@@ -209,6 +211,14 @@ func (d *Distributor) Display(project, app, env string) ([]byte, error) {
 	return b, nil
 }
 
+func setAlias(val interface{}, name string) {

Review comment:
       setAliasIfEmpty




-- 
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 #1016: 添加创建业务场景未对alias字段校验,将对methods校验修改为method

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



##########
File path: server/service/gov/kie/validate.go
##########
@@ -65,6 +65,9 @@ func matchValidate(val interface{}) error {
 	if spec["matches"] == nil {
 		return nil
 	}
+	if spec["alias"] == nil || spec["alias"] == "" {

Review comment:
       alias并非是强制选项,该变更不可合入




-- 
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 #1016: 添加创建业务场景未对alias字段校验,将对methods校验修改为method

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



##########
File path: server/service/gov/kie/kie_distributor.go
##########
@@ -209,6 +211,14 @@ func (d *Distributor) Display(project, app, env string) ([]byte, error) {
 	return b, nil
 }
 
+func setAlias(val interface{}, name string) {

Review comment:
       setAliasIfEmpty 直觉上set是一定会发生的,所以clean code倡导方法名也得易懂,没歧义




-- 
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] little-cui commented on a change in pull request #1016: 添加创建业务场景未对alias字段校验,将对methods校验修改为method

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



##########
File path: server/service/gov/kie/validate.go
##########
@@ -65,6 +65,9 @@ func matchValidate(val interface{}) error {
 	if spec["matches"] == nil {
 		return nil
 	}
+	if spec["alias"] == nil || spec["alias"] == "" {

Review comment:
       建议强类型校验:
   ```go
   if alias, ok := spec["alias"].(string); !ok || alias == "" {
       // err
   }
   ```




-- 
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 pull request #1016: 添加创建业务场景未对alias字段校验,将对methods校验修改为method

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on pull request #1016:
URL: https://github.com/apache/servicecomb-service-center/pull/1016#issuecomment-851212181


   感谢贡献


-- 
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 #1016: 添加创建业务场景未对alias字段校验,将对methods校验修改为method

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



##########
File path: server/service/gov/kie/validate.go
##########
@@ -77,12 +81,12 @@ func matchValidate(val interface{}) error {
 		if match["name"] == nil {
 			return &ErrIllegalItem{"match's name can not be null", match}
 		}
-		if match["apiPath"] == nil && match["headers"] == nil && match["methods"] == nil {
+		if match["apiPath"] == nil && match["headers"] == nil && match["method"] == nil {

Review comment:
       alias和method抽取常量吧,这么搞以后不好维护




-- 
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 #1016: 添加创建业务场景未对alias字段校验,将对methods校验修改为method

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



##########
File path: server/service/gov/kie/validate.go
##########
@@ -65,6 +65,9 @@ func matchValidate(val interface{}) error {
 	if spec["matches"] == nil {
 		return nil
 	}
+	if spec["alias"] == nil || spec["alias"] == "" {

Review comment:
       如果alias为空可以把name存进去




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