mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-12-01 03:07:51 +08:00
Merge branch 'V5.1' of https://github.com/goodrain/rainbond into V5.1
This commit is contained in:
commit
2c864f42bf
@ -31,6 +31,7 @@ import (
|
||||
"github.com/goodrain/rainbond/cmd/api/option"
|
||||
"github.com/goodrain/rainbond/mq/client"
|
||||
httputil "github.com/goodrain/rainbond/util/http"
|
||||
k8svalidation "k8s.io/apimachinery/pkg/util/validation"
|
||||
)
|
||||
|
||||
// GatewayStruct -
|
||||
@ -52,6 +53,19 @@ func (g *GatewayStruct) HTTPRule(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
func validateDomain(domain string) []string {
|
||||
if strings.TrimSpace(domain) == "" {
|
||||
return nil
|
||||
}
|
||||
var errs []string
|
||||
if strings.Contains(domain, "*") {
|
||||
errs = k8svalidation.IsWildcardDNS1123Subdomain(domain)
|
||||
} else {
|
||||
errs = k8svalidation.IsDNS1123Subdomain(domain)
|
||||
}
|
||||
return errs
|
||||
}
|
||||
|
||||
func (g *GatewayStruct) addHTTPRule(w http.ResponseWriter, r *http.Request) {
|
||||
var req api_model.AddHTTPRuleStruct
|
||||
ok := httputil.ValidatorRequestStructAndErrorResponse(r, w, &req, nil)
|
||||
@ -72,6 +86,11 @@ func (g *GatewayStruct) addHTTPRule(w http.ResponseWriter, r *http.Request) {
|
||||
values["private_key"] = []string{"The private_key field is required"}
|
||||
}
|
||||
}
|
||||
errs := validateDomain(req.Domain)
|
||||
if errs != nil && len(errs) > 0 {
|
||||
logrus.Debugf("Invalid domain: %s", strings.Join(errs, ";"))
|
||||
values["domain"] = []string{"The domain field is invalid"}
|
||||
}
|
||||
if len(values) != 0 {
|
||||
httputil.ReturnValidationError(r, w, values)
|
||||
return
|
||||
@ -123,6 +142,11 @@ func (g *GatewayStruct) updateHTTPRule(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
}
|
||||
errs := validateDomain(req.Domain)
|
||||
if errs != nil && len(errs) > 0 {
|
||||
logrus.Debugf("Invalid domain: %s", strings.Join(errs, ";"))
|
||||
values["domain"] = []string{"The domain field is invalid"}
|
||||
}
|
||||
if len(values) != 0 {
|
||||
httputil.ReturnValidationError(r, w, values)
|
||||
return
|
||||
|
@ -402,9 +402,9 @@ func createVolumes(as *v1.AppService, version *dbmodel.VersionInfo, dbmanager db
|
||||
return nil, fmt.Errorf("error getting TenantServiceVolume according to serviceID(%s) and volumeName(%s): %v",
|
||||
t.DependServiceID, t.VolumeName, err)
|
||||
}
|
||||
cf, err := dbmanager.TenantServiceConfigFileDao().GetByVolumeName(as.ServiceID, t.VolumeName)
|
||||
cf, err := dbmanager.TenantServiceConfigFileDao().GetByVolumeName(t.DependServiceID, t.VolumeName)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error getting TenantServiceConfigFileDao according to volumeName(%s): %v", t.VolumeName, err)
|
||||
return nil, fmt.Errorf("error getting TenantServiceConfigFile according to volumeName(%s): %v", t.VolumeName, err)
|
||||
}
|
||||
|
||||
cmap := &corev1.ConfigMap{
|
||||
|
Loading…
Reference in New Issue
Block a user