Skip to content

fix(privatedns): [124194904] update resource retry code logic #3372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Code generated by iacg; DO NOT EDIT.
package privatedns

import (
Expand Down Expand Up @@ -109,10 +108,11 @@ func dataSourceTencentCloudPrivateDnsEndPointsRead(d *schema.ResourceData, meta
defer tccommon.LogElapsed("data_source.tencentcloud_private_dns_end_points.read")()
defer tccommon.InconsistentCheck(d, meta)()

logId := tccommon.GetLogId(nil)
ctx := tccommon.NewResourceLifeCycleHandleFuncContext(context.Background(), logId, d, meta)

service := PrivatednsService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()}
var (
logId = tccommon.GetLogId(nil)
ctx = tccommon.NewResourceLifeCycleHandleFuncContext(context.Background(), logId, d, meta)
service = PrivatednsService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()}
)

paramMap := make(map[string]interface{})
if v, ok := d.GetOk("filters"); ok {
Expand All @@ -124,27 +124,32 @@ func dataSourceTencentCloudPrivateDnsEndPointsRead(d *schema.ResourceData, meta
if v, ok := filtersMap["name"]; ok {
filter.Name = helper.String(v.(string))
}

if v, ok := filtersMap["values"]; ok {
valuesSet := v.(*schema.Set).List()
for i := range valuesSet {
values := valuesSet[i].(string)
filter.Values = append(filter.Values, helper.String(values))
}
}

tmpSet = append(tmpSet, &filter)
}

paramMap["Filters"] = tmpSet
}

var respData []*privatednsv20201028.EndPointInfo
err := resource.Retry(tccommon.ReadRetryTimeout, func() *resource.RetryError {
result, e := service.DescribePrivateDnsEndPointsByFilter(ctx, paramMap)
if e != nil {
return tccommon.RetryError(e)
return tccommon.RetryError(e, PRIVATEDNS_CUSTOM_RETRY_SDK_ERROR...)
}

respData = result
return nil
})

if err != nil {
return err
}
Expand All @@ -154,9 +159,9 @@ func dataSourceTencentCloudPrivateDnsEndPointsRead(d *schema.ResourceData, meta
if respData != nil {
for _, endPointSet := range respData {
endPointSetMap := map[string]interface{}{}

if endPointSet.EndPointId != nil {
endPointSetMap["end_point_id"] = endPointSet.EndPointId
ids = append(ids, *endPointSet.EndPointId)
}

if endPointSet.EndPointName != nil {
Expand All @@ -179,7 +184,6 @@ func dataSourceTencentCloudPrivateDnsEndPointsRead(d *schema.ResourceData, meta
if endPointSet.Tags != nil {
for _, tags := range endPointSet.Tags {
tagsMap := map[string]interface{}{}

if tags.TagKey != nil {
tagsMap["tag_key"] = tags.TagKey
}
Expand All @@ -193,14 +197,14 @@ func dataSourceTencentCloudPrivateDnsEndPointsRead(d *schema.ResourceData, meta

endPointSetMap["tags"] = tagsList
}

endPointSetList = append(endPointSetList, endPointSetMap)
}

_ = d.Set("end_point_set", endPointSetList)
}

d.SetId(helper.DataResourceIdsHash(ids))

output, ok := d.GetOk("result_output_file")
if ok && output.(string) != "" {
if e := tccommon.WriteToFile(output.(string), endPointSetList); e != nil {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Use this data source to query detailed information of private dns dns end points
Use this data source to query detailed information of Private Dns end points

Example Usage

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Code generated by iacg; DO NOT EDIT.
package privatedns

import (
Expand Down Expand Up @@ -153,10 +152,11 @@ func dataSourceTencentCloudPrivateDnsForwardRulesRead(d *schema.ResourceData, me
defer tccommon.LogElapsed("data_source.tencentcloud_private_dns_forward_rules.read")()
defer tccommon.InconsistentCheck(d, meta)()

logId := tccommon.GetLogId(nil)
ctx := tccommon.NewResourceLifeCycleHandleFuncContext(context.Background(), logId, d, meta)

service := PrivatednsService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()}
var (
logId = tccommon.GetLogId(nil)
ctx = tccommon.NewResourceLifeCycleHandleFuncContext(context.Background(), logId, d, meta)
service = PrivatednsService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()}
)

paramMap := make(map[string]interface{})
if v, ok := d.GetOk("filters"); ok {
Expand All @@ -168,27 +168,32 @@ func dataSourceTencentCloudPrivateDnsForwardRulesRead(d *schema.ResourceData, me
if v, ok := filtersMap["name"]; ok {
filter.Name = helper.String(v.(string))
}

if v, ok := filtersMap["values"]; ok {
valuesSet := v.(*schema.Set).List()
for i := range valuesSet {
values := valuesSet[i].(string)
filter.Values = append(filter.Values, helper.String(values))
}
}

tmpSet = append(tmpSet, &filter)
}

paramMap["Filters"] = tmpSet
}

var respData []*privatednsv20201028.ForwardRule
err := resource.Retry(tccommon.ReadRetryTimeout, func() *resource.RetryError {
result, e := service.DescribePrivateDnsForwardRulesByFilter(ctx, paramMap)
if e != nil {
return tccommon.RetryError(e)
return tccommon.RetryError(e, PRIVATEDNS_CUSTOM_RETRY_SDK_ERROR...)
}

respData = result
return nil
})

if err != nil {
return err
}
Expand All @@ -198,8 +203,6 @@ func dataSourceTencentCloudPrivateDnsForwardRulesRead(d *schema.ResourceData, me
if respData != nil {
for _, forwardRuleSet := range respData {
forwardRuleSetMap := map[string]interface{}{}

var ruleId string
if forwardRuleSet.Domain != nil {
forwardRuleSetMap["domain"] = forwardRuleSet.Domain
}
Expand All @@ -210,6 +213,7 @@ func dataSourceTencentCloudPrivateDnsForwardRulesRead(d *schema.ResourceData, me

if forwardRuleSet.RuleId != nil {
forwardRuleSetMap["rule_id"] = forwardRuleSet.RuleId
ids = append(ids, *forwardRuleSet.RuleId)
}

if forwardRuleSet.RuleType != nil {
Expand Down Expand Up @@ -254,6 +258,7 @@ func dataSourceTencentCloudPrivateDnsForwardRulesRead(d *schema.ResourceData, me

forwardRuleSetMap["vpc_set"] = vpcSetList
}

if forwardRuleSet.ZoneId != nil {
forwardRuleSetMap["zone_id"] = forwardRuleSet.ZoneId
}
Expand All @@ -262,7 +267,6 @@ func dataSourceTencentCloudPrivateDnsForwardRulesRead(d *schema.ResourceData, me
if forwardRuleSet.Tags != nil {
for _, tags := range forwardRuleSet.Tags {
tagsMap := map[string]interface{}{}

if tags.TagKey != nil {
tagsMap["tag_key"] = tags.TagKey
}
Expand All @@ -276,15 +280,14 @@ func dataSourceTencentCloudPrivateDnsForwardRulesRead(d *schema.ResourceData, me

forwardRuleSetMap["tags"] = tagsList
}
ids = append(ids, ruleId)

forwardRuleSetList = append(forwardRuleSetList, forwardRuleSetMap)
}

_ = d.Set("forward_rule_set", forwardRuleSetList)
}

d.SetId(helper.DataResourceIdsHash(ids))

output, ok := d.GetOk("result_output_file")
if ok && output.(string) != "" {
if e := tccommon.WriteToFile(output.(string), forwardRuleSetList); e != nil {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Use this data source to query detailed information of private dns forward rules
Use this data source to query detailed information of Private Dns forward rules

Example Usage

Expand All @@ -14,12 +14,7 @@ Query all private dns forward rules by filters
data "tencentcloud_private_dns_forward_rules" "example" {
filters {
name = "RuleId"
values = ["eid-e9d5880672"]
}

filters {
name = "RuleName"
values = ["tf-example"]
values = ["fid-2ece6ca305"]
}

filters {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package privatedns
import (
"context"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
privatedns "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/privatedns/v20201028"

Expand Down Expand Up @@ -243,16 +242,7 @@ func dataSourceTencentCloudPrivateDnsPrivateZoneListRead(d *schema.ResourceData,
paramMap["Filters"] = tmpSet
}

err := resource.Retry(tccommon.ReadRetryTimeout, func() *resource.RetryError {
result, e := service.DescribePrivatednsPrivateZoneListByFilter(ctx, paramMap)
if e != nil {
return tccommon.RetryError(e)
}

privateZoneSet = result
return nil
})

privateZoneSet, err := service.DescribePrivatednsPrivateZoneListByFilter(ctx, paramMap)
if err != nil {
return err
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Use this data source to query detailed information of privatedns private_zone_list
Use this data source to query detailed information of Private Dns private zone list

Example Usage

Get All PrivateZones:
Query All private zones:

```hcl
data "tencentcloud_private_dns_private_zone_list" "example" {}
```

Get PrivateZone By ZoneId:
Query private zones by ZoneId:

```hcl
data "tencentcloud_private_dns_private_zone_list" "example" {
Expand All @@ -19,7 +19,7 @@ data "tencentcloud_private_dns_private_zone_list" "example" {
}
```

Get PrivateZone By Domain:
Query private zones by Domain:

```hcl
data "tencentcloud_private_dns_private_zone_list" "example" {
Expand All @@ -30,7 +30,7 @@ data "tencentcloud_private_dns_private_zone_list" "example" {
}
```

Get PrivateZone By Vpc:
Query private zones by Vpc:

```hcl
data "tencentcloud_private_dns_private_zone_list" "example" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
privatedns "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/privatedns/v20201028"

Expand Down Expand Up @@ -133,54 +132,43 @@ func dataSourceTencentCloudPrivateDnsRecordsRead(d *schema.ResourceData, meta in
defer tccommon.LogElapsed("data_source.tencentcloud_private_dns_records.read")()
defer tccommon.InconsistentCheck(d, meta)()

logId := tccommon.GetLogId(tccommon.ContextNil)

ctx := context.WithValue(context.TODO(), tccommon.LogIdKey, logId)
var (
logId = tccommon.GetLogId(tccommon.ContextNil)
ctx = context.WithValue(context.TODO(), tccommon.LogIdKey, logId)
service = PrivateDnsService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()}
)

zoneId := d.Get("zone_id").(string)
filterList := make([]*privatedns.Filter, 0)

if v, ok := d.GetOk("filters"); ok {
filters := v.([]interface{})

for _, item := range filters {
filter := privatedns.Filter{}
filterMap := item.(map[string]interface{})

if v, ok := filterMap["name"]; ok {
filter.Name = helper.String(v.(string))
}

if v, ok := filterMap["values"]; ok {
valuesSet := v.(*schema.Set).List()
filter.Values = helper.InterfacesStringsPoint(valuesSet)
}

filterList = append(filterList, &filter)
}
}

service := PrivateDnsService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()}

var recordSet []*privatedns.PrivateZoneRecord

err := resource.Retry(tccommon.ReadRetryTimeout, func() *resource.RetryError {
result, e := service.DescribePrivateDnsRecordByFilter(ctx, zoneId, filterList)
if e != nil {
return tccommon.RetryError(e)
}
recordSet = result
return nil
})
recordSet, err := service.DescribePrivateDnsRecordByFilter(ctx, zoneId, filterList)
if err != nil {
return err
}

ids := make([]string, 0, len(recordSet))
tmpList := make([]map[string]interface{}, 0, len(recordSet))

if recordSet != nil {
for _, privateZoneRecord := range recordSet {
privateZoneRecordMap := map[string]interface{}{}

if privateZoneRecord.RecordId != nil {
privateZoneRecordMap["record_id"] = privateZoneRecord.RecordId
}
Expand Down Expand Up @@ -247,5 +235,6 @@ func dataSourceTencentCloudPrivateDnsRecordsRead(d *schema.ResourceData, meta in
return e
}
}

return nil
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
Use this data source to query detailed information of private dns records
Use this data source to query detailed information of Private Dns records

Example Usage

```hcl
data "tencentcloud_private_dns_records" "private_dns_record" {
zone_id = "zone-xxxxxx"
data "tencentcloud_private_dns_records" "example" {
zone_id = "zone-kumt5wos"
}
```

Or

```hcl
data "tencentcloud_private_dns_records" "example" {
zone_id = "zone-kumt5wos"
filters {
name = "Value"
values = ["8.8.8.8"]
name = "RecordType"
values = ["A"]
}
}
```
```
Loading
Loading