Skip to content

Commit 59ba9c4

Browse files
authored
Merge pull request #154 from terraform-tencentcloud/master
add check ContainsBigSymbol
2 parents 5aafc2a + b4452a7 commit 59ba9c4

File tree

7 files changed

+37
-22
lines changed

7 files changed

+37
-22
lines changed

gendoc/gendoc_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,20 @@ resource "tencentcloud_cos_bucket" "mycos" {
7979
t.Error("format hcl failed")
8080
}
8181
}
82+
83+
func TestContainsBigSymbol(t *testing.T) {
84+
cases := "中国人繁體字abcABC~!@#¥%…&()—+{}|:“”《》?1234567890-=【】\;‘’,。、 "
85+
for _, c := range cases {
86+
if ContainsBigSymbol(string(c)) == "" {
87+
t.Log(c)
88+
t.Errorf("Expected %s to be Chinese symbol", string(c))
89+
}
90+
}
91+
92+
cases = "abcABC~!@#$%^&*()_+{}|:\"<>?`1234567890-=[]\\;',./ \t\r\n"
93+
for _, c := range cases {
94+
if ContainsBigSymbol(string(c)) != "" {
95+
t.Errorf("Expected %s not to be Chinese symbol", string(c))
96+
}
97+
}
98+
}

gendoc/main.go

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ const (
2727
)
2828

2929
var (
30-
hclMatch = regexp.MustCompile("(?si)([^`]+)?```(hcl)?(.*?)```")
30+
hclMatch = regexp.MustCompile("(?si)([^`]+)?```(hcl)?(.*?)```")
31+
bigSymbol = regexp.MustCompile("([\u007F-\uffff])")
3132
)
3233

3334
func main() {
@@ -439,20 +440,17 @@ func checkDescription(k, s string) {
439440
os.Exit(1)
440441
}
441442

442-
if c := ContainsChineseSymbol(s); c != "" {
443-
log.Printf("[FAIL!]There is Chinese symbol: '%s' on the description: '%s': '%s'", c, k, s)
443+
if c := ContainsBigSymbol(s); c != "" {
444+
log.Printf("[FAIL!]There is unexcepted symbol: '%s' on the description: '%s': '%s'", c, k, s)
444445
os.Exit(1)
445446
}
446447
}
447448

448-
// ContainsChineseSymbol returns the Chinese symbol if found
449-
func ContainsChineseSymbol(s string) string {
450-
symbolChinese := "abcdefghijklmnopqrstuvwsyzABCDEFGHIJKLMNOPQRSTUVWSYZ~!@#¥%……&×()——+{}|:“”《》?·1234567890-=【】\;‘’,。、 "
451-
452-
for _, c := range symbolChinese {
453-
if strings.Contains(s, string(c)) {
454-
return string(c)
455-
}
449+
// ContainsBigSymbol returns the Big symbol if found
450+
func ContainsBigSymbol(s string) string {
451+
m := bigSymbol.FindStringSubmatch(s)
452+
if len(m) > 0 {
453+
return m[0]
456454
}
457455

458456
return ""

tencentcloud/data_source_tc_mysql_instance.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func dataSourceTencentCloudMysqlInstance() *schema.Resource {
3939
Type: schema.TypeInt,
4040
Optional: true,
4141
ValidateFunc: validateAllowedIntValue([]int{0, 1, 4, 5}),
42-
Description: "Instance status. Available values: 0 - Creating; 1 - Running; 4 - Isolating; 5 Isolated.",
42+
Description: "Instance status. Available values: 0 - Creating; 1 - Running; 4 - Isolating; 5 - Isolated.",
4343
},
4444
"security_group_id": {
4545
Type: schema.TypeString,
@@ -67,7 +67,7 @@ func dataSourceTencentCloudMysqlInstance() *schema.Resource {
6767
Type: schema.TypeInt,
6868
Optional: true,
6969
ValidateFunc: validateAllowedIntValue([]int{0, 1}),
70-
Description: "Initialization mark. Available values: 0 - Uninitialized; 1 Initialized.",
70+
Description: "Initialization mark. Available values: 0 - Uninitialized; 1 - Initialized.",
7171
},
7272
"with_dr": {
7373
Type: schema.TypeInt,
@@ -131,12 +131,12 @@ func dataSourceTencentCloudMysqlInstance() *schema.Resource {
131131
"init_flag": {
132132
Type: schema.TypeInt,
133133
Computed: true,
134-
Description: "Initialization mark. Available values: 0 - Uninitialized; 1 Initialized.",
134+
Description: "Initialization mark. Available values: 0 - Uninitialized; 1 - Initialized.",
135135
},
136136
"status": {
137137
Type: schema.TypeInt,
138138
Computed: true,
139-
Description: "Instance status. Available values: 0 - Creating; 1 - Running; 4 - Isolating; 5 Isolated.",
139+
Description: "Instance status. Available values: 0 - Creating; 1 - Running; 4 - Isolating; 5 - Isolated.",
140140
},
141141
"zone": {
142142
Type: schema.TypeString,

tencentcloud/resource_tc_mysql_instance.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ func TencentMsyqlBasicInfo() map[string]*schema.Schema {
142142
"status": {
143143
Type: schema.TypeInt,
144144
Computed: true,
145-
Description: "Instance status. Available values: 0 - Creating; 1 - Running; 4 - Isolating; 5 Isolated.",
145+
Description: "Instance status. Available values: 0 - Creating; 1 - Running; 4 - Isolating; 5 - Isolated.",
146146
},
147147
"task_status": {
148148
Type: schema.TypeInt,

website/docs/d/mysql_instance.html.markdown

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ data "tencentcloud_mysql_instance" "database" {
2424
The following arguments are supported:
2525

2626
* `engine_version` - (Optional) The version number of the database engine to use. Supported versions include 5.5/5.6/5.7.
27-
* `init_flag` - (Optional) Initialization mark. Available values: 0 - Uninitialized; 1 Initialized.
27+
* `init_flag` - (Optional) Initialization mark. Available values: 0 - Uninitialized; 1 - Initialized.
2828
* `instance_name` - (Optional) Name of mysql instance.
2929
* `instance_role` - (Optional) Instance type. Supported values include: master - master instance, dr - disaster recovery instance, and ro - read-only instance.
3030
* `limit` - (Optional) Number of results returned for a single request. Default is 20, and maximum is 2000.
3131
* `mysql_id` - (Optional) Instance ID, such as cdb-c1nl9rpv. It is identical to the instance ID displayed in the database console page.
3232
* `offset` - (Optional) Record offset. Default is 0.
3333
* `result_output_file` - (Optional) Used to store results.
3434
* `security_group_id` - (Optional) Security groups ID of instance.
35-
* `status` - (Optional) Instance status. Available values: 0 - Creating; 1 - Running; 4 - Isolating; 5 Isolated.
35+
* `status` - (Optional) Instance status. Available values: 0 - Creating; 1 - Running; 4 - Isolating; 5 - Isolated.
3636
* `with_dr` - (Optional) Indicates whether to query disaster recovery instances.
3737
* `with_master` - (Optional) Indicates whether to query master instances.
3838
* `with_ro` - (Optional) Indicates whether to query read-only instances.
@@ -47,7 +47,7 @@ In addition to all arguments above, the following attributes are exported:
4747
* `device_type` - Supported instance model.HA - high available version; Basic - basic version.
4848
* `dr_instance_ids` - ID list of disaster-recovory type associated with the current instance.
4949
* `engine_version` - The version number of the database engine to use. Supported versions include 5.5/5.6/5.7.
50-
* `init_flag` - Initialization mark. Available values: 0 - Uninitialized; 1 Initialized.
50+
* `init_flag` - Initialization mark. Available values: 0 - Uninitialized; 1 - Initialized.
5151
* `instance_name` - Name of mysql instance.
5252
* `instance_role` - Instance type. Supported values include: master - master instance, dr - disaster recovery instance, and ro - read-only instance.
5353
* `internet_host` - Public network domain name.
@@ -60,7 +60,7 @@ In addition to all arguments above, the following attributes are exported:
6060
* `project_id` - Project ID to which the current instance belongs.
6161
* `ro_instance_ids` - ID list of read-only type associated with the current instance.
6262
* `slave_sync_mode` - Data replication mode. 0 - Async replication; 1 - Semisync replication; 2 - Strongsync replication.
63-
* `status` - Instance status. Available values: 0 - Creating; 1 - Running; 4 - Isolating; 5 Isolated.
63+
* `status` - Instance status. Available values: 0 - Creating; 1 - Running; 4 - Isolating; 5 - Isolated.
6464
* `subnet_id` - ID of subnet to which the current instance belongs.
6565
* `volume_size` - Disk capacity (in GB).
6666
* `vpc_id` - ID of Virtual Private Cloud.

website/docs/r/mysql_instance.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ In addition to all arguments above, the following attributes are exported:
7676
* `internet_port` - Access port for public access.
7777
* `intranet_ip` - instance intranet IP.
7878
* `locked` - Indicates whether the instance is locked. 0 - No; 1 - Yes.
79-
* `status` - Instance status. Available values: 0 - Creating; 1 - Running; 4 - Isolating; 5 Isolated.
79+
* `status` - Instance status. Available values: 0 - Creating; 1 - Running; 4 - Isolating; 5 - Isolated.
8080
* `task_status` - Indicates which kind of operations is being executed.
8181

8282

website/docs/r/mysql_readonly_instance.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ In addition to all arguments above, the following attributes are exported:
5151

5252
* `intranet_ip` - instance intranet IP.
5353
* `locked` - Indicates whether the instance is locked. 0 - No; 1 - Yes.
54-
* `status` - Instance status. Available values: 0 - Creating; 1 - Running; 4 - Isolating; 5 Isolated.
54+
* `status` - Instance status. Available values: 0 - Creating; 1 - Running; 4 - Isolating; 5 - Isolated.
5555
* `task_status` - Indicates which kind of operations is being executed.
5656

5757

0 commit comments

Comments
 (0)