Skip to content

Commit 4330617

Browse files
committed
add
1 parent 365c103 commit 4330617

File tree

1 file changed

+35
-31
lines changed

1 file changed

+35
-31
lines changed

tencentcloud/services/cos/resource_tc_cos_bucket.go

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,41 +1489,45 @@ func resourceTencentCloudCosBucketWebsiteUpdate(ctx context.Context, meta interf
14891489

14901490
if v, ok := w["routing_rules"]; ok {
14911491
websiteRoutingRules := cos.WebsiteRoutingRules{}
1492-
for _, item := range v.([]interface{}) {
1493-
rules := item.(map[string]interface{})
1494-
if v, ok := rules["rules"]; ok {
1495-
wbRules := []cos.WebsiteRoutingRule{}
1496-
for _, rule := range v.([]interface{}) {
1497-
dMap := rule.(map[string]interface{})
1498-
wbRule := cos.WebsiteRoutingRule{}
1499-
if v, ok := dMap["condition_error_code"].(string); ok && v != "" {
1500-
wbRule.ConditionErrorCode = v
1492+
if len(v.([]interface{})) > 0 {
1493+
for _, item := range v.([]interface{}) {
1494+
if rules, ok := item.(map[string]interface{}); ok && rules != nil {
1495+
if v, ok := rules["rules"]; ok {
1496+
wbRules := []cos.WebsiteRoutingRule{}
1497+
for _, rule := range v.([]interface{}) {
1498+
if dMap, ok := rule.(map[string]interface{}); ok && rules != nil {
1499+
wbRule := cos.WebsiteRoutingRule{}
1500+
if v, ok := dMap["condition_error_code"].(string); ok && v != "" {
1501+
wbRule.ConditionErrorCode = v
1502+
}
1503+
1504+
if v, ok := dMap["condition_prefix"].(string); ok && v != "" {
1505+
wbRule.ConditionPrefix = v
1506+
}
1507+
1508+
if v, ok := dMap["redirect_protocol"].(string); ok && v != "" {
1509+
wbRule.RedirectProtocol = v
1510+
}
1511+
1512+
if v, ok := dMap["redirect_replace_key"].(string); ok && v != "" {
1513+
wbRule.RedirectReplaceKey = v
1514+
}
1515+
1516+
if v, ok := dMap["redirect_replace_key_prefix"].(string); ok && v != "" {
1517+
wbRule.RedirectReplaceKeyPrefix = v
1518+
}
1519+
1520+
wbRules = append(wbRules, wbRule)
1521+
}
1522+
}
1523+
1524+
websiteRoutingRules.Rules = wbRules
15011525
}
1502-
1503-
if v, ok := dMap["condition_prefix"].(string); ok && v != "" {
1504-
wbRule.ConditionPrefix = v
1505-
}
1506-
1507-
if v, ok := dMap["redirect_protocol"].(string); ok && v != "" {
1508-
wbRule.RedirectProtocol = v
1509-
}
1510-
1511-
if v, ok := dMap["redirect_replace_key"].(string); ok && v != "" {
1512-
wbRule.RedirectReplaceKey = v
1513-
}
1514-
1515-
if v, ok := dMap["redirect_replace_key_prefix"].(string); ok && v != "" {
1516-
wbRule.RedirectReplaceKeyPrefix = v
1517-
}
1518-
1519-
wbRules = append(wbRules, wbRule)
15201526
}
1521-
1522-
websiteRoutingRules.Rules = wbRules
15231527
}
1524-
}
15251528

1526-
websiteConfiguration.RoutingRules = &websiteRoutingRules
1529+
websiteConfiguration.RoutingRules = &websiteRoutingRules
1530+
}
15271531
}
15281532

15291533
request := websiteConfiguration

0 commit comments

Comments
 (0)