mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-12-01 03:07:51 +08:00
merge code
This commit is contained in:
commit
0ad0e4f034
@ -612,6 +612,18 @@ func (t *TenantStruct) CreateService(w http.ResponseWriter, r *http.Request) {
|
||||
httputil.ReturnError(r, w, 500, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
values := url.Values{}
|
||||
if ss.Endpoints != nil && strings.TrimSpace(ss.Endpoints.Static) != "" {
|
||||
if strings.Contains(ss.Endpoints.Static, "127.0.0.1") {
|
||||
values["ip"] = []string{"The ip field is can't contains '127.0.0.1'"}
|
||||
}
|
||||
}
|
||||
if len(values) > 0 {
|
||||
httputil.ReturnValidationError(r, w, values)
|
||||
return
|
||||
}
|
||||
|
||||
tenantID := r.Context().Value(middleware.ContextKey("tenant_id")).(string)
|
||||
ss.TenantID = tenantID
|
||||
logrus.Debugf("begin to create service %s", ss.ServiceAlias)
|
||||
|
@ -22,6 +22,7 @@ import (
|
||||
"encoding/json"
|
||||
"github.com/Sirupsen/logrus"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/goodrain/rainbond/api/handler"
|
||||
"github.com/goodrain/rainbond/api/middleware"
|
||||
@ -51,6 +52,14 @@ func (t *ThirdPartyServiceController) addEndpoints(w http.ResponseWriter, r *htt
|
||||
if !httputil.ValidatorRequestStructAndErrorResponse(r, w, &data, nil) {
|
||||
return
|
||||
}
|
||||
values := make(map[string][]string)
|
||||
if strings.Contains(data.IP, "127.0.0.1") {
|
||||
values["ip"] = []string{"The ip field is can't contains '127.0.0.1'"}
|
||||
}
|
||||
if len(values) != 0 {
|
||||
httputil.ReturnValidationError(r, w, values)
|
||||
return
|
||||
}
|
||||
sid := r.Context().Value(middleware.ContextKey("service_id")).(string)
|
||||
if err := handler.Get3rdPartySvcHandler().AddEndpoints(sid, &data); err != nil {
|
||||
httputil.ReturnError(r, w, 500, err.Error())
|
||||
@ -64,6 +73,14 @@ func (t *ThirdPartyServiceController) updEndpoints(w http.ResponseWriter, r *htt
|
||||
if !httputil.ValidatorRequestStructAndErrorResponse(r, w, &data, nil) {
|
||||
return
|
||||
}
|
||||
values := make(map[string][]string)
|
||||
if strings.Contains(data.IP, "127.0.0.1") {
|
||||
values["ip"] = []string{"The ip field is can't contains '127.0.0.1'"}
|
||||
}
|
||||
if len(values) != 0 {
|
||||
httputil.ReturnValidationError(r, w, values)
|
||||
return
|
||||
}
|
||||
if err := handler.Get3rdPartySvcHandler().UpdEndpoints(&data); err != nil {
|
||||
httputil.ReturnError(r, w, 500, err.Error())
|
||||
return
|
||||
|
@ -333,12 +333,13 @@ type ServiceStruct struct {
|
||||
DepVolumesInfo []dbmodel.TenantServiceMountRelation `json:"dep_volumes_info"`
|
||||
EnvsInfo []dbmodel.TenantServiceEnvVar `json:"envs_info"`
|
||||
PortsInfo []dbmodel.TenantServicesPort `json:"ports_info"`
|
||||
Endpoints *Endpoints `json:"endpoints"`
|
||||
}
|
||||
|
||||
// Endpoints holds third-party service endpoints or configuraion to get endpoints.
|
||||
Endpoints struct {
|
||||
Static string `json:"static"`
|
||||
Discovery string `json:"discovery"`
|
||||
} `json:"endpoints"`
|
||||
// Endpoints holds third-party service endpoints or configuraion to get endpoints.
|
||||
type Endpoints struct {
|
||||
Static string `json:"static"`
|
||||
Discovery string `json:"discovery"`
|
||||
}
|
||||
|
||||
//TenantServiceVolumeStruct -
|
||||
|
Loading…
Reference in New Issue
Block a user