Merge pull request #303 from GLYASAI/RAINBOND-998

[FIX] err creating third-party service
This commit is contained in:
barnettZQG 2019-06-25 17:51:08 +08:00 committed by GitHub
commit 8093677ff7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View File

@ -600,7 +600,6 @@ func (t *TenantStruct) CreateService(w http.ResponseWriter, r *http.Request) {
tenantID := r.Context().Value(middleware.ContextKey("tenant_id")).(string)
ss.TenantID = tenantID
logrus.Debugf("begin to create service %s", ss.ServiceAlias)
if err := handler.GetServiceManager().ServiceCreate(&ss); err != nil {
httputil.ReturnError(r, w, 500, fmt.Sprintf("create service error, %v", err))
return

View File

@ -631,6 +631,9 @@ func (s *ServiceAction) ServiceCreate(sc *api_model.ServiceStruct) error {
// sc.Endpoints can't be nil
// sc.Endpoints.Discovery or sc.Endpoints.Static can't be nil
if sc.Kind == dbmodel.ServiceKindThirdParty.String() { // TODO: validate request data
if sc.Endpoints == nil {
return fmt.Errorf("endpoints can not be empty for third-party service")
}
if config := strings.Replace(sc.Endpoints.Discovery, " ", "", -1); config != "" {
var cfg dCfg
err := json.Unmarshal([]byte(config), &cfg)