Skip to content

Commit 46eb60d

Browse files
authored
feat(CDN): source support third bucket (#7414)
* feat(CDN):support config third bucket source * feat(CDN):support config third bucket * feat(CDN):support config third bucket * feat(CDN):support config third bucket * feat(CDN):support config third bucket
1 parent fe0ebbe commit 46eb60d

File tree

1 file changed

+66
-8
lines changed

1 file changed

+66
-8
lines changed

huaweicloud/services/cdn/resource_huaweicloud_cdn_domain.go

Lines changed: 66 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,7 @@ func ResourceCdnDomain() *schema.Resource {
963963
Type: schema.TypeString,
964964
Required: true,
965965
ValidateFunc: validation.StringInSlice([]string{
966-
"ipaddr", "domain", "obs_bucket",
966+
"ipaddr", "domain", "obs_bucket", "third_bucket",
967967
}, true),
968968
},
969969
"active": {
@@ -1001,6 +1001,50 @@ func ResourceCdnDomain() *schema.Resource {
10011001
Optional: true,
10021002
Computed: true,
10031003
},
1004+
"bucket_access_key": {
1005+
Type: schema.TypeString,
1006+
Optional: true,
1007+
Computed: true,
1008+
Description: utils.SchemaDesc(
1009+
"Third-party object storage access key.",
1010+
utils.SchemaDescInput{
1011+
Internal: true,
1012+
},
1013+
),
1014+
},
1015+
"bucket_secret_key": {
1016+
Type: schema.TypeString,
1017+
Optional: true,
1018+
Computed: true,
1019+
Description: utils.SchemaDesc(
1020+
"Third-party object storage secret key.",
1021+
utils.SchemaDescInput{
1022+
Internal: true,
1023+
},
1024+
),
1025+
},
1026+
"bucket_region": {
1027+
Type: schema.TypeString,
1028+
Optional: true,
1029+
Computed: true,
1030+
Description: utils.SchemaDesc(
1031+
"Third-party object storage bucket region.",
1032+
utils.SchemaDescInput{
1033+
Internal: true,
1034+
},
1035+
),
1036+
},
1037+
"bucket_name": {
1038+
Type: schema.TypeString,
1039+
Optional: true,
1040+
Computed: true,
1041+
Description: utils.SchemaDesc(
1042+
"Third-party object storage bucket name.",
1043+
utils.SchemaDescInput{
1044+
Internal: true,
1045+
},
1046+
),
1047+
},
10041048
},
10051049
},
10061050
},
@@ -1222,11 +1266,17 @@ func buildCreateCdnDomainSourcesBodyParams(d *schema.ResourceData) []interface{}
12221266

12231267
for _, v := range sources {
12241268
sourceMap := v.(map[string]interface{})
1225-
rst = append(rst, map[string]interface{}{
1226-
"ip_or_domain": sourceMap["origin"],
1227-
"origin_type": sourceMap["origin_type"],
1228-
"active_standby": sourceMap["active"],
1229-
})
1269+
rst = append(rst, utils.RemoveNil(map[string]interface{}{
1270+
"ip_or_domain": sourceMap["origin"],
1271+
"origin_type": sourceMap["origin_type"],
1272+
"active_standby": sourceMap["active"],
1273+
"obs_bucket_type": sourceMap["obs_bucket_type"],
1274+
"bucket_access_key": sourceMap["bucket_access_key"],
1275+
"bucket_secret_key": sourceMap["bucket_secret_key"],
1276+
"bucket_region": sourceMap["bucket_region"],
1277+
"bucket_name": sourceMap["bucket_name"],
1278+
"host_name": sourceMap["retrieval_host"],
1279+
}))
12301280
}
12311281
return rst
12321282
}
@@ -1444,6 +1494,10 @@ func flattenSourcesAttributes(configResp interface{}) []interface{} {
14441494
"retrieval_host": sourceMap["host_name"],
14451495
"weight": sourceMap["weight"],
14461496
"obs_bucket_type": sourceMap["obs_bucket_type"],
1497+
"bucket_access_key": sourceMap["bucket_access_key"],
1498+
"bucket_secret_key": sourceMap["bucket_secret_key"],
1499+
"bucket_region": sourceMap["bucket_region"],
1500+
"bucket_name": sourceMap["bucket_name"],
14471501
})
14481502
}
14491503
return rst
@@ -2205,7 +2259,7 @@ func buildCdnDomainSourcesOpts(rawSources []interface{}) []interface{} {
22052259
rst := make([]interface{}, 0, len(rawSources))
22062260
for _, v := range rawSources {
22072261
rawMap := v.(map[string]interface{})
2208-
rst = append(rst, map[string]interface{}{
2262+
rst = append(rst, utils.RemoveNil(map[string]interface{}{
22092263
"origin_addr": rawMap["origin"],
22102264
"origin_type": rawMap["origin_type"],
22112265
"priority": buildCdnDomainSourcesPriorityOpts(rawMap["active"].(int)),
@@ -2215,7 +2269,11 @@ func buildCdnDomainSourcesOpts(rawSources []interface{}) []interface{} {
22152269
"host_name": utils.ValueIgnoreEmpty(rawMap["retrieval_host"]),
22162270
"weight": utils.ValueIgnoreEmpty(rawMap["weight"]),
22172271
"obs_bucket_type": utils.ValueIgnoreEmpty(rawMap["obs_bucket_type"]),
2218-
})
2272+
"bucket_access_key": utils.ValueIgnoreEmpty(rawMap["bucket_access_key"]),
2273+
"bucket_secret_key": utils.ValueIgnoreEmpty(rawMap["bucket_secret_key"]),
2274+
"bucket_region": utils.ValueIgnoreEmpty(rawMap["bucket_region"]),
2275+
"bucket_name": utils.ValueIgnoreEmpty(rawMap["bucket_name"]),
2276+
}))
22192277
}
22202278
return rst
22212279
}

0 commit comments

Comments
 (0)