lb: onecloud: allow empty string for redirect_{scheme,host,path}

This commit is contained in:
Yousong Zhou
2020-06-19 10:17:04 +08:00
parent 4ce404dd8d
commit 3fe10a7383
2 changed files with 12 additions and 10 deletions
+4 -2
View File
@@ -295,11 +295,13 @@ var LB_REDIRECT_CODES = []int64{
}
const (
LB_REDIRECT_SCHEME_HTTP = "http"
LB_REDIRECT_SCHEME_HTTPS = "https"
LB_REDIRECT_SCHEME_IDENTITY = ""
LB_REDIRECT_SCHEME_HTTP = "http"
LB_REDIRECT_SCHEME_HTTPS = "https"
)
var LB_REDIRECT_SCHEMES = choices.NewChoices(
LB_REDIRECT_SCHEME_IDENTITY,
LB_REDIRECT_SCHEME_HTTP,
LB_REDIRECT_SCHEME_HTTPS,
)
+8 -8
View File
@@ -299,8 +299,8 @@ func (self *SKVMRegionDriver) ValidateCreateLoadbalancerListenerRuleData(ctx con
"redirect": redirectV.Default(api.LB_REDIRECT_OFF),
"redirect_code": redirectCodeV.Default(api.LB_REDIRECT_CODE_302),
"redirect_scheme": redirectSchemeV.Optional(true),
"redirect_host": redirectHostV.Optional(true),
"redirect_path": redirectPathV.Optional(true),
"redirect_host": redirectHostV.AllowEmpty(true).Optional(true),
"redirect_path": redirectPathV.AllowEmpty(true).Optional(true),
}
if err := RunValidators(keyV, data, false); err != nil {
@@ -382,8 +382,8 @@ func (self *SKVMRegionDriver) ValidateUpdateLoadbalancerListenerRuleData(ctx con
"redirect": redirectV,
"redirect_code": redirectCodeV,
"redirect_scheme": redirectSchemeV,
"redirect_host": redirectHostV,
"redirect_path": redirectPathV,
"redirect_host": redirectHostV.AllowEmpty(true),
"redirect_path": redirectPathV.AllowEmpty(true),
}
for _, v := range keyV {
v.Optional(true)
@@ -475,8 +475,8 @@ func (self *SKVMRegionDriver) ValidateCreateLoadbalancerListenerData(ctx context
"redirect": redirectV.Default(api.LB_REDIRECT_OFF),
"redirect_code": redirectCodeV.Default(api.LB_REDIRECT_CODE_302),
"redirect_scheme": redirectSchemeV.Optional(true),
"redirect_host": redirectHostV.Optional(true),
"redirect_path": redirectPathV.Optional(true),
"redirect_host": redirectHostV.AllowEmpty(true).Optional(true),
"redirect_path": redirectPathV.AllowEmpty(true).Optional(true),
}
if err := RunValidators(keyV, data, false); err != nil {
@@ -637,8 +637,8 @@ func (self *SKVMRegionDriver) ValidateUpdateLoadbalancerListenerData(ctx context
"redirect": redirectV,
"redirect_code": redirectCodeV,
"redirect_scheme": redirectSchemeV,
"redirect_host": redirectHostV,
"redirect_path": redirectPathV,
"redirect_host": redirectHostV.AllowEmpty(true),
"redirect_path": redirectPathV.AllowEmpty(true),
}
if err := RunValidators(keyV, data, true); err != nil {