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/01/11 12:19:48 UTC

[GitHub] [servicecomb-service-center] GuoYL123 commented on a change in pull request #826: [SCD-2133] add scene id / add custome err

GuoYL123 commented on a change in pull request #826:
URL: https://github.com/apache/servicecomb-service-center/pull/826#discussion_r555008222



##########
File path: server/service/gov/mock/mock.go
##########
@@ -98,14 +98,18 @@ func (d *Distributor) Display(project, app, env string) ([]byte, error) {
 func (d *Distributor) List(kind, project, app, env string) ([]byte, error) {
 	r := make([]*gov.Policy, 0, len(d.lbPolicies))
 	for _, g := range d.lbPolicies {
-		if g.Kind == kind && g.Selector.App == app && g.Selector.Environment == env {
+		if check(g, kind, app, env) {
 			r = append(r, g)
 		}
 	}
 	b, _ := json.MarshalIndent(r, "", "  ")
 	return b, nil
 }
 
+func check(g *gov.Policy, kind, app, env string) bool {

Review comment:
       done

##########
File path: server/service/gov/kie/kie_distributor.go
##########
@@ -42,8 +45,13 @@ func (d *Distributor) Create(kind, project string, spec []byte) ([]byte, error)
 	if err != nil {
 		return nil, err
 	}
+	if kind == MatchGroup {
+		err = d.generateID(project, p)
+	}
+	if err != nil {

Review comment:
       done

##########
File path: server/service/gov/kie/kie_distributor.go
##########
@@ -241,6 +249,70 @@ func (d *Distributor) listDataByKind(kind, project, app, env string) (*kie.KVRes
 	return d.client.List(context.TODO(), ops...)
 }
 
+func (d *Distributor) generateID(project string, p *gov.Policy) error {
+	if p.Name != "" {
+		return nil
+	}
+	list, _, err := d.listDataByKind(MatchGroup, project, p.Selector.App, p.Selector.Environment)
+	if err != nil {
+		return err
+	}
+	alias, err := getAlias(p)
+	if err != nil {
+		return err
+	}
+	var id string
+	for {
+		var repeat bool
+		id = getID()
+		for _, datum := range list.Data {
+			itemP, err := d.transform(datum, MatchGroup)
+			if err != nil {
+				return err
+			}
+			temp, err := getAlias(itemP)

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.

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