Skip to content

Commit c081b89

Browse files
authored
Merge pull request tencentcloudstack#420 from Himer/master
rewrite tcaplus names.
2 parents 2ccceb0 + 64592f9 commit c081b89

28 files changed

+933
-839
lines changed

CHANGELOG.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
## 1.34.0 (Unreleased)
1+
## 1.33.2 (Unreleased)
2+
3+
DEPRECATED:
4+
* Data Source: `tencentcloud_tcaplus_applications` replace by `tencentcloud_tcaplus_clusters`,optional arguments `app_id` and `app_name` are no longer supported, replace by `cluster_id` and `cluster_name`
5+
* Data Source: `tencentcloud_tcaplus_zones` replace by `tencentcloud_tcaplus_groups`,optional arguments `app_id`,`zone_id` and `zone_name` are no longer supported, replace by `cluster_id`,`group_id` and `cluster_name`
6+
* Data Source: `tencentcloud_tcaplus_tables` optional arguments `app_id` and `zone_id` are no longer supported, replace by `cluster_id` and `group_id`
7+
* Data Source: `tencentcloud_tcaplus_idls`: optional argument `app_id` is no longer supported, replace by `cluster_id`.
8+
* Resource: `tencentcloud_tcaplus_application` replace by `tencentcloud_tcaplus_cluster`,input argument `app_name` is no longer supported, replace by `cluster_name`
9+
* Resource: `tencentcloud_tcaplus_zone` replace by `tencentcloud_tcaplus_group`, input arguments `app_id` and `zone_name` are no longer supported, replace by `cluster_id` and `group_name`
10+
* Resource: `tencentcloud_tcaplus_idl` input arguments `app_id` and `zone_id` are no longer supported, replace by `cluster_id` and `group_id`
11+
* Resource: `tencentcloud_tcaplus_table` input arguments `app_id`and `zone_id` are no longer supported, replace by `cluster_id` and `group_id`
12+
* Resource: `tencentcloud_redis_instance`: optional argument `type` is no longer supported, replace by `type_id`.
13+
* Data Source: `tencentcloud_redis_instances`: output argument `type` is no longer supported, replace by `type_id`.
14+
* Data Source: `tencentcloud_redis_zone_config`: output argument `type` is no longer supported, replace by `type_id`.
15+
216
## 1.33.1 (May 22, 2020)
317

418
ENHANCEMENTS:

tencentcloud/data_source_tc_tcaplus_applications.go

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
/*
22
3-
Use this data source to query tcaplus applications
3+
Use this data source to query tcaplus clusters
44
55
Example Usage
66
77
```hcl
8-
data "tencentcloud_tcaplus_applications" "name" {
9-
app_name = "app"
8+
data "tencentcloud_tcaplus_clusters" "name" {
9+
cluster_name = "cluster"
1010
}
11-
data "tencentcloud_tcaplus_applications" "id" {
12-
app_id = tencentcloud_tcaplus_application.test.id
11+
data "tencentcloud_tcaplus_clusters" "id" {
12+
cluster_id = tencentcloud_tcaplus_cluster.test.id
1313
}
14-
data "tencentcloud_tcaplus_applications" "idname" {
15-
app_id = tencentcloud_tcaplus_application.test.id
16-
app_name = "app"
14+
data "tencentcloud_tcaplus_clusters" "idname" {
15+
cluster_id = tencentcloud_tcaplus_cluster.test.id
16+
cluster_name = "cluster"
1717
}
1818
```
1919
*/
@@ -26,19 +26,19 @@ import (
2626
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
2727
)
2828

29-
func dataSourceTencentCloudTcaplusApplications() *schema.Resource {
29+
func dataSourceTencentCloudTcaplusClusters() *schema.Resource {
3030
return &schema.Resource{
31-
Read: dataSourceTencentCloudTcaplusApplicationsRead,
31+
Read: dataSourceTencentCloudTcaplusClustersRead,
3232
Schema: map[string]*schema.Schema{
33-
"app_name": {
33+
"cluster_name": {
3434
Type: schema.TypeString,
3535
Optional: true,
36-
Description: "Name of the tcapplus application to be query.",
36+
Description: "Name of the tcaplus cluster to be query.",
3737
},
38-
"app_id": {
38+
"cluster_id": {
3939
Type: schema.TypeString,
4040
Optional: true,
41-
Description: "Id of the tcapplus application to be query.",
41+
Description: "Id of the tcaplus cluster to be query.",
4242
},
4343
"result_output_file": {
4444
Type: schema.TypeString,
@@ -48,68 +48,68 @@ func dataSourceTencentCloudTcaplusApplications() *schema.Resource {
4848
"list": {
4949
Type: schema.TypeList,
5050
Computed: true,
51-
Description: "A list of tcaplus application. Each element contains the following attributes.",
51+
Description: "A list of tcaplus cluster. Each element contains the following attributes.",
5252
Elem: &schema.Resource{
5353
Schema: map[string]*schema.Schema{
54-
"app_name": {
54+
"cluster_name": {
5555
Type: schema.TypeString,
5656
Computed: true,
57-
Description: "Name of the tcapplus application.",
57+
Description: "Name of the tcaplus cluster.",
5858
},
59-
"app_id": {
59+
"cluster_id": {
6060
Type: schema.TypeString,
6161
Computed: true,
62-
Description: "Id of the tcapplus application.",
62+
Description: "Id of the tcaplus cluster.",
6363
},
6464
"idl_type": {
6565
Type: schema.TypeString,
6666
Computed: true,
67-
Description: "Idl type of the tcapplus application.",
67+
Description: "Idl type of the tcaplus cluster.",
6868
},
6969
"vpc_id": {
7070
Type: schema.TypeString,
7171
Computed: true,
72-
Description: "VPC id of the tcapplus application.",
72+
Description: "VPC id of the tcaplus cluster.",
7373
},
7474
"subnet_id": {
7575
Type: schema.TypeString,
7676
Computed: true,
77-
Description: "Subnet id of the tcapplus application.",
77+
Description: "Subnet id of the tcaplus cluster.",
7878
},
7979
"password": {
8080
Type: schema.TypeString,
8181
Computed: true,
82-
Description: "Password of the tcapplus application.",
82+
Description: "Password of the tcaplus cluster.",
8383
},
8484
"network_type": {
8585
Type: schema.TypeString,
8686
Computed: true,
87-
Description: "Network type of the tcapplus application.",
87+
Description: "Network type of the tcaplus cluster.",
8888
},
8989
"create_time": {
9090
Type: schema.TypeString,
9191
Computed: true,
92-
Description: "Create time of the tcapplus application.",
92+
Description: "Create time of the tcaplus cluster.",
9393
},
9494
"password_status": {
9595
Type: schema.TypeString,
9696
Computed: true,
97-
Description: "Password status of the tcapplus application.`unmodifiable` means:can not change password now,`modifiable` means:can change password now.",
97+
Description: "Password status of the tcaplus cluster.`unmodifiable` means:can not change password now,`modifiable` means:can change password now.",
9898
},
9999
"api_access_id": {
100100
Type: schema.TypeString,
101101
Computed: true,
102-
Description: "Access id of the tcapplus application.For TcaplusDB SDK connect.",
102+
Description: "Access id of the tcaplus cluster.For TcaplusDB SDK connect.",
103103
},
104104
"api_access_ip": {
105105
Type: schema.TypeString,
106106
Computed: true,
107-
Description: "Access ip of the tcapplus application.For TcaplusDB SDK connect.",
107+
Description: "Access ip of the tcaplus cluster.For TcaplusDB SDK connect.",
108108
},
109109
"api_access_port": {
110110
Type: schema.TypeInt,
111111
Computed: true,
112-
Description: "Access port of the tcapplus application.For TcaplusDB SDK connect.",
112+
Description: "Access port of the tcaplus cluster.For TcaplusDB SDK connect.",
113113
},
114114
"old_password_expire_time": {
115115
Type: schema.TypeString,
@@ -123,8 +123,8 @@ func dataSourceTencentCloudTcaplusApplications() *schema.Resource {
123123
}
124124
}
125125

126-
func dataSourceTencentCloudTcaplusApplicationsRead(d *schema.ResourceData, meta interface{}) error {
127-
defer logElapsed("data_source.tencentcloud_tcaplus_applications.read")()
126+
func dataSourceTencentCloudTcaplusClustersRead(d *schema.ResourceData, meta interface{}) error {
127+
defer logElapsed("data_source.tencentcloud_tcaplus_clusters.read")()
128128

129129
logId := getLogId(contextNil)
130130
ctx := context.WithValue(context.TODO(), "logId", logId)
@@ -133,39 +133,39 @@ func dataSourceTencentCloudTcaplusApplicationsRead(d *schema.ResourceData, meta
133133
client: meta.(*TencentCloudClient).apiV3Conn,
134134
}
135135

136-
applicationId := d.Get("app_id").(string)
137-
applicationName := d.Get("app_name").(string)
136+
clusterId := d.Get("cluster_id").(string)
137+
clusterName := d.Get("cluster_name").(string)
138138

139-
apps, err := service.DescribeApps(ctx, applicationId, applicationName)
139+
clusters, err := service.DescribeClusters(ctx, clusterId, clusterName)
140140
if err != nil {
141-
apps, err = service.DescribeApps(ctx, applicationId, applicationName)
141+
clusters, err = service.DescribeClusters(ctx, clusterId, clusterName)
142142
}
143143

144144
if err != nil {
145145
return err
146146
}
147147

148-
list := make([]map[string]interface{}, 0, len(apps))
148+
list := make([]map[string]interface{}, 0, len(clusters))
149149

150-
for _, app := range apps {
150+
for _, cluster := range clusters {
151151
listItem := make(map[string]interface{})
152-
listItem["app_name"] = *app.ClusterName
153-
listItem["app_id"] = *app.ClusterId
154-
listItem["idl_type"] = *app.IdlType
155-
listItem["vpc_id"] = *app.VpcId
156-
listItem["subnet_id"] = *app.SubnetId
157-
listItem["password"] = *app.Password
158-
listItem["network_type"] = *app.NetworkType
159-
listItem["create_time"] = *app.CreatedTime
160-
listItem["password_status"] = *app.PasswordStatus
161-
listItem["api_access_id"] = *app.ApiAccessId
162-
listItem["api_access_ip"] = *app.ApiAccessIp
163-
listItem["api_access_port"] = *app.ApiAccessPort
164-
listItem["old_password_expire_time"] = *app.OldPasswordExpireTime
152+
listItem["cluster_name"] = cluster.ClusterName
153+
listItem["cluster_id"] = cluster.ClusterId
154+
listItem["idl_type"] = cluster.IdlType
155+
listItem["vpc_id"] = cluster.VpcId
156+
listItem["subnet_id"] = cluster.SubnetId
157+
listItem["password"] = cluster.Password
158+
listItem["network_type"] = cluster.NetworkType
159+
listItem["create_time"] = cluster.CreatedTime
160+
listItem["password_status"] = cluster.PasswordStatus
161+
listItem["api_access_id"] = cluster.ApiAccessId
162+
listItem["api_access_ip"] = cluster.ApiAccessIp
163+
listItem["api_access_port"] = cluster.ApiAccessPort
164+
listItem["old_password_expire_time"] = cluster.OldPasswordExpireTime
165165
list = append(list, listItem)
166166
}
167167

168-
d.SetId("app." + applicationId + "." + applicationName)
168+
d.SetId("cluster." + clusterId + "." + clusterName)
169169
if e := d.Set("list", list); e != nil {
170170
log.Printf("[CRITAL]%s provider set list fail, reason:%s\n", logId, e.Error())
171171
return e

tencentcloud/data_source_tc_tcaplus_applications_test.go

Lines changed: 25 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6,71 +6,53 @@ import (
66
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
77
)
88

9-
var testDataTcaplusApplicationsName = "data.tencentcloud_tcaplus_applications.id_test"
9+
var testDataTcaplusClustersName = "data.tencentcloud_tcaplus_clusters.id_test"
1010

11-
func TestAccTencentCloudDataTcaplusApplications(t *testing.T) {
11+
func TestAccTencentCloudDataTcaplusClusters(t *testing.T) {
1212
resource.Test(t, resource.TestCase{
1313
PreCheck: func() { testAccPreCheck(t) },
1414
Providers: testAccProviders,
15-
CheckDestroy: testAccCheckTcaplusApplicationDestroy,
15+
CheckDestroy: testAccCheckTcaplusClusterDestroy,
1616
Steps: []resource.TestStep{
1717
{
18-
Config: testAccTencentCloudDataTcaplusApplicationsBaic,
18+
Config: testAccTencentCloudDataTcaplusClustersBaic,
1919
Check: resource.ComposeAggregateTestCheckFunc(
20-
testAccCheckTcaplusApplicationExists("tencentcloud_tcaplus_application.test_app"),
21-
resource.TestCheckResourceAttrSet(testDataTcaplusApplicationsName, "app_id"),
22-
resource.TestCheckResourceAttr(testDataTcaplusApplicationsName, "list.#", "1"),
23-
resource.TestCheckResourceAttr(testDataTcaplusApplicationsName, "list.0.app_name", "tf_tcaplus_data_guagua"),
24-
resource.TestCheckResourceAttr(testDataTcaplusApplicationsName, "list.0.idl_type", "PROTO"),
25-
resource.TestCheckResourceAttr(testDataTcaplusApplicationsName, "list.0.password", "1qaA2k1wgvfa3ZZZ"),
26-
resource.TestCheckResourceAttrSet(testDataTcaplusApplicationsName, "list.0.network_type"),
27-
resource.TestCheckResourceAttrSet(testDataTcaplusApplicationsName, "list.0.create_time"),
28-
resource.TestCheckResourceAttrSet(testDataTcaplusApplicationsName, "list.0.password_status"),
29-
resource.TestCheckResourceAttrSet(testDataTcaplusApplicationsName, "list.0.api_access_id"),
30-
resource.TestCheckResourceAttrSet(testDataTcaplusApplicationsName, "list.0.api_access_ip"),
31-
resource.TestCheckResourceAttrSet(testDataTcaplusApplicationsName, "list.0.api_access_port"),
20+
testAccCheckTcaplusClusterExists("tencentcloud_tcaplus_cluster.test_cluster"),
21+
resource.TestCheckResourceAttrSet(testDataTcaplusClustersName, "cluster_id"),
22+
resource.TestCheckResourceAttr(testDataTcaplusClustersName, "list.#", "1"),
23+
resource.TestCheckResourceAttr(testDataTcaplusClustersName, "list.0.cluster_name", "tf_tcaplus_data_guagua"),
24+
resource.TestCheckResourceAttr(testDataTcaplusClustersName, "list.0.idl_type", "PROTO"),
25+
resource.TestCheckResourceAttrSet(testDataTcaplusClustersName, "list.0.network_type"),
26+
resource.TestCheckResourceAttrSet(testDataTcaplusClustersName, "list.0.create_time"),
27+
resource.TestCheckResourceAttrSet(testDataTcaplusClustersName, "list.0.password_status"),
28+
resource.TestCheckResourceAttrSet(testDataTcaplusClustersName, "list.0.api_access_id"),
29+
resource.TestCheckResourceAttrSet(testDataTcaplusClustersName, "list.0.api_access_ip"),
30+
resource.TestCheckResourceAttrSet(testDataTcaplusClustersName, "list.0.api_access_port"),
3231
),
3332
},
3433
},
3534
})
3635
}
3736

38-
const testAccTencentCloudDataTcaplusApplicationsBaic = `
37+
const testAccTencentCloudDataTcaplusClustersBaic = `
3938
variable "availability_zone" {
4039
default = "ap-shanghai-2"
4140
}
4241
43-
variable "instance_name" {
44-
default = "` + defaultInsName + `"
45-
}
46-
variable "vpc_cidr" {
47-
default = "` + defaultVpcCidr + `"
48-
}
49-
variable "subnet_cidr" {
50-
default = "` + defaultSubnetCidr + `"
42+
data "tencentcloud_vpc_subnets" "vpc" {
43+
is_default = true
44+
availability_zone = var.availability_zone
5145
}
5246
53-
resource "tencentcloud_vpc" "foo" {
54-
name = var.instance_name
55-
cidr_block = var.vpc_cidr
56-
}
57-
58-
resource "tencentcloud_subnet" "subnet" {
59-
name = var.instance_name
60-
vpc_id = tencentcloud_vpc.foo.id
61-
availability_zone = var.availability_zone
62-
cidr_block = var.subnet_cidr
63-
is_multicast = false
64-
}
65-
resource "tencentcloud_tcaplus_application" "test_app" {
47+
resource "tencentcloud_tcaplus_cluster" "test_cluster" {
6648
idl_type = "PROTO"
67-
app_name = "tf_tcaplus_data_guagua"
68-
vpc_id = tencentcloud_vpc.foo.id
69-
subnet_id = tencentcloud_subnet.subnet.id
49+
cluster_name = "tf_tcaplus_data_guagua"
50+
vpc_id = data.tencentcloud_vpc_subnets.vpc.instance_list.0.vpc_id
51+
subnet_id = data.tencentcloud_vpc_subnets.vpc.instance_list.0.subnet_id
7052
password = "1qaA2k1wgvfa3ZZZ"
7153
old_password_expire_last = 3600
7254
}
73-
data "tencentcloud_tcaplus_applications" "id_test" {
74-
app_id = tencentcloud_tcaplus_application.test_app.id
55+
data "tencentcloud_tcaplus_clusters" "id_test" {
56+
cluster_id = tencentcloud_tcaplus_cluster.test_cluster.id
7557
}
7658
`

tencentcloud/data_source_tc_tcaplus_idls.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Example Usage
55
66
```hcl
77
data "tencentcloud_tcaplus_idls" "id_test" {
8-
app_id = "19162256624"
8+
cluster_id = "19162256624"
99
}
1010
```
1111
*/
@@ -24,10 +24,10 @@ func dataSourceTencentCloudTcaplusIdls() *schema.Resource {
2424
return &schema.Resource{
2525
Read: dataSourceTencentCloudTcaplusIdlsRead,
2626
Schema: map[string]*schema.Schema{
27-
"app_id": {
27+
"cluster_id": {
2828
Type: schema.TypeString,
2929
Required: true,
30-
Description: "Id of the tcapplus application to be query.",
30+
Description: "Id of the tcaplus cluster to be query.",
3131
},
3232
"result_output_file": {
3333
Type: schema.TypeString,
@@ -62,27 +62,27 @@ func dataSourceTencentCloudTcaplusIdlsRead(d *schema.ResourceData, meta interfac
6262
client: meta.(*TencentCloudClient).apiV3Conn,
6363
}
6464

65-
applicationId := d.Get("app_id").(string)
65+
clusterId := d.Get("cluster_id").(string)
6666

67-
apps, err := service.DescribeIdlFileInfos(ctx, applicationId)
67+
infos, err := service.DescribeIdlFileInfos(ctx, clusterId)
6868
if err != nil {
69-
apps, err = service.DescribeIdlFileInfos(ctx, applicationId)
69+
infos, err = service.DescribeIdlFileInfos(ctx, clusterId)
7070
}
7171
if err != nil {
7272
return err
7373
}
7474

75-
list := make([]map[string]interface{}, 0, len(apps))
75+
list := make([]map[string]interface{}, 0, len(infos))
7676

77-
for _, app := range apps {
77+
for _, info := range infos {
7878
listItem := make(map[string]interface{})
7979
var tcaplusIdlId TcaplusIdlId
80-
tcaplusIdlId.ApplicationId = applicationId
81-
tcaplusIdlId.FileName = *app.FileName
82-
tcaplusIdlId.FileType = *app.FileType
83-
tcaplusIdlId.FileExtType = *app.FileExtType
84-
tcaplusIdlId.FileSize = *app.FileSize
85-
tcaplusIdlId.FileId = *app.FileId
80+
tcaplusIdlId.ClusterId = clusterId
81+
tcaplusIdlId.FileName = *info.FileName
82+
tcaplusIdlId.FileType = *info.FileType
83+
tcaplusIdlId.FileExtType = *info.FileExtType
84+
tcaplusIdlId.FileSize = *info.FileSize
85+
tcaplusIdlId.FileId = *info.FileId
8686
id, err := json.Marshal(tcaplusIdlId)
8787
if err != nil {
8888
return fmt.Errorf("format idl id fail,%s", err.Error())
@@ -91,7 +91,7 @@ func dataSourceTencentCloudTcaplusIdlsRead(d *schema.ResourceData, meta interfac
9191
list = append(list, listItem)
9292
}
9393

94-
d.SetId("idl." + applicationId)
94+
d.SetId("idl." + clusterId)
9595
if e := d.Set("list", list); e != nil {
9696
log.Printf("[CRITAL]%s provider set list fail, reason:%s\n", logId, e.Error())
9797
return e

0 commit comments

Comments
 (0)