Skip to content

Commit c65eeaa

Browse files
gitmknanonymous
andauthored
Fix/tsf support (#1632)
* fix: update tsf * fix: support tencentcloud_tsf_api_rate_limit_rule * fix: update test * fix: modify tsf * fix: modify tsf * fix: support tsf * fix: update account * feat: support group * fix: modfiy provider * feat: add changelog * fix: modify changelog * fix: modify contain group * fix: modify task test * fix: modfiy task test * fix: modify unit rule test * fix: modify limit rule test --------- Co-authored-by: anonymous <anonymous@mail.org>
1 parent 763eddb commit c65eeaa

File tree

55 files changed

+5079
-579
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+5079
-579
lines changed

.changelog/1632.txt

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
```release-note:new-resource
2+
tencentcloud_tsf_cluster
3+
```
4+
5+
```release-note:new-resource
6+
tencentcloud_tsf_path_rewrite
7+
```
8+
9+
```release-note:new-resource
10+
tencentcloud_tsf_unit_rule
11+
```
12+
13+
```release-note:new-resource
14+
tencentcloud_tsf_task
15+
```
16+
17+
```release-note:new-resource
18+
tencentcloud_tsf_config_template
19+
```
20+
21+
```release-note:new-resource
22+
tencentcloud_tsf_api_rate_limit_rule
23+
```
24+
25+
```release-note:new-resource
26+
tencentcloud_tsf_application_release_config
27+
```
28+
29+
```release-note:new-resource
30+
tencentcloud_tsf_lane
31+
```
32+
33+
```release-note:new-resource
34+
tencentcloud_tsf_lane_rule
35+
```
36+
37+
```release-note:new-resource
38+
tencentcloud_tsf_group
39+
```
40+
41+
```release-note:enhancement
42+
resource/tencentcloud_tsf_namespace: Cancel support for import
43+
```
44+
45+
```release-note:enhancement
46+
resource/tencentcloud_tsf_application_config: Cancel support for import
47+

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ require (
8282
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tem v1.0.578
8383
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/teo v1.0.529
8484
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.583
85-
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf v1.0.584
85+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf v1.0.625
8686
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vod v1.0.199
8787
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc v1.0.569
8888
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/wss v1.0.199

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.583 h1:tUEZuK9
623623
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.583/go.mod h1:HaMLvoYz5fldMlSpudPTtIN+cf2YYS69+w8jqiC2x1s=
624624
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf v1.0.584 h1:gejIVfoHRqvbR0Znt6DJlpsA3Z9cutUmbdhdWb4gZK4=
625625
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf v1.0.584/go.mod h1:Qs+sspd2V1hRAn7WmK6K3iu3M+F+azX1ryFgsZbGGg4=
626+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf v1.0.625 h1:7MIw7C2ra7zPQPKDvQd1G/daAhg0wXxftCHqmRK+kgo=
627+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf v1.0.625/go.mod h1:xmIp0wQaSn5rSGJFCjakl5FPNVrIPYa3Uknj3oI3tmc=
626628
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vod v1.0.199 h1:6Yt74l4pA5QtzhwMNIEUt0spXdSBKH744DDqTHJOCP0=
627629
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vod v1.0.199/go.mod h1:Yw6OQ33z3s4k0HVYTNSffB12qOzEJ2Zf1Vj4+5S3sRs=
628630
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc v1.0.569 h1:rrtTVqu44XEXf88RDE0G7dgT+MwR1XA/YfM11a/+F5g=

tencentcloud/basic_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -934,8 +934,15 @@ variable "cynosdb_cluster_security_group_id" {
934934

935935
// TSF
936936
const (
937-
defaultNamespaceId = "namespace-ym9mkeza"
938-
defaultTsfApplicationId = "application-v69bo6ev"
937+
defaultNamespaceId = "namespace-aemrg36v"
938+
defaultTsfApplicationId = "application-a24x29xv"
939+
defaultTsfClustId = "cluster-vwgj5e6y"
940+
defaultTsfGroupId = "group-yrjkln9v"
941+
defaultTsfGateway = "gw-ins-lvdypq5k"
942+
defaultTsfDestNamespaceId = "namespace-aemrg36v"
943+
defaultTsfConfigId = "dcfg-y54wzk3a"
944+
defaultTsfApiId = "api-j03q029a"
945+
defaultTsfGWGroupId = "group-vzd97zpy"
939946
)
940947

941948
// End of TSF

tencentcloud/provider.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -968,10 +968,20 @@ TDMQ for CMQ
968968
969969
Tencent Service Framework(TSF)
970970
Resource
971+
tencentcloud_tsf_cluster
971972
tencentcloud_tsf_microservice
972973
tencentcloud_tsf_application_config
973974
tencentcloud_tsf_api_group
974975
tencentcloud_tsf_namespace
976+
tencentcloud_tsf_path_rewrite
977+
tencentcloud_tsf_unit_rule
978+
tencentcloud_tsf_task
979+
tencentcloud_tsf_config_template
980+
tencentcloud_tsf_api_rate_limit_rule
981+
tencentcloud_tsf_application_release_config
982+
tencentcloud_tsf_lane
983+
tencentcloud_tsf_lane_rule
984+
tencentcloud_tsf_group
975985
976986
Media Processing Service(MPS)
977987
Resource
@@ -1758,18 +1768,20 @@ func Provider() terraform.ResourceProvider {
17581768
"tencentcloud_tsf_microservice": resourceTencentCloudTsfMicroservice(),
17591769
"tencentcloud_tsf_application_config": resourceTencentCloudTsfApplicationConfig(),
17601770
"tencentcloud_cvm_launch_template": resourceTencentCloudCvmLaunchTemplate(),
1771+
"tencentcloud_tsf_cluster": resourceTencentCloudTsfCluster(),
17611772
"tencentcloud_tsf_api_group": resourceTencentCloudTsfApiGroup(),
17621773
"tencentcloud_tsf_namespace": resourceTencentCloudTsfNamespace(),
17631774
"tencentcloud_tsf_path_rewrite": resourceTencentCloudTsfPathRewrite(),
17641775
"tencentcloud_tsf_unit_rule": resourceTencentCloudTsfUnitRule(),
17651776
"tencentcloud_tsf_task": resourceTencentCloudTsfTask(),
1766-
"tencentcloud_tsf_repository": resourceTencentCloudTsfRepository(),
17671777
"tencentcloud_tsf_config_template": resourceTencentCloudTsfConfigTemplate(),
17681778
"tencentcloud_tsf_api_rate_limit_rule": resourceTencentCloudTsfApiRateLimitRule(),
17691779
"tencentcloud_tsf_application_release_config": resourceTencentCloudTsfApplicationReleaseConfig(),
17701780
"tencentcloud_tsf_contain_group": resourceTencentCloudTsfContainGroup(),
17711781
"tencentcloud_tsf_lane": resourceTencentCloudTsfLane(),
17721782
"tencentcloud_tsf_lane_rule": resourceTencentCloudTsfLaneRule(),
1783+
"tencentcloud_tsf_group": resourceTencentCloudTsfGroup(),
1784+
"tencentcloud_tsf_repository": resourceTencentCloudTsfRepository(),
17731785
"tencentcloud_mps_workflow": resourceTencentCloudMpsWorkflow(),
17741786
"tencentcloud_mps_transcode_template": resourceTencentCloudMpsTranscodeTemplate(),
17751787
"tencentcloud_mps_watermark_template": resourceTencentCloudMpsWatermarkTemplate(),

tencentcloud/provider_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const (
2424
ACCOUNT_TYPE_SUB_ACCOUNT = "SUB_ACCOUNT"
2525
ACCOUNT_TYPE_SMS = "SMS"
2626
ACCOUNT_TYPE_SES = "SES"
27+
ACCOUNT_TYPE_TSF = "TSF"
2728
INTERNATIONAL_PROVIDER_SECRET_ID = "TENCENTCLOUD_SECRET_ID_INTERNATIONAL"
2829
INTERNATIONAL_PROVIDER_SECRET_KEY = "TENCENTCLOUD_SECRET_KEY_INTERNATIONAL"
2930
PREPAY_PROVIDER_SECRET_ID = "TENCENTCLOUD_SECRET_ID_PREPAY"
@@ -36,6 +37,8 @@ const (
3637
SUB_ACCOUNT_PROVIDER_SECRET_KEY = "TENCENTCLOUD_SECRET_KEY_SUB_ACCOUNT"
3738
SMS_PROVIDER_SECRET_ID = "TENCENTCLOUD_SECRET_ID_SMS"
3839
SMS_PROVIDER_SECRET_KEY = "TENCENTCLOUD_SECRET_KEY_SMS"
40+
TSF_PROVIDER_SECRET_ID = "TENCENTCLOUD_SECRET_ID_TSF"
41+
TSF_PROVIDER_SECRET_KEY = "TENCENTCLOUD_SECRET_KEY_TSF"
3942
)
4043

4144
func init() {
@@ -143,6 +146,14 @@ func testAccPreCheckCommon(t *testing.T, accountType string) {
143146
}
144147
os.Setenv(PROVIDER_SECRET_ID, secretId)
145148
os.Setenv(PROVIDER_SECRET_KEY, secretKey)
149+
case accountType == ACCOUNT_TYPE_TSF:
150+
secretId := os.Getenv(TSF_PROVIDER_SECRET_ID)
151+
secretKey := os.Getenv(TSF_PROVIDER_SECRET_KEY)
152+
if secretId == "" || secretKey == "" {
153+
t.Fatalf("%v and %v must be set for acceptance tests\n", TSF_PROVIDER_SECRET_ID, TSF_PROVIDER_SECRET_KEY)
154+
}
155+
os.Setenv(PROVIDER_SECRET_ID, secretId)
156+
os.Setenv(PROVIDER_SECRET_KEY, secretKey)
146157
default:
147158
if v := os.Getenv(PROVIDER_SECRET_ID); v == "" {
148159
t.Fatalf("%v must be set for acceptance tests\n", PROVIDER_SECRET_ID)

tencentcloud/resource_tc_tsf_api_group_test.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,15 @@ import (
77

88
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
99
"github.com/hashicorp/terraform-plugin-sdk/terraform"
10+
sdkErrors "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"
1011
)
1112

1213
// go test -i; go test -test.run TestAccTencentCloudTsfApiGroupResource_basic -v
13-
func TestAccTencentCloudNeedFixTsfApiGroupResource_basic(t *testing.T) {
14+
func TestAccTencentCloudTsfApiGroupResource_basic(t *testing.T) {
1415
t.Parallel()
1516

1617
resource.Test(t, resource.TestCase{
17-
PreCheck: func() {
18-
testAccPreCheck(t)
19-
},
18+
PreCheck: func() { testAccPreCheckCommon(t, ACCOUNT_TYPE_TSF) },
2019
Providers: testAccProviders,
2120
CheckDestroy: testAccCheckTsfApiGroupDestroy,
2221
Steps: []resource.TestStep{
@@ -54,6 +53,10 @@ func testAccCheckTsfApiGroupDestroy(s *terraform.State) error {
5453

5554
res, err := service.DescribeTsfApiGroupById(ctx, rs.Primary.ID)
5655
if err != nil {
56+
code := err.(*sdkErrors.TencentCloudSDKError).Code
57+
if code == "InvalidParameterValue.GatewayParameterInvalid" {
58+
return nil
59+
}
5760
return err
5861
}
5962

@@ -88,15 +91,21 @@ func testAccCheckTsfApiGroupExists(r string) resource.TestCheckFunc {
8891
}
8992
}
9093

91-
const testAccTsfApiGroup = `
94+
const testAccTsfApiGroupVar = `
95+
variable "gateway_instance_id" {
96+
default = "` + defaultTsfGateway + `"
97+
}
98+
`
99+
100+
const testAccTsfApiGroup = testAccTsfApiGroupVar + `
92101
93102
resource "tencentcloud_tsf_api_group" "api_group" {
94103
group_name = "terraform_test_group"
95104
group_context = "/terraform-test"
96105
auth_type = "none"
97106
description = "terraform-test"
98107
group_type = "ms"
99-
gateway_instance_id = "gw-ins-i6mjpgm8"
108+
gateway_instance_id = var.gateway_instance_id
100109
# namespace_name_key = "path"
101110
# service_name_key = "path"
102111
namespace_name_key_position = "path"

tencentcloud/resource_tc_tsf_api_rate_limit_rule.go

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ Example Usage
55
66
```hcl
77
resource "tencentcloud_tsf_api_rate_limit_rule" "api_rate_limit_rule" {
8-
api_id = ""
9-
max_qps =
10-
usable_status = ""
8+
api_id = "api-xxxxxx"
9+
max_qps = 10
10+
usable_status = "enable"
1111
}
1212
```
1313
@@ -56,10 +56,11 @@ func resourceTencentCloudTsfApiRateLimitRule() *schema.Resource {
5656
},
5757

5858
"usable_status": {
59-
Optional: true,
60-
Computed: true,
61-
Type: schema.TypeString,
62-
Description: "Enable/disable, enabled/disabled, if not passed, it is enabled by default.",
59+
Optional: true,
60+
Computed: true,
61+
Type: schema.TypeString,
62+
ValidateFunc: validateAllowedStringValue([]string{"enabled", "disabled"}),
63+
Description: "Enabled/disabled, enabled/disabled, if not passed, it is enabled by default.",
6364
},
6465

6566
"rule_id": {
@@ -114,10 +115,10 @@ func resourceTencentCloudTsfApiRateLimitRuleCreate(d *schema.ResourceData, meta
114115
logId := getLogId(contextNil)
115116

116117
var (
117-
request = tsf.NewCreateApiRateLimitRuleRequest()
118-
// response = tsf.NewCreateApiRateLimitRuleResponse()
119-
apiId string
120-
ruleId string
118+
request = tsf.NewCreateApiRateLimitRuleWithDetailRespRequest()
119+
response = tsf.NewCreateApiRateLimitRuleWithDetailRespResponse()
120+
apiId string
121+
ruleId string
121122
)
122123
if v, ok := d.GetOk("api_id"); ok {
123124
apiId = v.(string)
@@ -133,21 +134,21 @@ func resourceTencentCloudTsfApiRateLimitRuleCreate(d *schema.ResourceData, meta
133134
}
134135

135136
err := resource.Retry(writeRetryTimeout, func() *resource.RetryError {
136-
result, e := meta.(*TencentCloudClient).apiV3Conn.UseTsfClient().CreateApiRateLimitRule(request)
137+
result, e := meta.(*TencentCloudClient).apiV3Conn.UseTsfClient().CreateApiRateLimitRuleWithDetailResp(request)
137138
if e != nil {
138139
return retryError(e)
139140
} else {
140141
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString())
141142
}
142-
// response = result
143+
response = result
143144
return nil
144145
})
145146
if err != nil {
146147
log.Printf("[CRITAL]%s create tsf apiRateLimitRule failed, reason:%+v", logId, err)
147148
return err
148149
}
149150

150-
// ruleId = *response.Response.RuleId
151+
ruleId = *response.Response.Result.RuleId
151152
d.SetId(apiId + FILED_SP + ruleId)
152153

153154
return resourceTencentCloudTsfApiRateLimitRuleRead(d, meta)
@@ -241,7 +242,7 @@ func resourceTencentCloudTsfApiRateLimitRuleUpdate(d *schema.ResourceData, meta
241242

242243
request.RuleId = &ruleId
243244

244-
immutableArgs := []string{"api_id", "max_qps", "usable_status", "result"}
245+
immutableArgs := []string{"api_id"}
245246

246247
for _, v := range immutableArgs {
247248
if d.HasChange(v) {
@@ -282,20 +283,20 @@ func resourceTencentCloudTsfApiRateLimitRuleDelete(d *schema.ResourceData, meta
282283
defer logElapsed("resource.tencentcloud_tsf_api_rate_limit_rule.delete")()
283284
defer inconsistentCheck(d, meta)()
284285

285-
// logId := getLogId(contextNil)
286-
// ctx := context.WithValue(context.TODO(), logIdKey, logId)
286+
logId := getLogId(contextNil)
287+
ctx := context.WithValue(context.TODO(), logIdKey, logId)
287288

288-
// service := TsfService{client: meta.(*TencentCloudClient).apiV3Conn}
289-
// idSplit := strings.Split(d.Id(), FILED_SP)
290-
// if len(idSplit) != 2 {
291-
// return fmt.Errorf("id is broken,%s", d.Id())
292-
// }
293-
// apiId := idSplit[0]
294-
// ruleId := idSplit[1]
289+
service := TsfService{client: meta.(*TencentCloudClient).apiV3Conn}
290+
idSplit := strings.Split(d.Id(), FILED_SP)
291+
if len(idSplit) != 2 {
292+
return fmt.Errorf("id is broken,%s", d.Id())
293+
}
294+
apiId := idSplit[0]
295+
ruleId := idSplit[1]
295296

296-
// if err := service.DeleteTsfApiRateLimitRuleById(ctx, apiId, ruleId); err != nil {
297-
// return err
298-
// }
297+
if err := service.DeleteTsfApiRateLimitRuleById(ctx, apiId, ruleId); err != nil {
298+
return err
299+
}
299300

300301
return nil
301302
}

0 commit comments

Comments
 (0)