Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
SevenEarth committed Dec 19, 2024
1 parent 8f9eefa commit af2c9a4
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 12 deletions.
42 changes: 42 additions & 0 deletions tencentcloud/internal/helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,3 +297,45 @@ func CheckElementsExist(slice1 []string, slice2 []string) (bool, []string) {
}
return exist, diff
}

func StringSlicesEqual(slice1, slice2 []string) bool {
if len(slice1) != len(slice2) {
return false
}

count := make(map[string]int)

for _, value := range slice1 {
count[value]++
}

for _, value := range slice2 {
count[value]--
if count[value] < 0 {
return false
}
}

return true
}

func StringPtrSlicesEqual(slice1, slice2 []*string) bool {
if len(slice1) != len(slice2) {
return false
}

count := make(map[string]int)

for _, value := range slice1 {
count[*value]++
}

for _, value := range slice2 {
count[*value]--
if count[*value] < 0 {
return false
}
}

return true
}
4 changes: 2 additions & 2 deletions tencentcloud/services/clb/resource_tc_clb_listener_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func ResourceTencentCloudClbListenerRule() *schema.Resource {
Description: "Domain name of the listener rule. Single domain rules are passed to `domain`, and multi domain rules are passed to `domains`.",
},
"domains": {
Type: schema.TypeList,
Type: schema.TypeSet,
Optional: true,
Computed: true,
ForceNew: true,
Expand Down Expand Up @@ -272,7 +272,7 @@ func resourceTencentCloudClbListenerRuleCreate(d *schema.ResourceData, meta inte
}

if v, ok := d.GetOk("domains"); ok {
tmpDomains := v.([]interface{})
tmpDomains := v.(*schema.Set).List()
domains = make([]*string, 0, len(tmpDomains))
for _, value := range tmpDomains {
tmpDomain := value.(string)
Expand Down
10 changes: 1 addition & 9 deletions tencentcloud/services/clb/service_tencentcloud_clb.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,15 +375,7 @@ func (me *ClbService) DescribeRuleByPara(ctx context.Context, clbId string, list
findFlag = true
break
} else if len(domains) > 0 {
tmpRef := true
for i := range domains {
if *domains[i] != *rule.Domains[i] {
tmpRef = false
break
}
}

if tmpRef {
if helper.StringPtrSlicesEqual(domains, rule.Domains) {
ruleOutput = *rule
findFlag = true
break
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/clb_listener_rule.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ The following arguments are supported:
* `certificate_id` - (Optional, String) ID of the server certificate. NOTES: Only supports listeners of HTTPS protocol.
* `certificate_ssl_mode` - (Optional, String, ForceNew) Type of certificate. Valid values: `UNIDIRECTIONAL`, `MUTUAL`. NOTES: Only supports listeners of HTTPS protocol.
* `domain` - (Optional, String) Domain name of the listener rule. Single domain rules are passed to `domain`, and multi domain rules are passed to `domains`.
* `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`.
* `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`.
* `forward_type` - (Optional, String) Forwarding protocol between the CLB instance and real server. Valid values: `HTTP`, `HTTPS`, `GRPC`, `GRPCS`, `TRPC`. The default is `HTTP`.
* `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`.
* `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.
Expand Down

0 comments on commit af2c9a4

Please sign in to comment.