@@ -1489,41 +1489,45 @@ func resourceTencentCloudCosBucketWebsiteUpdate(ctx context.Context, meta interf
1489
1489
1490
1490
if v , ok := w ["routing_rules" ]; ok {
1491
1491
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
1501
1525
}
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 )
1520
1526
}
1521
-
1522
- websiteRoutingRules .Rules = wbRules
1523
1527
}
1524
- }
1525
1528
1526
- websiteConfiguration .RoutingRules = & websiteRoutingRules
1529
+ websiteConfiguration .RoutingRules = & websiteRoutingRules
1530
+ }
1527
1531
}
1528
1532
1529
1533
request := websiteConfiguration
0 commit comments