Skip to content

Commit af2c9a4

Browse files
committed
add
1 parent 8f9eefa commit af2c9a4

File tree

4 files changed

+46
-12
lines changed

4 files changed

+46
-12
lines changed

tencentcloud/internal/helper/helper.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,3 +297,45 @@ func CheckElementsExist(slice1 []string, slice2 []string) (bool, []string) {
297297
}
298298
return exist, diff
299299
}
300+
301+
func StringSlicesEqual(slice1, slice2 []string) bool {
302+
if len(slice1) != len(slice2) {
303+
return false
304+
}
305+
306+
count := make(map[string]int)
307+
308+
for _, value := range slice1 {
309+
count[value]++
310+
}
311+
312+
for _, value := range slice2 {
313+
count[value]--
314+
if count[value] < 0 {
315+
return false
316+
}
317+
}
318+
319+
return true
320+
}
321+
322+
func StringPtrSlicesEqual(slice1, slice2 []*string) bool {
323+
if len(slice1) != len(slice2) {
324+
return false
325+
}
326+
327+
count := make(map[string]int)
328+
329+
for _, value := range slice1 {
330+
count[*value]++
331+
}
332+
333+
for _, value := range slice2 {
334+
count[*value]--
335+
if count[*value] < 0 {
336+
return false
337+
}
338+
}
339+
340+
return true
341+
}

tencentcloud/services/clb/resource_tc_clb_listener_rule.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func ResourceTencentCloudClbListenerRule() *schema.Resource {
4747
Description: "Domain name of the listener rule. Single domain rules are passed to `domain`, and multi domain rules are passed to `domains`.",
4848
},
4949
"domains": {
50-
Type: schema.TypeList,
50+
Type: schema.TypeSet,
5151
Optional: true,
5252
Computed: true,
5353
ForceNew: true,
@@ -272,7 +272,7 @@ func resourceTencentCloudClbListenerRuleCreate(d *schema.ResourceData, meta inte
272272
}
273273

274274
if v, ok := d.GetOk("domains"); ok {
275-
tmpDomains := v.([]interface{})
275+
tmpDomains := v.(*schema.Set).List()
276276
domains = make([]*string, 0, len(tmpDomains))
277277
for _, value := range tmpDomains {
278278
tmpDomain := value.(string)

tencentcloud/services/clb/service_tencentcloud_clb.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -375,15 +375,7 @@ func (me *ClbService) DescribeRuleByPara(ctx context.Context, clbId string, list
375375
findFlag = true
376376
break
377377
} else if len(domains) > 0 {
378-
tmpRef := true
379-
for i := range domains {
380-
if *domains[i] != *rule.Domains[i] {
381-
tmpRef = false
382-
break
383-
}
384-
}
385-
386-
if tmpRef {
378+
if helper.StringPtrSlicesEqual(domains, rule.Domains) {
387379
ruleOutput = *rule
388380
findFlag = true
389381
break

website/docs/r/clb_listener_rule.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ The following arguments are supported:
7070
* `certificate_id` - (Optional, String) ID of the server certificate. NOTES: Only supports listeners of HTTPS protocol.
7171
* `certificate_ssl_mode` - (Optional, String, ForceNew) Type of certificate. Valid values: `UNIDIRECTIONAL`, `MUTUAL`. NOTES: Only supports listeners of HTTPS protocol.
7272
* `domain` - (Optional, String) Domain name of the listener rule. Single domain rules are passed to `domain`, and multi domain rules are passed to `domains`.
73-
* `domains` - (Optional, List: [`String`], ForceNew) Domain name list of the listener rule. Single domain rules are passed to `domain`, and multi domain rules are passed to `domains`.
73+
* `domains` - (Optional, Set: [`String`], ForceNew) Domain name list of the listener rule. Single domain rules are passed to `domain`, and multi domain rules are passed to `domains`.
7474
* `forward_type` - (Optional, String) Forwarding protocol between the CLB instance and real server. Valid values: `HTTP`, `HTTPS`, `GRPC`, `GRPCS`, `TRPC`. The default is `HTTP`.
7575
* `health_check_health_num` - (Optional, Int) Health threshold of health check, and the default is `3`. If a success result is returned for the health check 3 consecutive times, indicates that the forwarding is normal. The value range is [2-10]. NOTES: TCP/UDP/TCP_SSL listener allows direct configuration, HTTP/HTTPS listener needs to be configured in `tencentcloud_clb_listener_rule`.
7676
* `health_check_http_code` - (Optional, Int) HTTP Status Code. The default is 31. Valid value ranges: [1~31]. `1 means the return value '1xx' is health. `2` means the return value '2xx' is health. `4` means the return value '3xx' is health. `8` means the return value '4xx' is health. 16 means the return value '5xx' is health. If you want multiple return codes to indicate health, need to add the corresponding values. NOTES: The 'HTTP' health check of the 'TCP' listener only supports specifying one health check status code. NOTES: Only supports listeners of 'HTTP' and 'HTTPS' protocol.

0 commit comments

Comments
 (0)