Skip to content

Commit f623d5c

Browse files
gitmknanonymous
andauthored
Feat/pts support (#1383)
* feat: support project * feat: support alert_channel * feat: support scenario * feat: support pts_file * feat: support pts_job * feat: support cron job * feat: add unit * fix: update func name * feat: support scenario * feat: add changelog * fix: modify field properties * fix: update unit name * fix: modify unit Co-authored-by: anonymous <anonymous@mail.org>
1 parent 0d882a7 commit f623d5c

35 files changed

+14719
-16
lines changed

.changelog/1383.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
```release-note:new-resource
2+
tencentcloud_pts_project
3+
```
4+
5+
```release-note:new-resource
6+
tencentcloud_pts_alert_channel
7+
```
8+
9+
```release-note:new-resource
10+
tencentcloud_pts_scenario
11+
```
12+
13+
```release-note:new-resource
14+
tencentcloud_pts_file
15+
```
16+
17+
```release-note:new-resource
18+
tencentcloud_pts_job
19+
```
20+
21+
```release-note:new-resource
22+
tencentcloud_pts_cron_job
23+
```

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ require (
3535
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb v1.0.445
3636
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudaudit v1.0.199
3737
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.0.412
38-
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.532
38+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.533
3939
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.445
4040
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cynosdb v1.0.488
4141
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dayu v1.0.335
@@ -53,6 +53,7 @@ require (
5353
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/monitor v1.0.518
5454
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/postgres v1.0.391
5555
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/privatedns v1.0.290
56+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/pts v1.0.533
5657
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/redis v1.0.490
5758
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/scf v1.0.275
5859
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ses v1.0.529

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.529 h1:B26P
508508
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.529/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y=
509509
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.532 h1:DjnGMxuX49TNNyXp6V18VO+oY9Y5Gs4/+vL0LeZ8YIo=
510510
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.532/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y=
511+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.533 h1:UBHA9iYBQfkNYAWb6BixA8JCOQPxyMNMIVFdGjdM+1w=
512+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.533/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y=
511513
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.445 h1:Bh7XD0ypNMHYyBOM8hhKsSu+y0VVKUnJVS+YKKhfpGg=
512514
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.445/go.mod h1:jMDD351efCFpT1+KVFbcpu6SbmP4TYmp4qkoCfr63nQ=
513515
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cynosdb v1.0.488 h1:A1seXWtMf2atBjSNYvcwxyDoFzCMgqyVnsxnWzhqJEA=
@@ -543,6 +545,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/postgres v1.0.391 h1:1y
543545
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/postgres v1.0.391/go.mod h1:BZSQiBjNQ+6/gL1fFXBr/0BOuPTdHmSYoIg4/AkmZB4=
544546
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/privatedns v1.0.290 h1:osYZxh9ApEc8UpvIMwjAUfdl7ytRcWUpcnnqLIpiJ/U=
545547
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/privatedns v1.0.290/go.mod h1:En+pdagcHkAASorHT1l8R6tUtieRNNxaQ7nfyqWPefk=
548+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/pts v1.0.533 h1:BJDJlHkuoPsSUJ/ZHnmtX3gmA2PVfmKyhB7uV2d9QlE=
549+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/pts v1.0.533/go.mod h1:SHeExU5ggWrG8hsc4BMmxdhhw6WpoiWSu1Jw8CXs/Dg=
546550
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/redis v1.0.490 h1:JEW8+EjIGG5APXrPKLlMHo4fzLcCxVlg5QXwK1+YhA0=
547551
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/redis v1.0.490/go.mod h1:1yBtZUeKla8GNnVnJ1JOgMVBi/YgjEuQgzO4uNmisdI=
548552
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/scf v1.0.275 h1:hn5RrN/qkcObnyKfJ+raey/riVeRqHJFvY34l2YgELs=

tencentcloud/basic_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,3 +786,12 @@ const (
786786
)
787787

788788
// End of MARIADB
789+
// PTS
790+
const (
791+
defaultPtsProjectId = "project-45vw7v82"
792+
defaultScenarioId = "scenario-gb5ix8m2"
793+
defaultScenarioIdJob = "scenario-22q19f3k"
794+
defaultPtsNoticeId = "notice-tj75hgqj"
795+
)
796+
797+
// End of PTS

tencentcloud/common.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -384,16 +384,16 @@ func YamlParser(config string) (map[interface{}]interface{}, error) {
384384
return m, nil
385385
}
386386

387-
func YamlToBase64(config string) string {
387+
func StringToBase64(config string) string {
388388
m := []byte(config)
389389
encodedStr := base64.StdEncoding.EncodeToString(m)
390390
return encodedStr
391391
}
392392

393-
func Base64ToYaml(config string) (string, error) {
394-
yamlConfig, err := base64.StdEncoding.DecodeString(config)
393+
func Base64ToString(config string) (string, error) {
394+
strConfig, err := base64.StdEncoding.DecodeString(config)
395395
if err != nil {
396396
return "", err
397397
}
398-
return string(yamlConfig), nil
398+
return string(strConfig), nil
399399
}

tencentcloud/connectivity/client.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import (
5252
monitor "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/monitor/v20180724"
5353
postgre "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/postgres/v20170312"
5454
privatedns "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/privatedns/v20201028"
55+
pts "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/pts/v20210728"
5556
redis "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/redis/v20180412"
5657
scf "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/scf/v20180416"
5758
sms "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/sms/v20210111"
@@ -135,6 +136,7 @@ type TencentCloudClient struct {
135136
smsConn *sms.Client
136137
catConn *cat.Client
137138
mariadbConn *mariadb.Client
139+
ptsConn *pts.Client
138140
}
139141

140142
// NewClientProfile returns a new ClientProfile
@@ -853,6 +855,19 @@ func (me *TencentCloudClient) UseMariadbClient() *mariadb.Client {
853855
return me.mariadbConn
854856
}
855857

858+
// UsePtsClient returns pts client for service
859+
func (me *TencentCloudClient) UsePtsClient() *pts.Client {
860+
if me.ptsConn != nil {
861+
return me.ptsConn
862+
}
863+
864+
cpf := me.NewClientProfile(300)
865+
me.ptsConn, _ = pts.NewClient(me.Credential, me.Region, cpf)
866+
me.ptsConn.WithHttpTransport(&LogRoundTripper{})
867+
868+
return me.ptsConn
869+
}
870+
856871
func getEnvDefault(key string, defVal int) int {
857872
val, ex := os.LookupEnv(key)
858873
if !ex {

tencentcloud/internal/helper/helper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ func SetMapInterfaces(d *schema.ResourceData, key string, values ...map[string]i
157157

158158
func InterfaceToMap(d map[string]interface{}, key string) (result map[string]interface{}, ok bool) {
159159
if v, ok := d[key]; ok {
160-
if len(v.([]interface{})) != 1 {
160+
if len(v.([]interface{})) != 1 || v.([]interface{})[0] == nil {
161161
return nil, false
162162
}
163163
return v.([]interface{})[0].(map[string]interface{}), true

tencentcloud/provider.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,15 @@ TencentDB for MariaDB(MariaDB)
746746
tencentcloud_mariadb_log_file_retention_period
747747
tencentcloud_mariadb_security_groups
748748
749+
Performance Testing Service(PTS)
750+
Resource
751+
tencentcloud_pts_project
752+
tencentcloud_pts_alert_channel
753+
tencentcloud_pts_scenario
754+
tencentcloud_pts_file
755+
tencentcloud_pts_job
756+
tencentcloud_pts_cron_job
757+
749758
*/
750759
package tencentcloud
751760

@@ -1335,6 +1344,12 @@ func Provider() terraform.ResourceProvider {
13351344
"tencentcloud_mariadb_parameters": resourceTencentCloudMariadbParameters(),
13361345
"tencentcloud_mariadb_log_file_retention_period": resourceTencentCloudMariadbLogFileRetentionPeriod(),
13371346
"tencentcloud_mariadb_security_groups": resourceTencentCloudMariadbSecurityGroups(),
1347+
"tencentcloud_pts_project": resourceTencentCloudPtsProject(),
1348+
"tencentcloud_pts_alert_channel": resourceTencentCloudPtsAlertChannel(),
1349+
"tencentcloud_pts_scenario": resourceTencentCloudPtsScenario(),
1350+
"tencentcloud_pts_file": resourceTencentCloudPtsFile(),
1351+
"tencentcloud_pts_job": resourceTencentCloudPtsJob(),
1352+
"tencentcloud_pts_cron_job": resourceTencentCloudPtsCronJob(),
13381353
},
13391354

13401355
ConfigureFunc: providerConfigure,

tencentcloud/resource_tc_monitor_tmp_recording_rule.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func resourceTencentCloudMonitorTmpRecordingRuleCreate(d *schema.ResourceData, m
8989
request.Name = helper.String(v.(string))
9090
}
9191
if v, ok := d.GetOk("group"); ok {
92-
request.Group = helper.String(YamlToBase64(v.(string)))
92+
request.Group = helper.String(StringToBase64(v.(string)))
9393
}
9494
if v, ok := d.GetOk("instance_id"); ok {
9595
instanceId = v.(string)
@@ -152,7 +152,7 @@ func resourceTencentCloudMonitorTmpRecordingRuleRead(d *schema.ResourceData, met
152152
_ = d.Set("name", recordingRule.Name)
153153
}
154154
if recordingRule.Group != nil {
155-
group, err := Base64ToYaml(*recordingRule.Group)
155+
group, err := Base64ToString(*recordingRule.Group)
156156
if err != nil {
157157
return fmt.Errorf("`recordingRule.Group` %s does not be decoded to yaml", *recordingRule.Group)
158158
}

0 commit comments

Comments
 (0)