You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by ti...@apache.org on 2021/03/27 06:28:33 UTC
[servicecomb-service-center] branch master updated: [SCB-2176]
Fix:remove all instance properties and service properties & schemas (#921)
This is an automated email from the ASF dual-hosted git repository.
tianxiaoliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git
The following commit(s) were added to refs/heads/master by this push:
new 6f1e2b2 [SCB-2176] Fix:remove all instance properties and service properties & schemas (#921)
6f1e2b2 is described below
commit 6f1e2b29a427ed84b6b930a16f1b981c1125a1df
Author: robotLJW <79...@qq.com>
AuthorDate: Sat Mar 27 14:28:24 2021 +0800
[SCB-2176] Fix:remove all instance properties and service properties & schemas (#921)
---
datasource/etcd/ms.go | 16 +++++++++++++++-
datasource/mongo/ms.go | 16 +++++++++++++++-
go.mod | 1 +
3 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/datasource/etcd/ms.go b/datasource/etcd/ms.go
index f9e3902..57af234 100644
--- a/datasource/etcd/ms.go
+++ b/datasource/etcd/ms.go
@@ -26,6 +26,7 @@ import (
"time"
pb "github.com/go-chassis/cari/discovery"
+ "github.com/jinzhu/copier"
"github.com/apache/servicecomb-service-center/datasource"
"github.com/apache/servicecomb-service-center/datasource/etcd/cache"
@@ -321,7 +322,20 @@ func (ds *DataSource) GetServicesInfo(ctx context.Context, request *pb.GetServic
}, err
}
serviceDetail.MicroService = service
- allServiceDetails = append(allServiceDetails, serviceDetail)
+ tmpServiceDetail := &pb.ServiceDetail{}
+ err = copier.CopyWithOption(tmpServiceDetail, serviceDetail, copier.Option{DeepCopy: true})
+ if err != nil {
+ return &pb.GetServicesInfoResponse{
+ Response: pb.CreateResponse(pb.ErrInternal, err.Error()),
+ }, err
+ }
+ tmpServiceDetail.MicroService.Properties = nil
+ tmpServiceDetail.MicroService.Schemas = nil
+ instances := tmpServiceDetail.Instances
+ for _, instance := range instances {
+ instance.Properties = nil
+ }
+ allServiceDetails = append(allServiceDetails, tmpServiceDetail)
}
return &pb.GetServicesInfoResponse{
diff --git a/datasource/mongo/ms.go b/datasource/mongo/ms.go
index 9850f4f..185f14c 100644
--- a/datasource/mongo/ms.go
+++ b/datasource/mongo/ms.go
@@ -31,6 +31,7 @@ import (
"time"
"github.com/go-chassis/cari/discovery"
+ "github.com/jinzhu/copier"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
@@ -506,7 +507,20 @@ func (ds *DataSource) GetServicesInfo(ctx context.Context, request *discovery.Ge
}, err
}
serviceDetail.MicroService = mgSvc.Service
- allServiceDetails = append(allServiceDetails, serviceDetail)
+ tmpServiceDetail := &discovery.ServiceDetail{}
+ err = copier.CopyWithOption(tmpServiceDetail, serviceDetail, copier.Option{DeepCopy: true})
+ if err != nil {
+ return &discovery.GetServicesInfoResponse{
+ Response: discovery.CreateResponse(discovery.ErrInternal, err.Error()),
+ }, err
+ }
+ tmpServiceDetail.MicroService.Properties = nil
+ tmpServiceDetail.MicroService.Schemas = nil
+ instances := tmpServiceDetail.Instances
+ for _, instance := range instances {
+ instance.Properties = nil
+ }
+ allServiceDetails = append(allServiceDetails, tmpServiceDetail)
}
return &discovery.GetServicesInfoResponse{
diff --git a/go.mod b/go.mod
index 04bb139..cd8f53b 100644
--- a/go.mod
+++ b/go.mod
@@ -4,6 +4,7 @@ replace google.golang.org/grpc => google.golang.org/grpc v1.19.0
require (
bou.ke/monkey v1.0.2
+ github.com/jinzhu/copier v0.2.9-0.20210317033127-fc3adf52acab
github.com/NYTimes/gziphandler v1.0.2-0.20180820182813-253f1acb9d9f
github.com/Shopify/sarama v1.27.2 // indirect
github.com/apache/thrift v0.0.0-20180125231006-3d556248a8b9 // indirect