You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2018/06/25 07:56:37 UTC
[incubator-servicecomb-service-center] branch master updated:
SCB-694 Add 'PLATFORM' register type (#378)
This is an automated email from the ASF dual-hosted git repository.
littlecui pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-service-center.git
The following commit(s) were added to refs/heads/master by this push:
new 38b4a40 SCB-694 Add 'PLATFORM' register type (#378)
38b4a40 is described below
commit 38b4a4083f89c11bb0a8c536da49e470b9c88b06
Author: aseTo2016 <14...@qq.com>
AuthorDate: Mon Jun 25 15:56:35 2018 +0800
SCB-694 Add 'PLATFORM' register type (#378)
* [SCB-694]registerBY 添加PLATFORM
* [SCB-694]registerBY 添加PLATFORM
---
server/core/proto/services.go | 1 +
server/service/microservice_test.go | 34 ++++++++++++++++++++++++++++++--
server/service/microservice_validator.go | 2 +-
3 files changed, 34 insertions(+), 3 deletions(-)
diff --git a/server/core/proto/services.go b/server/core/proto/services.go
index 1a6de8e..133eb09 100644
--- a/server/core/proto/services.go
+++ b/server/core/proto/services.go
@@ -60,6 +60,7 @@ const (
REGISTERBY_SDK string = "SDK"
REGISTERBY_SIDECAR string = "SIDECAR"
+ REGISTERBY_PLATFORM string = "PLATFORM"
APP_ID = "default"
VERSION = "0.0.1"
diff --git a/server/service/microservice_test.go b/server/service/microservice_test.go
index 5808196..9e419c7 100644
--- a/server/service/microservice_test.go
+++ b/server/service/microservice_test.go
@@ -110,7 +110,7 @@ var _ = Describe("'Micro-service' service", func() {
By("first: create")
resp, err := serviceResource.Create(getContext(), &pb.CreateServiceRequest{
Service: &pb.MicroService{
- ServiceName: "create_serivce_rule_tag",
+ ServiceName: "create_service_rule_tag",
AppId: "default",
Version: "1.0.0",
Level: "FRONT",
@@ -131,7 +131,7 @@ var _ = Describe("'Micro-service' service", func() {
tags["second"] = "second"
resp, err = serviceResource.Create(getContext(), &pb.CreateServiceRequest{
Service: &pb.MicroService{
- ServiceName: "create_serivce_rule_tag",
+ ServiceName: "create_service_rule_tag",
AppId: "default",
Version: "1.0.0",
Level: "FRONT",
@@ -582,6 +582,36 @@ var _ = Describe("'Micro-service' service", func() {
Expect(err).To(BeNil())
Expect(resp.Response.Code).To(Equal(scerr.ErrInvalidParams))
+ By("valid registerBy")
+ r = &pb.CreateServiceRequest{
+ Service: &pb.MicroService{
+ AppId: "default",
+ ServiceName: "registerBy-test",
+ Version: "1.0.10",
+ Level: "BACK",
+ Status: "UP",
+ RegisterBy: "PLATFORM",
+ },
+ }
+ resp, err = serviceResource.Create(getContext(), r)
+ Expect(err).To(BeNil())
+ Expect(resp.Response.Code).To(Equal(pb.Response_SUCCESS))
+
+ By("valid registerBy")
+ r = &pb.CreateServiceRequest{
+ Service: &pb.MicroService{
+ AppId: "default",
+ ServiceName: "registerBy-test",
+ Version: "1.0.11",
+ Level: "BACK",
+ Status: "UP",
+ RegisterBy: "SIDECAR",
+ },
+ }
+ resp, err = serviceResource.Create(getContext(), r)
+ Expect(err).To(BeNil())
+ Expect(resp.Response.Code).To(Equal(pb.Response_SUCCESS))
+
By("invalid description")
r = &pb.CreateServiceRequest{
Service: &pb.MicroService{
diff --git a/server/service/microservice_validator.go b/server/service/microservice_validator.go
index ea72b78..70a3072 100644
--- a/server/service/microservice_validator.go
+++ b/server/service/microservice_validator.go
@@ -47,7 +47,7 @@ var (
statusRegex, _ = regexp.Compile("^(" + pb.MS_UP + "|" + pb.MS_DOWN + ")?$")
serviceIdRegex, _ = regexp.Compile(`^\S*$`)
aliasRegex, _ = regexp.Compile(`^[a-zA-Z0-9_\-.:]*$`)
- registerByRegex, _ = regexp.Compile("^(" + util.StringJoin([]string{pb.REGISTERBY_SDK, pb.REGISTERBY_SIDECAR}, "|") + ")*$")
+ registerByRegex, _ = regexp.Compile("^(" + util.StringJoin([]string{pb.REGISTERBY_SDK, pb.REGISTERBY_SIDECAR, pb.REGISTERBY_PLATFORM}, "|") + ")*$")
envRegex, _ = regexp.Compile("^(" + util.StringJoin([]string{
pb.ENV_DEV, pb.ENV_TEST, pb.ENV_ACCEPT, pb.ENV_PROD}, "|") + ")*$")
schemaIdRegex, _ = regexp.Compile(`^[a-zA-Z0-9]{1,160}$|^[a-zA-Z0-9][a-zA-Z0-9_\-.]{0,158}[a-zA-Z0-9]$`)