[ 
https://issues.apache.org/jira/browse/SCB-914?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16621365#comment-16621365
 ] 

ASF GitHub Bot commented on SCB-914:
------------------------------------

little-cui closed pull request #442: SCB-914 Support using scctl to download 
schemas
URL: https://github.com/apache/incubator-servicecomb-service-center/pull/442
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/glide.yaml b/glide.yaml
index f18baaa3..89eaa69c 100644
--- a/glide.yaml
+++ b/glide.yaml
@@ -404,3 +404,6 @@ import:
 - package: github.com/olekukonko/tablewriter
   version: d4647c9c7a84d847478d890b816b7d8b62b0b279
   repo: https://github.com/olekukonko/tablewriter
+- package: github.com/cheggaaa/pb
+  version: v1.0.25
+  repo: https://github.com/cheggaaa/pb
diff --git a/go.mod b/go.mod
index ff876244..08169850 100644
--- a/go.mod
+++ b/go.mod
@@ -21,6 +21,7 @@ require (
        github.com/astaxie/beego v1.8.0
        github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 // indirect
        github.com/boltdb/bolt v1.3.1 // indirect
+       github.com/cheggaaa/pb v1.0.25
        github.com/cockroachdb/cmux v0.0.0-20170110192607-30d10be49292 // 
indirect
        github.com/coreos/etcd v3.1.9+incompatible
        github.com/coreos/go-semver v0.2.0 // indirect
diff --git a/pkg/client/sc/apis.go b/pkg/client/sc/apis.go
index f6dd2fec..7e0e6abe 100644
--- a/pkg/client/sc/apis.go
+++ b/pkg/client/sc/apis.go
@@ -18,24 +18,30 @@ package sc
 import (
        "encoding/json"
        "fmt"
-       "github.com/apache/incubator-servicecomb-service-center/pkg/rest"
        
"github.com/apache/incubator-servicecomb-service-center/server/admin/model"
+       "github.com/apache/incubator-servicecomb-service-center/server/core"
+       pb 
"github.com/apache/incubator-servicecomb-service-center/server/core/proto"
        "github.com/apache/incubator-servicecomb-service-center/version"
        "io/ioutil"
        "net/http"
 )
 
 const (
-       apiVersionURL = "/version"
-       apiDumpURL    = "/v4/default/admin/dump"
+       apiVersionURL    = "/version"
+       apiDumpURL       = "/v4/default/admin/dump"
+       apiGetSchemasURL = "/v4/%s/registry/microservices/%s/schemas"
 )
 
-func GetScVersion(scClient *rest.URLClient) (*version.VersionSet, error) {
+func (c *SCClient) commonHeaders() http.Header {
        var headers = make(http.Header)
        if len(Token) > 0 {
                headers.Set("X-Auth-Token", Token)
        }
-       resp, err := scClient.HttpDo(http.MethodGet, Addr+apiVersionURL, 
headers, nil)
+       return headers
+}
+
+func (c *SCClient) GetScVersion() (*version.VersionSet, error) {
+       resp, err := c.client.HttpDo(http.MethodGet, Addr+apiVersionURL, 
c.commonHeaders(), nil)
        if err != nil {
                return nil, err
        }
@@ -60,14 +66,10 @@ func GetScVersion(scClient *rest.URLClient) 
(*version.VersionSet, error) {
        return v, nil
 }
 
-func GetScCache(scClient *rest.URLClient) (*model.Cache, error) {
-       headers := http.Header{
-               "X-Domain-Name": []string{"default"},
-       }
-       if len(Token) > 0 {
-               headers.Set("X-Auth-Token", Token)
-       }
-       resp, err := scClient.HttpDo(http.MethodGet, Addr+apiDumpURL, headers, 
nil)
+func (c *SCClient) GetScCache() (*model.Cache, error) {
+       headers := c.commonHeaders()
+       headers.Set("X-Domain-Name", "default")
+       resp, err := c.client.HttpDo(http.MethodGet, Addr+apiDumpURL, headers, 
nil)
        if err != nil {
                return nil, err
        }
@@ -91,3 +93,34 @@ func GetScCache(scClient *rest.URLClient) (*model.Cache, 
error) {
 
        return dump.Cache, nil
 }
+
+func (c *SCClient) GetSchemasByServiceId(domainProject, serviceId string) 
([]*pb.Schema, error) {
+       domain, project := core.FromDomainProject(domainProject)
+       headers := c.commonHeaders()
+       headers.Set("X-Domain-Name", domain)
+       resp, err := c.client.HttpDo(http.MethodGet,
+               Addr+fmt.Sprintf(apiGetSchemasURL, project, 
serviceId)+"?withSchema=1",
+               headers, nil)
+       if err != nil {
+               return nil, err
+       }
+       defer resp.Body.Close()
+
+       body, err := ioutil.ReadAll(resp.Body)
+       if err != nil {
+               return nil, err
+       }
+
+       if resp.StatusCode != http.StatusOK {
+               return nil, fmt.Errorf("%d %s", resp.StatusCode, string(body))
+       }
+
+       schemas := &pb.GetAllSchemaResponse{}
+       err = json.Unmarshal(body, schemas)
+       if err != nil {
+               fmt.Println(string(body))
+               return nil, err
+       }
+
+       return schemas.Schemas, nil
+}
diff --git a/pkg/client/sc/client.go b/pkg/client/sc/client.go
index b035b0ce..1067fd38 100644
--- a/pkg/client/sc/client.go
+++ b/pkg/client/sc/client.go
@@ -33,13 +33,13 @@ var (
        CAPath      string
 )
 
-func NewSCClient() (*rest.URLClient, error) {
+func NewSCClient() (*SCClient, error) {
        ssl := strings.Index(Addr, "https://";) >= 0
        if ssl && len(KeyPass) == 0 && len(KeyPassPath) > 0 {
                content, _ := ioutil.ReadFile(KeyPassPath)
                KeyPass = string(content)
        }
-       return rest.GetURLClient(&rest.URLClientOption{
+       client, err := rest.GetURLClient(&rest.URLClientOption{
                SSLEnabled:     ssl,
                VerifyPeer:     VerifyPeer,
                CAFile:         CAPath,
@@ -48,4 +48,12 @@ func NewSCClient() (*rest.URLClient, error) {
                CertKeyPWD:     KeyPass,
                RequestTimeout: 10 * time.Second,
        })
+       if err != nil {
+               return nil, err
+       }
+       return &SCClient{client: client}, nil
+}
+
+type SCClient struct {
+       client *rest.URLClient
 }
diff --git a/scctl/bootstrap/bootstrap.go b/scctl/bootstrap/bootstrap.go
index 5671663d..b1ff4815 100644
--- a/scctl/bootstrap/bootstrap.go
+++ b/scctl/bootstrap/bootstrap.go
@@ -19,3 +19,4 @@ import _ 
"github.com/apache/incubator-servicecomb-service-center/scctl/pkg/plugi
 import _ 
"github.com/apache/incubator-servicecomb-service-center/scctl/pkg/plugin/diagnose"
 import _ 
"github.com/apache/incubator-servicecomb-service-center/scctl/pkg/plugin/get/service"
 import _ 
"github.com/apache/incubator-servicecomb-service-center/scctl/pkg/plugin/get/instance"
+import _ 
"github.com/apache/incubator-servicecomb-service-center/scctl/pkg/plugin/get/schema"
diff --git a/scctl/pkg/plugin/README.md b/scctl/pkg/plugin/README.md
index 464283b8..da9f2db8 100644
--- a/scctl/pkg/plugin/README.md
+++ b/scctl/pkg/plugin/README.md
@@ -77,6 +77,63 @@ Get the instances list from ServiceCenter. `instance` 
command can be instead of
 #   desktop-0001 | rest://127.0.0.1:30100/ | 0.0.1   | SERVICECENTER | default 
| 2m    | 18m
 ```
 
+
+### schema [options]
+
+Get the schemas content from ServiceCenter.
+
+#### Options
+
+- `domain`(d) domain name, return all microservice schema contents from 
`default` domain by default.
+- `app` the application name of microservice.
+- `name` the name of microservice.
+- `version` the semantic version of microservice.
+- `save-dir`(s) the directory to save the schema content,
+the schema file path structure follows the rule:
+`{save-dir}/schemas/[{domain}/][{project}/][{env}/]{app}/{microservice}.{version}/{schemaId}.yaml`
 
+- `all-domains` return all microservice schema contents from all domains.
+
+#### Examples
+```bash
+# save schemas to files
+./scctl get schema -s .
+#  2 / 2 [============================================================] 
100.00% 0s
+# Finished.
+ls -l schemas/springmvc/provider.v0.0.1
+# total 4
+# -rw-r----- 1 ubuntu ubuntu 610 Sep 15 23:05 say.yaml
+
+# print schema to console
+./scctl get schema --name provider
+# ---
+# swagger: "2.0"
+# info:
+#   version: "1.0.0"
+#   title: "swagger definition for 
com.service.provider.controller.ProviderImpl"
+#   x-java-interface: "cse.gen.springmvc.provider.provider.ProviderImplIntf"
+# basePath: "/say"
+# consumes:
+# - "application/json"
+# produces:
+# - "application/json"
+# paths:
+#   /helloworld:
+#     get:
+#       operationId: "helloworld"
+#       produces:
+#       - "application/json"
+#       parameters:
+#       - name: "name"
+#         in: "query"
+#         required: false
+#         type: "string"
+#       responses:
+#         200:
+#           description: "response of 200"
+#           schema:
+#             type: "string"
+```
+
 ## Diagnose commands
 
 The diagnostic command can output the ServiceCenter health report. 
diff --git a/scctl/pkg/plugin/diagnose/diagnose.go 
b/scctl/pkg/plugin/diagnose/diagnose.go
index 4efdae18..68929559 100644
--- a/scctl/pkg/plugin/diagnose/diagnose.go
+++ b/scctl/pkg/plugin/diagnose/diagnose.go
@@ -65,7 +65,7 @@ func DiagnoseCommandFunc(_ *cobra.Command, args []string) {
        }
 
        // query sc
-       cache, err := sc.GetScCache(scClient)
+       cache, err := scClient.GetScCache()
        if err != nil {
                cmd.StopAndExit(cmd.ExitError, err)
        }
diff --git a/scctl/pkg/plugin/get/instance/instance_cmd.go 
b/scctl/pkg/plugin/get/instance/instance_cmd.go
index 19db3366..43cf9608 100644
--- a/scctl/pkg/plugin/get/instance/instance_cmd.go
+++ b/scctl/pkg/plugin/get/instance/instance_cmd.go
@@ -47,7 +47,7 @@ func InstanceCommandFunc(_ *cobra.Command, args []string) {
        if err != nil {
                cmd.StopAndExit(cmd.ExitError, err)
        }
-       cache, err := sc.GetScCache(scClient)
+       cache, err := scClient.GetScCache()
        if err != nil {
                cmd.StopAndExit(cmd.ExitError, err)
        }
diff --git a/scctl/pkg/plugin/get/instance/types.go 
b/scctl/pkg/plugin/get/instance/types.go
index 36ac2395..180ca85c 100644
--- a/scctl/pkg/plugin/get/instance/types.go
+++ b/scctl/pkg/plugin/get/instance/types.go
@@ -20,7 +20,6 @@ import (
        "github.com/apache/incubator-servicecomb-service-center/scctl/pkg/model"
        
"github.com/apache/incubator-servicecomb-service-center/scctl/pkg/writer"
        "github.com/apache/incubator-servicecomb-service-center/server/core"
-       "strings"
        "time"
 )
 
@@ -62,10 +61,8 @@ func (s *InstanceRecord) AgeString() string {
 }
 
 func (s *InstanceRecord) Domain() string {
-       if i := strings.Index(s.DomainProject, core.SPLIT); i >= 0 {
-               return s.DomainProject[:i]
-       }
-       return s.DomainProject
+       domain, _ := core.FromDomainProject(s.DomainProject)
+       return domain
 }
 
 func (s *InstanceRecord) PrintBody(fmt string, all bool) []string {
diff --git a/scctl/pkg/plugin/get/schema/schema_cmd.go 
b/scctl/pkg/plugin/get/schema/schema_cmd.go
new file mode 100644
index 00000000..caa2cfeb
--- /dev/null
+++ b/scctl/pkg/plugin/get/schema/schema_cmd.go
@@ -0,0 +1,130 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package schema
+
+import (
+       "fmt"
+       "github.com/apache/incubator-servicecomb-service-center/pkg/client/sc"
+       "github.com/apache/incubator-servicecomb-service-center/scctl/pkg/cmd"
+       "github.com/apache/incubator-servicecomb-service-center/scctl/pkg/model"
+       
"github.com/apache/incubator-servicecomb-service-center/scctl/pkg/plugin/get"
+       
"github.com/apache/incubator-servicecomb-service-center/scctl/pkg/progress-bar"
+       adminModel 
"github.com/apache/incubator-servicecomb-service-center/server/admin/model"
+       "github.com/apache/incubator-servicecomb-service-center/server/core"
+       "github.com/spf13/cobra"
+       "io"
+       "io/ioutil"
+       "os"
+       "path/filepath"
+       "strings"
+)
+
+const (
+       defaultBufferSize = 64 * 1024
+)
+
+var (
+       AppId       string
+       ServiceName string
+       Version     string
+       SaveDir     string
+)
+
+func init() {
+       NewSchemaCommand(get.RootCmd)
+}
+
+func NewSchemaCommand(parent *cobra.Command) *cobra.Command {
+       cmd := &cobra.Command{
+               Use:   "schema [options]",
+               Short: "Output the microservice schema information of the 
service center ",
+               Run:   SchemaCommandFunc,
+       }
+
+       cmd.Flags().StringVarP(&SaveDir, "save-dir", "s", "",
+               "the directory to save the schemas data")
+       cmd.Flags().StringVar(&AppId, "app", "", "the application name of 
microservice")
+       cmd.Flags().StringVar(&ServiceName, "name", "", "the name of 
microservice")
+       cmd.Flags().StringVar(&Version, "version", "", "the semantic version of 
microservice")
+
+       parent.AddCommand(cmd)
+       return cmd
+}
+
+// 
schemas/[${domain}/][${project}/][${env}/]${app}/${microservice}.${version}/${schemaId}.yaml
+func saveDirectory(root string, ms *adminModel.Microservice) string {
+       if len(root) == 0 {
+               return ""
+       }
+       domain, project := core.FromDomainProject(model.GetDomainProject(ms))
+       if domain == core.REGISTRY_DOMAIN {
+               domain = ""
+       }
+       if project == core.REGISTRY_DOMAIN {
+               project = ""
+       }
+       return filepath.Join(root, "schemas", domain, project, 
ms.Value.Environment, ms.Value.AppId, 
ms.Value.ServiceName+".v"+ms.Value.Version)
+}
+
+func SchemaCommandFunc(_ *cobra.Command, args []string) {
+       scClient, err := sc.NewSCClient()
+       if err != nil {
+               cmd.StopAndExit(cmd.ExitError, err)
+       }
+       cache, err := scClient.GetScCache()
+       if err != nil {
+               cmd.StopAndExit(cmd.ExitError, err)
+       }
+
+       var progressBarWriter io.Writer = os.Stdout
+       if len(SaveDir) == 0 {
+               progressBarWriter = ioutil.Discard
+       }
+       progressBar := pb.NewProgressBar(len(cache.Microservices), 
progressBarWriter)
+       defer progressBar.FinishPrint("Finished.")
+
+       for _, ms := range cache.Microservices {
+               progressBar.Increment()
+
+               domainProject := model.GetDomainProject(ms)
+               if !get.AllDomains && strings.Index(domainProject+core.SPLIT, 
get.Domain+core.SPLIT) != 0 {
+                       continue
+               }
+               if len(AppId) > 0 && ms.Value.AppId != AppId {
+                       continue
+               }
+               if len(ServiceName) > 0 && ms.Value.ServiceName != ServiceName {
+                       continue
+               }
+               if len(Version) > 0 && ms.Value.Version != Version {
+                       continue
+               }
+
+               schemas, err := scClient.GetSchemasByServiceId(domainProject, 
ms.Value.ServiceId)
+               if err != nil {
+                       cmd.StopAndExit(cmd.ExitError, err)
+               }
+               if len(schemas) == 0 {
+                       continue
+               }
+
+               writer := NewSchemaWriter(Config{SaveDir: 
saveDirectory(SaveDir, ms)})
+               err = writer.Write(schemas)
+               if err != nil {
+                       fmt.Fprintln(os.Stderr, "output schema data failed", 
err.Error())
+               }
+       }
+}
diff --git a/scctl/pkg/plugin/get/schema/types.go 
b/scctl/pkg/plugin/get/schema/types.go
new file mode 100644
index 00000000..5d498b8e
--- /dev/null
+++ b/scctl/pkg/plugin/get/schema/types.go
@@ -0,0 +1,77 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package schema
+
+import (
+       pb 
"github.com/apache/incubator-servicecomb-service-center/server/core/proto"
+       "os"
+       "path/filepath"
+)
+
+type Config struct {
+       SaveDir string
+}
+
+type SchemaWriter interface {
+       Write([]*pb.Schema) error
+}
+
+func NewSchemaWriter(cfg Config) SchemaWriter {
+       switch {
+       case len(cfg.SaveDir) == 0:
+               return &SchemaStdoutWriter{}
+       default:
+               return &SchemaFileWriter{cfg.SaveDir}
+       }
+}
+
+type SchemaStdoutWriter struct {
+}
+
+func (w *SchemaStdoutWriter) Write(schemas []*pb.Schema) error {
+       for _, schema := range schemas {
+               _, err := os.Stdout.WriteString(schema.Schema)
+               if err != nil {
+                       return err
+               }
+       }
+       return nil
+}
+
+type SchemaFileWriter struct {
+       Dir string
+}
+
+func (w *SchemaFileWriter) Write(schemas []*pb.Schema) error {
+       err := os.MkdirAll(w.Dir, 0750)
+       if err != nil {
+               return err
+       }
+       for _, schemas := range schemas {
+               file, err := os.OpenFile(filepath.Join(w.Dir, 
schemas.SchemaId+".yaml"),
+                       os.O_TRUNC|os.O_CREATE|os.O_WRONLY, 0640)
+               if err != nil {
+                       return err
+               }
+               _, err = file.WriteString(schemas.Schema)
+               if err != nil {
+                       file.Close()
+                       return err
+               }
+               file.Close()
+       }
+       return nil
+}
diff --git a/scctl/pkg/plugin/get/service/service_cmd.go 
b/scctl/pkg/plugin/get/service/service_cmd.go
index 280968be..b69bd150 100644
--- a/scctl/pkg/plugin/get/service/service_cmd.go
+++ b/scctl/pkg/plugin/get/service/service_cmd.go
@@ -35,7 +35,7 @@ func NewServiceCommand(parent *cobra.Command) *cobra.Command {
        cmd := &cobra.Command{
                Use:     "service [options]",
                Aliases: []string{"svc"},
-               Short:   "Output the service information of the service center 
",
+               Short:   "Output the microservice information of the service 
center ",
                Run:     ServiceCommandFunc,
        }
 
@@ -48,7 +48,7 @@ func ServiceCommandFunc(_ *cobra.Command, args []string) {
        if err != nil {
                cmd.StopAndExit(cmd.ExitError, err)
        }
-       cache, err := sc.GetScCache(scClient)
+       cache, err := scClient.GetScCache()
        if err != nil {
                cmd.StopAndExit(cmd.ExitError, err)
        }
diff --git a/scctl/pkg/plugin/get/service/types.go 
b/scctl/pkg/plugin/get/service/types.go
index b96f2eec..d00f6d8d 100644
--- a/scctl/pkg/plugin/get/service/types.go
+++ b/scctl/pkg/plugin/get/service/types.go
@@ -20,7 +20,6 @@ import (
        "github.com/apache/incubator-servicecomb-service-center/scctl/pkg/model"
        
"github.com/apache/incubator-servicecomb-service-center/scctl/pkg/writer"
        "github.com/apache/incubator-servicecomb-service-center/server/core"
-       "strings"
 )
 
 const maxWidth = 35
@@ -56,10 +55,8 @@ func (s *ServiceRecord) AgeString() string {
 }
 
 func (s *ServiceRecord) Domain() string {
-       if i := strings.Index(s.DomainProject, core.SPLIT); i >= 0 {
-               return s.DomainProject[:i]
-       }
-       return s.DomainProject
+       domain, _ := core.FromDomainProject(s.DomainProject)
+       return domain
 }
 
 func (s *ServiceRecord) PrintBody(fmt string, all bool) []string {
diff --git a/scctl/pkg/plugin/version/cmd.go b/scctl/pkg/plugin/version/cmd.go
index 27eab80d..ddbec2ff 100644
--- a/scctl/pkg/plugin/version/cmd.go
+++ b/scctl/pkg/plugin/version/cmd.go
@@ -51,7 +51,7 @@ func VersionCommandFunc(_ *cobra.Command, _ []string) {
        if err != nil {
                return
        }
-       v, err := sc.GetScVersion(scClient)
+       v, err := scClient.GetScVersion()
        if err != nil {
                return
        }
diff --git a/scctl/pkg/progress-bar/progress-bar.go 
b/scctl/pkg/progress-bar/progress-bar.go
new file mode 100644
index 00000000..96acae9e
--- /dev/null
+++ b/scctl/pkg/progress-bar/progress-bar.go
@@ -0,0 +1,32 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package pb
+
+import (
+       "github.com/cheggaaa/pb"
+       "io"
+)
+
+func NewProgressBar(count int, w io.Writer) *pb.ProgressBar {
+       bar := pb.New(count)
+       bar.Output = w
+       bar.Empty = " "
+       bar.SetMaxWidth(80)
+       bar.ShowTimeLeft = false
+       bar.ShowSpeed = false
+       bar.Start()
+       return bar
+}
diff --git a/scripts/release/LICENSE b/scripts/release/LICENSE
index ab0467bb..bc9f83f4 100644
--- a/scripts/release/LICENSE
+++ b/scripts/release/LICENSE
@@ -933,3 +933,11 @@ For valyala/bytebufferpool (master)
 This product bundles valyala/bytebufferpool which is licensed under the MIT 
License.
 For details, see https://github.com/valyala/bytebufferpool
 You can find a copy of the License at licenses/LICENSE-valyala-bytebufferpool
+
+================================================================
+For cheggaaa/pb (v1.0.25)
+================================================================
+This product bundles cheggaaa/pb which is licensed under the 3-Clause BSD
+License.
+For details, see https://github.com/cheggaaa/pb
+You can find a copy of the License at licenses/LICENSE-cheggaaa-pb
diff --git a/scripts/release/licenses/LICENSE-cheggaaa-pb 
b/scripts/release/licenses/LICENSE-cheggaaa-pb
new file mode 100644
index 00000000..51197033
--- /dev/null
+++ b/scripts/release/licenses/LICENSE-cheggaaa-pb
@@ -0,0 +1,12 @@
+Copyright (c) 2012-2015, Sergey Cherepanov
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without 
modification, are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice, this 
list of conditions and the following disclaimer.
+
+* Redistributions in binary form must reproduce the above copyright notice, 
this list of conditions and the following disclaimer in the documentation 
and/or other materials provided with the distribution.
+
+* Neither the name of the author nor the names of its contributors may be used 
to endorse or promote products derived from this software without specific 
prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
diff --git a/server/core/key_convertor.go b/server/core/key_convertor.go
index 1f6353d9..0e860f1a 100644
--- a/server/core/key_convertor.go
+++ b/server/core/key_convertor.go
@@ -162,3 +162,15 @@ func GetInfoFromDependencyRuleKV(key []byte) 
*pb.MicroServiceKey {
                Version:     keys[l-1],
        }
 }
+
+func FromDomainProject(domainProject string) (domain, project string) {
+       if i := strings.Index(domainProject, "/"); i >= 0 {
+               return domainProject[:i], domainProject[i+1:]
+       }
+       return domainProject, ""
+}
+
+func ToDomainProject(domain, project string) (domainProject string) {
+       domainProject = domain + "/" + project
+       return
+}
diff --git a/server/core/microservice.go b/server/core/microservice.go
index 8d6a0ccd..90c0d95b 100644
--- a/server/core/microservice.go
+++ b/server/core/microservice.go
@@ -35,8 +35,9 @@ var (
 )
 
 const (
-       REGISTRY_DOMAIN  = "default"
-       REGISTRY_PROJECT = "default"
+       REGISTRY_DOMAIN         = "default"
+       REGISTRY_PROJECT        = "default"
+       REGISTRY_DOMAIN_PROJECT = "default/default"
 
        REGISTRY_APP_ID       = "default"
        REGISTRY_SERVICE_NAME = "SERVICECENTER"
@@ -90,7 +91,7 @@ func AddDefaultContextValue(ctx context.Context) 
context.Context {
 }
 
 func IsDefaultDomainProject(domainProject string) bool {
-       return domainProject == util.StringJoin([]string{REGISTRY_DOMAIN, 
REGISTRY_PROJECT}, "/")
+       return domainProject == REGISTRY_DOMAIN_PROJECT
 }
 
 func SetSharedMode() {
diff --git a/server/service/instance.go b/server/service/instance.go
index b40dbeec..f33fe486 100644
--- a/server/service/instance.go
+++ b/server/service/instance.go
@@ -716,7 +716,7 @@ func (s *InstanceService) UpdateInstanceProperties(ctx 
context.Context, in *pb.U
 }
 
 func (s *InstanceService) ClusterHealth(ctx context.Context) 
(*pb.GetInstancesResponse, error) {
-       domainProject := util.StringJoin([]string{apt.REGISTRY_DOMAIN, 
apt.REGISTRY_PROJECT}, "/")
+       domainProject := apt.REGISTRY_DOMAIN_PROJECT
        serviceId, err := serviceUtil.GetServiceId(ctx, &pb.MicroServiceKey{
                AppId:       apt.Service.AppId,
                Environment: apt.Service.Environment,


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Support using scctl to download schemas
> ---------------------------------------
>
>                 Key: SCB-914
>                 URL: https://issues.apache.org/jira/browse/SCB-914
>             Project: Apache ServiceComb
>          Issue Type: New Feature
>          Components: Service-Center
>            Reporter: little-cui
>            Assignee: little-cui
>            Priority: Major
>             Fix For: service-center-1.1.0
>
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to