Skip to content

Commit f88aaed

Browse files
committed
Merge remote-tracking branch 'upstream/master' into feature/tke_global_config
2 parents ddfdbdd + 212cc6f commit f88aaed

File tree

28 files changed

+1287
-521
lines changed

28 files changed

+1287
-521
lines changed

CHANGELOG.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
## 1.55.0 (Unreleased)
1+
## 1.55.1 (Unreleased)
2+
## 1.55.0 (March 26, 2021)
23

34
FEATURES:
45

@@ -7,6 +8,13 @@ FEATURES:
78
* **New Data Source**: `tencentcloud_ssm_secrets`
89
* **New Data Source**: `tencentcloud_ssm_secret_versions`
910

11+
ENHANCEMENTS:
12+
13+
* Resource: `tencentcloud_ssl_certificate` refactor logic with api3.0 .
14+
* Data Source: `tencentcloud_ssl_certificates` refactor logic with api3.0 .
15+
* Resource `tencentcloud_kubernetes_cluster` add `disaster_recover_group_ids` to set disaster recover group ID.
16+
* Resource `tencentcloud_kubernetes_scale_worker` add `disaster_recover_group_ids` to set disaster recover group ID.
17+
1018
## 1.54.1 (March 24, 2021)
1119

1220
ENHANCEMENTS:
@@ -24,10 +32,10 @@ FEATURES:
2432

2533
ENHANCEMENTS:
2634

27-
* Resource `tencentcloud_kubernetes_cluster_attachment` add `unschedulable` to sets whether the joining node participates in the schedule.
28-
* Resource `tencentcloud_kubernetes_cluster` add `unschedulable` to sets whether the joining node participates in the schedule.
29-
* Resource `tencentcloud_kubernetes_node_pool` add `unschedulable` to sets whether the joining node participates in the schedule.
30-
* Resource `tencentcloud_kubernetes_scale_worker` add `unschedulable` to sets whether the joining node participates in the schedule.
35+
* Resource `tencentcloud_kubernetes_cluster_attachment` add `unschedulable` to set whether the joining node participates in the schedule.
36+
* Resource `tencentcloud_kubernetes_cluster` add `unschedulable` to set whether the joining node participates in the schedule.
37+
* Resource `tencentcloud_kubernetes_node_pool` add `unschedulable` to set whether the joining node participates in the schedule.
38+
* Resource `tencentcloud_kubernetes_scale_worker` add `unschedulable` to set whether the joining node participates in the schedule.
3139

3240
## 1.53.9 (March 19, 2021)
3341

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ require (
1515
github.com/mattn/go-colorable v0.1.6 // indirect
1616
github.com/mitchellh/go-homedir v1.1.0
1717
github.com/pkg/errors v0.9.1
18-
github.com/tencentcloud/tencentcloud-sdk-go v1.0.119
18+
github.com/tencentcloud/tencentcloud-sdk-go v1.0.123
1919
github.com/yangwenmai/ratelimit v0.0.0-20180104140304-44221c2292e1
2020
github.com/zclconf/go-cty v1.4.2 // indirect
2121
golang.org/x/sys v0.0.0-20200523222454-059865788121 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,8 @@ github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s
441441
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
442442
github.com/tdakkota/asciicheck v0.0.0-20200416190851-d7f85be797a2 h1:Xr9gkxfOP0KQWXKNqmwe8vEeSUiUj4Rlee9CMVX2ZUQ=
443443
github.com/tdakkota/asciicheck v0.0.0-20200416190851-d7f85be797a2/go.mod h1:yHp0ai0Z9gUljN3o0xMhYJnH/IcvkdTBOX2fmJ93JEM=
444-
github.com/tencentcloud/tencentcloud-sdk-go v1.0.119 h1:wjidEbe8rWoQNfUEzILykgi4SO1LYjC4tNRY7RN8chI=
445-
github.com/tencentcloud/tencentcloud-sdk-go v1.0.119/go.mod h1:asUz5BPXxgoPGaRgZaVm1iGcUAuHyYUo1nXqKa83cvI=
444+
github.com/tencentcloud/tencentcloud-sdk-go v1.0.123 h1:6yOMrmTuKtW1Y8VtWgN5Jt3jUcWnWtRX0gZfD1LxRcc=
445+
github.com/tencentcloud/tencentcloud-sdk-go v1.0.123/go.mod h1:asUz5BPXxgoPGaRgZaVm1iGcUAuHyYUo1nXqKa83cvI=
446446
github.com/tetafro/godot v0.3.7 h1:+mecr7RKrUKB5UQ1gwqEMn13sDKTyDR8KNIquB9mm+8=
447447
github.com/tetafro/godot v0.3.7/go.mod h1:/7NLHhv08H1+8DNj0MElpAACw1ajsCuf3TKNQxA5S+0=
448448
github.com/timakin/bodyclose v0.0.0-20190930140734-f7f2e9bca95e h1:RumXZ56IrCj4CL+g1b9OL/oH0QnsF976bC8xQFYUD5Q=

tencentcloud/connectivity/transport.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"time"
1111
)
1212

13-
const ReqClient = "Terraform-v1.54.1"
13+
const ReqClient = "Terraform-v1.55.0"
1414

1515
type LogRoundTripper struct {
1616
}

tencentcloud/data_source_tc_ssl_certificates.go

Lines changed: 127 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ import (
1717
"log"
1818
"strconv"
1919

20+
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
2021
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
22+
ssl "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ssl/v20191205"
2123
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper"
2224
)
2325

@@ -144,46 +146,42 @@ func dataSourceTencentCloudSslCertificatesRead(d *schema.ResourceData, m interfa
144146
id = helper.String(raw.(string))
145147
}
146148

147-
service := SslService{client: m.(*TencentCloudClient).apiV3Conn}
148-
149-
respCertificates, err := service.DescribeCertificates(ctx, id, name, certType)
149+
sslService := SSLService{client: m.(*TencentCloudClient).apiV3Conn}
150+
certificateList, err := GetCertificateList(ctx, sslService, id, name, certType)
150151
if err != nil {
151152
return err
152153
}
153154

154-
certificates := make([]map[string]interface{}, 0, len(respCertificates))
155-
ids := make([]string, 0, len(respCertificates))
156-
157-
for _, certificate := range respCertificates {
155+
certificates := make([]map[string]interface{}, 0, len(certificateList))
156+
ids := make([]string, 0, len(certificateList))
157+
for _, certificate := range certificateList {
158158
if nilNames := CheckNil(certificate, map[string]string{
159-
"Id": "id",
160-
"Alias": "name",
161-
"CertType": "type",
162-
"ProjectId": "project id",
163-
"Cert": "cert",
164-
"ProductZhName": "product zh name",
165-
"Domain": "domain",
166-
"Status": "status",
167-
"CertBeginTime": "begin time",
168-
"CertEndTime": "end time",
169-
"InsertTime": "create time",
159+
"CertificateId": "id",
160+
"Alias": "name",
161+
"CertificateType": "type",
162+
"ProjectId": "project id",
163+
"ProductZhName": "product zh name",
164+
"Domain": "domain",
165+
"Status": "status",
166+
"CertBeginTime": "begin time",
167+
"CertEndTime": "end time",
168+
"InsertTime": "create time",
170169
}); len(nilNames) > 0 {
171170
return fmt.Errorf("certificate %v are nil", nilNames)
172171
}
173172

174-
ids = append(ids, *certificate.Id)
173+
ids = append(ids, *certificate.CertificateId)
175174

176175
projectId, err := strconv.Atoi(*certificate.ProjectId)
177176
if err != nil {
178177
return err
179178
}
180179

181180
m := map[string]interface{}{
182-
"id": *certificate.Id,
181+
"id": *certificate.CertificateId,
183182
"name": *certificate.Alias,
184-
"type": *certificate.CertType,
183+
"type": *certificate.CertificateType,
185184
"project_id": projectId,
186-
"cert": *certificate.Cert,
187185
"product_zh_name": *certificate.ProductZhName,
188186
"domain": *certificate.Domain,
189187
"status": *certificate.Status,
@@ -200,6 +198,26 @@ func dataSourceTencentCloudSslCertificatesRead(d *schema.ResourceData, m interfa
200198
m["subject_names"] = subjectAltNames
201199
}
202200

201+
describeRequest := ssl.NewDescribeCertificateDetailRequest()
202+
describeRequest.CertificateId = certificate.CertificateId
203+
var outErr, inErr error
204+
var describeResponse *ssl.DescribeCertificateDetailResponse
205+
outErr = resource.Retry(readRetryTimeout, func() *resource.RetryError {
206+
describeResponse, inErr = sslService.DescribeCertificateDetail(ctx, describeRequest)
207+
if inErr != nil {
208+
return retryError(inErr)
209+
}
210+
return nil
211+
})
212+
if outErr != nil {
213+
log.Printf("[CRITAL]%s read certificate failed, reason: %v", logId, outErr)
214+
return outErr
215+
}
216+
217+
if describeResponse != nil && describeResponse.Response != nil {
218+
m["cert"] = *describeResponse.Response.CertificatePublicKey
219+
}
220+
203221
certificates = append(certificates, m)
204222
}
205223

@@ -216,3 +234,90 @@ func dataSourceTencentCloudSslCertificatesRead(d *schema.ResourceData, m interfa
216234

217235
return nil
218236
}
237+
238+
func GetCertificateList(ctx context.Context, sslService SSLService, id, name, certType *string) (certificateList []*ssl.Certificates, errRet error) {
239+
logId := getLogId(contextNil)
240+
241+
var (
242+
outErr, inErr error
243+
certificatesById, certificatesByName []*ssl.Certificates
244+
)
245+
246+
if id == nil && name == nil {
247+
describeRequest := ssl.NewDescribeCertificatesRequest()
248+
describeRequest.CertificateType = certType
249+
outErr = resource.Retry(readRetryTimeout, func() *resource.RetryError {
250+
certificateList, inErr = sslService.DescribeCertificates(ctx, describeRequest)
251+
if inErr != nil {
252+
return retryError(inErr)
253+
}
254+
return nil
255+
})
256+
if outErr != nil {
257+
log.Printf("[CRITAL]%s read certificates failed, reason: %v", logId, outErr)
258+
errRet = outErr
259+
return
260+
}
261+
return
262+
}
263+
264+
if id != nil {
265+
describeRequest := ssl.NewDescribeCertificatesRequest()
266+
describeRequest.CertificateType = certType
267+
describeRequest.SearchKey = id
268+
outErr = resource.Retry(readRetryTimeout, func() *resource.RetryError {
269+
certificatesById, inErr = sslService.DescribeCertificates(ctx, describeRequest)
270+
if inErr != nil {
271+
return retryError(inErr)
272+
}
273+
return nil
274+
})
275+
if outErr != nil {
276+
log.Printf("[CRITAL]%s read certificates failed, reason: %v", logId, outErr)
277+
errRet = outErr
278+
return
279+
}
280+
}
281+
if name != nil {
282+
describeRequest := ssl.NewDescribeCertificatesRequest()
283+
describeRequest.CertificateType = certType
284+
describeRequest.SearchKey = name
285+
outErr = resource.Retry(readRetryTimeout, func() *resource.RetryError {
286+
certificatesByName, inErr = sslService.DescribeCertificates(ctx, describeRequest)
287+
if inErr != nil {
288+
return retryError(inErr)
289+
}
290+
return nil
291+
})
292+
if outErr != nil {
293+
log.Printf("[CRITAL]%s read certificates failed, reason: %v", logId, outErr)
294+
errRet = outErr
295+
return
296+
}
297+
}
298+
299+
certificateList = GetCommonCertificates(certificatesById, certificatesByName)
300+
return
301+
}
302+
303+
func GetCommonCertificates(certificatesById, certificatesByName []*ssl.Certificates) (result []*ssl.Certificates) {
304+
if len(certificatesById) == 0 {
305+
return certificatesByName
306+
} else if len(certificatesByName) == 0 {
307+
return certificatesById
308+
}
309+
certificateMap := make(map[string]bool)
310+
for _, certificate := range certificatesById {
311+
if _, ok := certificateMap[*certificate.CertificateId]; ok {
312+
continue
313+
}
314+
certificateMap[*certificate.CertificateId] = true
315+
}
316+
317+
for _, certificate := range certificatesByName {
318+
if _, ok := certificateMap[*certificate.CertificateId]; ok {
319+
result = append(result, certificate)
320+
}
321+
}
322+
return
323+
}

tencentcloud/resource_tc_kubernetes_cluster.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,14 @@ func TkeCvmCreateInfo() map[string]*schema.Schema {
469469
"Windows example: The length of the name character is [2, 15], letters (capitalization is not restricted), numbers and dashes (-) are allowed, dots (.) are not supported, and not all numbers are allowed. " +
470470
"Examples of other types (Linux, etc.): The character length is [2, 60], and multiple dots are allowed. There is a segment between the dots. Each segment allows letters (with no limitation on capitalization), numbers and dashes (-).",
471471
},
472+
"disaster_recover_group_ids": {
473+
Type: schema.TypeList,
474+
ForceNew: true,
475+
Optional: true,
476+
MaxItems: 1,
477+
Elem: &schema.Schema{Type: schema.TypeString},
478+
Description: "Disaster recover groups to which a CVM instance belongs. Only support maximum 1.",
479+
},
472480
}
473481
}
474482

@@ -1105,6 +1113,15 @@ func tkeGetCvmRunInstancesPara(dMap map[string]interface{}, meta interface{},
11051113
}
11061114
}
11071115

1116+
if v, ok := dMap["disaster_recover_group_ids"]; ok {
1117+
disasterGroups := v.([]interface{})
1118+
request.DisasterRecoverGroupIds = make([]*string, 0, len(disasterGroups))
1119+
for i := range disasterGroups {
1120+
disasterGroup := disasterGroups[i].(string)
1121+
request.DisasterRecoverGroupIds = append(request.DisasterRecoverGroupIds, &disasterGroup)
1122+
}
1123+
}
1124+
11081125
if v, ok := dMap["enhanced_security_service"]; ok {
11091126

11101127
if request.EnhancedService == nil {

0 commit comments

Comments
 (0)