AngLi2 commented on a change in pull request #766:
URL: 
https://github.com/apache/servicecomb-service-center/pull/766#discussion_r532323519



##########
File path: server/service/gov/mock/mock.go
##########
@@ -31,32 +31,36 @@ type Distributor struct {
        name       string
 }
 
-func (d *Distributor) Create(kind string, spec []byte) error {
+func (d *Distributor) Create(kind, project string, spec []byte) error {
        p := &gov.LoadBalancer{}
        err := json.Unmarshal(spec, p)
        log.Println(fmt.Sprintf("create %v", &p))
        d.lbPolicies[p.GovernancePolicy.Name] = p
        return err
 }
-func (d *Distributor) Update(kind string, spec []byte) error {
+func (d *Distributor) Update(id, kind, project string, spec []byte) error {
        p := &gov.LoadBalancer{}
        err := json.Unmarshal(spec, p)
        log.Println("update ", p)
        d.lbPolicies[p.GovernancePolicy.Name] = p
        return err
 }
-func (d *Distributor) Delete(name, kind string) error {
-       delete(d.lbPolicies, name)
+func (d *Distributor) Delete(id, project string) error {
+       delete(d.lbPolicies, id)
        return nil
 }
-func (d *Distributor) List(kind string) ([]byte, error) {
+func (d *Distributor) List(kind, project, app, env string) ([]byte, error) {
        r := make([]*gov.LoadBalancer, len(d.lbPolicies))

Review comment:
       这里有个bug,会导致 r 的前 len(d.lbPolicies) 数据为 nil
   如果使用 make([]*gov.LoadBalancer, len(d.lbPolicies)),使用 r[i] = g
   如果使用 make([]*gov.LoadBalancer, 0, len(d.lbPolicies)), 使用 append




----------------------------------------------------------------
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:
[email protected]


Reply via email to