Skip to content

Commit ef53108

Browse files
committed
check for space before symbol
1 parent 147ec04 commit ef53108

16 files changed

+62
-55
lines changed

gendoc/main.go

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func main() {
3737

3838
fname, _ := vProvider.FileLine(0)
3939
fpath := filepath.Dir(fname)
40-
Message("generating doc from: %s\n", fpath)
40+
message("generating doc from: %s\n", fpath)
4141

4242
// document for DataSources
4343
for k, v := range provider.DataSourcesMap {
@@ -68,16 +68,16 @@ func genIdx(fpath string) {
6868
sources := []Index{}
6969

7070
fname := "provider.go"
71-
Message("[START]get description from file: %s\n", fname)
71+
message("[START]get description from file: %s\n", fname)
7272
description, err := getFileDescription(fmt.Sprintf("%s/%s", fpath, fname))
7373
if err != nil {
74-
Message("[SKIP!]get description failed, skip: %s", err)
74+
message("[SKIP!]get description failed, skip: %s", err)
7575
return
7676
}
7777

7878
description = strings.TrimSpace(description)
7979
if description == "" {
80-
Message("[SKIP!]description empty, skip: %s\n", fname)
80+
message("[SKIP!]description empty, skip: %s\n", fname)
8181
return
8282
}
8383

@@ -86,7 +86,7 @@ func genIdx(fpath string) {
8686
resources = strings.TrimSpace(description[pos+16:])
8787
// description = strings.TrimSpace(description[:pos])
8888
} else {
89-
Message("[SKIP!]resource list missing, skip: %s\n", fname)
89+
message("[SKIP!]resource list missing, skip: %s\n", fname)
9090
return
9191
}
9292

@@ -98,7 +98,7 @@ func genIdx(fpath string) {
9898
}
9999
if strings.HasPrefix(v, " ") {
100100
if index.Name == "" {
101-
Message("[FAIL!]no resource name found: %s", v)
101+
message("[FAIL!]no resource name found: %s", v)
102102
return
103103
}
104104
index.Resources = append(index.Resources, []string{vv, vv[len(cloudMark)+1:]})
@@ -145,19 +145,19 @@ func genIdx(fpath string) {
145145
fname = fmt.Sprintf("%s/../%s.erb", docRoot, cloudMark)
146146
fd, err := os.OpenFile(fname, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
147147
if err != nil {
148-
Message("[FAIL!]open file %s failed: %s", fname, err)
148+
message("[FAIL!]open file %s failed: %s", fname, err)
149149
os.Exit(1)
150150
}
151151

152152
defer fd.Close()
153153
t := template.Must(template.New("t").Parse(idxTPL))
154154
err = t.Execute(fd, data)
155155
if err != nil {
156-
Message("[FAIL!]write file %s failed: %s", fname, err)
156+
message("[FAIL!]write file %s failed: %s", fname, err)
157157
os.Exit(1)
158158
}
159159

160-
Message("[SUCC.]write doc to file success: %s", fname)
160+
message("[SUCC.]write doc to file success: %s", fname)
161161
}
162162

163163
// genDoc generating doc for data source and resource
@@ -175,17 +175,17 @@ func genDoc(dtype, fpath, name string, resource *schema.Resource) {
175175
}
176176

177177
fname := fmt.Sprintf("%s_%s_%s.go", dtype, cloudMarkShort, data["resource"])
178-
Message("[START]get description from file: %s\n", fname)
178+
message("[START]get description from file: %s\n", fname)
179179

180180
description, err := getFileDescription(fmt.Sprintf("%s/%s", fpath, fname))
181181
if err != nil {
182-
Message("[FAIL!]get description failed: %s", err)
182+
message("[FAIL!]get description failed: %s", err)
183183
os.Exit(1)
184184
}
185185

186186
description = strings.TrimSpace(description)
187187
if description == "" {
188-
Message("[FAIL!]description empty: %s\n", fname)
188+
message("[FAIL!]description empty: %s\n", fname)
189189
os.Exit(1)
190190
}
191191

@@ -200,7 +200,7 @@ func genDoc(dtype, fpath, name string, resource *schema.Resource) {
200200
data["example"] = formatHCL(description[pos+15:])
201201
description = strings.TrimSpace(description[:pos])
202202
} else {
203-
Message("[FAIL!]example usage missing: %s\n", fname)
203+
message("[FAIL!]example usage missing: %s\n", fname)
204204
os.Exit(1)
205205
}
206206

@@ -219,17 +219,17 @@ func genDoc(dtype, fpath, name string, resource *schema.Resource) {
219219

220220
for k, v := range resource.Schema {
221221
if v.Description == "" {
222-
Message("[FAIL!]description for '%s' is missing: %s\n", k, fname)
222+
message("[FAIL!]description for '%s' is missing: %s\n", k, fname)
223223
os.Exit(1)
224224
} else {
225225
checkDescription(k, v.Description)
226226
}
227227
if dtype == "data_source" && v.ForceNew {
228-
Message("[FAIL!]Don't set ForceNew on data source: '%s'", k)
228+
message("[FAIL!]Don't set ForceNew on data source: '%s'", k)
229229
os.Exit(1)
230230
}
231231
if v.Required && v.Optional {
232-
Message("[FAIL!]Don't set Required and Optional at the same time: '%s'", k)
232+
message("[FAIL!]Don't set Required and Optional at the same time: '%s'", k)
233233
os.Exit(1)
234234
}
235235
if v.Required {
@@ -290,19 +290,19 @@ func genDoc(dtype, fpath, name string, resource *schema.Resource) {
290290
fname = fmt.Sprintf("%s/%s/%s.html.markdown", docRoot, dtype[0:1], data["resource"])
291291
fd, err := os.OpenFile(fname, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
292292
if err != nil {
293-
Message("[FAIL!]open file %s failed: %s", fname, err)
293+
message("[FAIL!]open file %s failed: %s", fname, err)
294294
os.Exit(1)
295295
}
296296

297297
defer fd.Close()
298298
t := template.Must(template.New("t").Parse(docTPL))
299299
err = t.Execute(fd, data)
300300
if err != nil {
301-
Message("[FAIL!]write file %s failed: %s", fname, err)
301+
message("[FAIL!]write file %s failed: %s", fname, err)
302302
os.Exit(1)
303303
}
304304

305-
Message("[SUCC.]write doc to file success: %s", fname)
305+
message("[SUCC.]write doc to file success: %s", fname)
306306
}
307307

308308
// getAttributes get attributes from schema
@@ -427,28 +427,35 @@ func checkDescription(k, s string) {
427427
}
428428

429429
if strings.TrimLeft(s, " ") != s {
430-
Message("[FAIL!]There is space on the left of description: '%s': '%s'", k, s)
430+
message("[FAIL!]There is space on the left of description: '%s': '%s'", k, s)
431431
os.Exit(1)
432432
}
433433

434434
if strings.TrimRight(s, " ") != s {
435-
Message("[FAIL!]There is space on the right of description: '%s': '%s'", k, s)
435+
message("[FAIL!]There is space on the right of description: '%s': '%s'", k, s)
436436
os.Exit(1)
437437
}
438438

439439
if s[len(s)-1] != '.' && s[len(s)-1] != ':' {
440-
Message("[FAIL!]There is no ending charset(.|:) on the description: '%s': '%s'", k, s)
440+
message("[FAIL!]There is no ending charset(. or :) on the description: '%s': '%s'", k, s)
441441
os.Exit(1)
442442
}
443443

444-
if c := ContainsBigSymbol(s); c != "" {
445-
Message("[FAIL!]There is unexcepted symbol: '%s' on the description: '%s': '%s'", c, k, s)
444+
if c := containsBigSymbol(s); c != "" {
445+
message("[FAIL!]There is unexcepted symbol '%s' on the description: '%s': '%s'", c, k, s)
446446
os.Exit(1)
447447
}
448+
449+
for _, v := range []string{",", ".", ";", ":", "?", "!"} {
450+
if strings.Contains(s, " "+v) {
451+
message("[FAIL!]There is space before '%s' on the description: '%s': '%s'", v, k, s)
452+
os.Exit(1)
453+
}
454+
}
448455
}
449456

450-
// ContainsBigSymbol returns the Big symbol if found
451-
func ContainsBigSymbol(s string) string {
457+
// containsBigSymbol returns the Big symbol if found
458+
func containsBigSymbol(s string) string {
452459
m := bigSymbol.FindStringSubmatch(s)
453460
if len(m) > 0 {
454461
return m[0]
@@ -457,8 +464,8 @@ func ContainsBigSymbol(s string) string {
457464
return ""
458465
}
459466

460-
// Message print color message
461-
func Message(msg string, v ...interface{}) {
467+
// message print color message
468+
func message(msg string, v ...interface{}) {
462469
if strings.Contains(msg, "FAIL") {
463470
color.Red(fmt.Sprintf(msg, v...))
464471
} else if strings.Contains(msg, "SUCC") {

tencentcloud/data_source_tc_cam_policies.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func dataSourceTencentCloudCamPolicies() *schema.Resource {
4343
"description": {
4444
Type: schema.TypeString,
4545
Optional: true,
46-
Description: "The description of the CAM policy .",
46+
Description: "The description of the CAM policy.",
4747
},
4848
"type": {
4949
Type: schema.TypeInt,

tencentcloud/data_source_tc_cam_saml_providers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func dataSourceTencentCloudCamSAMLProviders() *schema.Resource {
3333
"description": {
3434
Type: schema.TypeString,
3535
Optional: true,
36-
Description: "The description of the CAM SAML provider .",
36+
Description: "The description of the CAM SAML provider.",
3737
},
3838
"result_output_file": {
3939
Type: schema.TypeString,

tencentcloud/data_source_tc_clb_listener_rules.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func dataSourceTencentCloudClbListenerRules() *schema.Resource {
5959
Type: schema.TypeString,
6060
Optional: true,
6161
ValidateFunc: validateAllowedStringValue(CLB_LISTENER_SCHEDULER),
62-
Description: "Scheduling method of the forwarding rule of thr CLB listener, and available values include 'WRR' , 'IP HASH' and 'LEAST_CONN'. The default is 'WRR'.",
62+
Description: "Scheduling method of the forwarding rule of thr CLB listener, and available values include 'WRR', 'IP HASH' and 'LEAST_CONN'. The default is 'WRR'.",
6363
},
6464
"result_output_file": {
6565
Type: schema.TypeString,

tencentcloud/data_source_tc_clb_listeners.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func dataSourceTencentCloudClbListeners() *schema.Resource {
124124
"certificate_ca_id": {
125125
Type: schema.TypeString,
126126
Computed: true,
127-
Description: "Id of the client certificate. It must be set when SSLMode is 'mutual'. NOTES: only supported by listeners of 'HTTPS' and 'TCP_SSL' protocol .",
127+
Description: "Id of the client certificate. It must be set when SSLMode is 'mutual'. NOTES: only supported by listeners of 'HTTPS' and 'TCP_SSL' protocol.",
128128
},
129129
"session_expire_time": {
130130
Type: schema.TypeInt,

tencentcloud/data_source_tc_mysql_instance.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func dataSourceTencentCloudMysqlInstance() *schema.Resource {
5050
Type: schema.TypeInt,
5151
Optional: true,
5252
ValidateFunc: validateAllowedIntValue([]int{0, 1}),
53-
Description: "Pay type of instance, 0: prepay, 1: postpay. Now only supported postpay.",
53+
Description: "Pay type of instance, 0: prepay, 1: postpay. NOTES: Only prepay is supported.",
5454
},
5555
"instance_name": {
5656
Type: schema.TypeString,
@@ -146,7 +146,7 @@ func dataSourceTencentCloudMysqlInstance() *schema.Resource {
146146
"auto_renew_flag": {
147147
Type: schema.TypeInt,
148148
Computed: true,
149-
Description: "Auto renew flag, works for prepay instance.",
149+
Description: "Auto renew flag. NOTES: Only supported prepay instance.",
150150
},
151151
"engine_version": {
152152
Type: schema.TypeString,
@@ -221,7 +221,7 @@ func dataSourceTencentCloudMysqlInstance() *schema.Resource {
221221
"pay_type": {
222222
Type: schema.TypeInt,
223223
Computed: true,
224-
Description: "Pay type of instance, 0: prepay, 1: postpay. Now only supported postpay.",
224+
Description: "Pay type of instance, 0: prepay, 1: postpay. NOTES: Only prepay is supported.",
225225
},
226226
"create_time": {
227227
Type: schema.TypeString,
@@ -231,7 +231,7 @@ func dataSourceTencentCloudMysqlInstance() *schema.Resource {
231231
"dead_line_time": {
232232
Type: schema.TypeString,
233233
Computed: true,
234-
Description: "Expire date of instance, works for prepay instance.",
234+
Description: "Expire date of instance. NOTES: Only supported prepay instance.",
235235
},
236236
"master_instance_id": {
237237
Type: schema.TypeString,

tencentcloud/resource_tc_kubernetes_scale_worker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func resourceTencentCloudTkeScaleWorker() *schema.Resource {
8888
Elem: &schema.Resource{
8989
Schema: tkeCvmState(),
9090
},
91-
Description: "An information list of kubernetes cluster 'WORKER' . Each element contains the following attributes:",
91+
Description: "An information list of kubernetes cluster 'WORKER'. Each element contains the following attributes:",
9292
},
9393
},
9494
}

tencentcloud/resource_tc_mysql_instance.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,21 +64,21 @@ func TencentMsyqlBasicInfo() map[string]*schema.Schema {
6464
Optional: true,
6565
ValidateFunc: validateAllowedIntValue([]int{MysqlPayByMonth, MysqlPayByUse}),
6666
Default: MysqlPayByUse,
67-
Description: "Pay type of instance, 0: prepay, 1: postpay. Now only supported postpay.",
67+
Description: "Pay type of instance, 0: prepay, 1: postpay. NOTES: Only supported prepay instance.",
6868
},
6969
"period": {
7070
Type: schema.TypeInt,
7171
Optional: true,
7272
Default: 1,
7373
ValidateFunc: validateAllowedIntValue(MYSQL_AVAILABLE_PERIOD),
74-
Description: "Period of instance, works for prepay instance.",
74+
Description: "Period of instance. NOTES: Only supported prepay instance.",
7575
},
7676
"auto_renew_flag": {
7777
Type: schema.TypeInt,
7878
Optional: true,
7979
ValidateFunc: validateAllowedIntValue([]int{0, 1}),
8080
Default: 0,
81-
Description: "Auto renew flag, works for prepay instance.",
81+
Description: "Auto renew flag. NOTES: Only supported prepay instance.",
8282
},
8383
"intranet_port": {
8484
Type: schema.TypeInt,

website/docs/d/cam_policies.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ The following arguments are supported:
2828

2929
* `policy_id` - (Required) Id of CAM policy to be queried to be queried.
3030
* `create_mode` - (Optional) Mode of creation of policy strategy. 1 means policy was created with console, and 2 means it was created by strategies.
31-
* `description` - (Optional) The description of the CAM policy .
31+
* `description` - (Optional) The description of the CAM policy.
3232
* `name` - (Optional) Name of the CAM policy to be queried.
3333
* `result_output_file` - (Optional) Used to save results.
3434
* `type` - (Optional) Type of the policy strategy. 1 means customer strategy and 2 means preset strategy.

website/docs/d/cam_saml_providers.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ data "tencentcloud_cam_saml_providers" "foo" {
2222

2323
The following arguments are supported:
2424

25-
* `description` - (Optional) The description of the CAM SAML provider .
25+
* `description` - (Optional) The description of the CAM SAML provider.
2626
* `name` - (Optional) Name of the CAM SAML provider to be queried.
2727
* `result_output_file` - (Optional) Used to save results.
2828

website/docs/d/clb_listener_rules.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ The following arguments are supported:
3232
* `domain` - (Optional) Domain name of the forwarding rule to be queried.
3333
* `result_output_file` - (Optional) Used to save results.
3434
* `rule_id` - (Optional) Id of the forwarding rule to be queried.
35-
* `scheduler` - (Optional) Scheduling method of the forwarding rule of thr CLB listener, and available values include 'WRR' , 'IP HASH' and 'LEAST_CONN'. The default is 'WRR'.
35+
* `scheduler` - (Optional) Scheduling method of the forwarding rule of thr CLB listener, and available values include 'WRR', 'IP HASH' and 'LEAST_CONN'. The default is 'WRR'.
3636
* `url` - (Optional) Url of the forwarding rule to be queried.
3737

3838
## Attributes Reference

website/docs/d/clb_listeners.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ The following arguments are supported:
3636
In addition to all arguments above, the following attributes are exported:
3737

3838
* `listener_list` - A list of listeners of cloud load balancers. Each element contains the following attributes:
39-
* `certificate_ca_id` - Id of the client certificate. It must be set when SSLMode is 'mutual'. NOTES: only supported by listeners of 'HTTPS' and 'TCP_SSL' protocol .
39+
* `certificate_ca_id` - Id of the client certificate. It must be set when SSLMode is 'mutual'. NOTES: only supported by listeners of 'HTTPS' and 'TCP_SSL' protocol.
4040
* `certificate_id` - Id of the server certificate. It must be set when protocol is 'HTTPS' or 'TCP_SSL'. NOTES: only supported by listeners of 'HTTPS' and 'TCP_SSL' protocol and must be set when it is available.
4141
* `certificate_ssl_mode` - Type of certificate, and available values inclue 'UNIDIRECTIONAL', 'MUTUAL'. NOTES: Only supports listeners of 'HTTPS' and 'TCP_SSL' protocol and must be set when it is available.
4242
* `clb_id` - Id of the CLB.

website/docs/d/mysql_instance.html.markdown

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ The following arguments are supported:
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.
33-
* `pay_type` - (Optional) Pay type of instance, 0: prepay, 1: postpay. Now only supported postpay.
33+
* `pay_type` - (Optional) Pay type of instance, 0: prepay, 1: postpay. NOTES: Only prepay is supported.
3434
* `result_output_file` - (Optional) Used to store results.
3535
* `security_group_id` - (Optional) Security groups ID of instance.
3636
* `status` - (Optional) Instance status. Available values: 0 - Creating; 1 - Running; 4 - Isolating; 5 - Isolated.
@@ -43,10 +43,10 @@ The following arguments are supported:
4343
In addition to all arguments above, the following attributes are exported:
4444

4545
* `instance_list` - A list of instances. Each element contains the following attributes:
46-
* `auto_renew_flag` - Auto renew flag, works for prepay instance.
46+
* `auto_renew_flag` - Auto renew flag. NOTES: Only supported prepay instance.
4747
* `cpu_core_count` - CPU count.
4848
* `create_time` - The time at which a instance is created.
49-
* `dead_line_time` - Expire date of instance, works for prepay instance.
49+
* `dead_line_time` - Expire date of instance. NOTES: Only supported prepay instance.
5050
* `device_type` - Supported instance model.HA - high available version; Basic - basic version.
5151
* `dr_instance_ids` - ID list of disaster-recovory type associated with the current instance.
5252
* `engine_version` - The version number of the database engine to use. Supported versions include 5.5/5.6/5.7.
@@ -61,7 +61,7 @@ In addition to all arguments above, the following attributes are exported:
6161
* `master_instance_id` - Indicates the master instance ID of recovery instances.
6262
* `memory_size` - Memory size (in MB).
6363
* `mysql_id` - Instance ID, such as cdb-c1nl9rpv. It is identical to the instance ID displayed in the database console page.
64-
* `pay_type` - Pay type of instance, 0: prepay, 1: postpay. Now only supported postpay.
64+
* `pay_type` - Pay type of instance, 0: prepay, 1: postpay. NOTES: Only prepay is supported.
6565
* `project_id` - Project ID to which the current instance belongs.
6666
* `ro_instance_ids` - ID list of read-only type associated with the current instance.
6767
* `slave_sync_mode` - Data replication mode. 0 - Async replication; 1 - Semisync replication; 2 - Strongsync replication.

website/docs/r/kubernetes_scale_worker.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ The `worker_config` object supports the following:
8989

9090
In addition to all arguments above, the following attributes are exported:
9191

92-
* `worker_instances_list` - An information list of kubernetes cluster 'WORKER' . Each element contains the following attributes:
92+
* `worker_instances_list` - An information list of kubernetes cluster 'WORKER'. Each element contains the following attributes:
9393
* `failed_reason` - Information of the cvm when it is failed.
9494
* `instance_id` - ID of the cvm.
9595
* `instance_role` - Role of the cvm.

website/docs/r/mysql_instance.html.markdown

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ The following arguments are supported:
5252
* `mem_size` - (Required) Memory size (in MB).
5353
* `root_password` - (Required) Password of root account. This parameter can be specified when you purchase master instances, but it should be ignored when you purchase read-only instances or disaster recovery instances.
5454
* `volume_size` - (Required) Disk size (in GB).
55-
* `auto_renew_flag` - (Optional) Auto renew flag, works for prepay instance.
55+
* `auto_renew_flag` - (Optional) Auto renew flag. NOTES: Only supported prepay instance.
5656
* `availability_zone` - (Optional, ForceNew) Indicates which availability zone will be used.
5757
* `engine_version` - (Optional, ForceNew) The version number of the database engine to use. Supported versions include 5.5/5.6/5.7, and default is 5.7.
5858
* `first_slave_zone` - (Optional, ForceNew) Zone information about first slave instance.
5959
* `internet_service` - (Optional) Indicates whether to enable the access to an instance from public network: 0 - No, 1 - Yes.
6060
* `intranet_port` - (Optional) Public access port, rang form 1024 to 65535 and default value is 3306.
6161
* `parameters` - (Optional) List of parameters to use.
62-
* `pay_type` - (Optional, ForceNew) Pay type of instance, 0: prepay, 1: postpay. Now only supported postpay.
63-
* `period` - (Optional) Period of instance, works for prepay instance.
62+
* `pay_type` - (Optional, ForceNew) Pay type of instance, 0: prepay, 1: postpay. NOTES: Only supported prepay instance.
63+
* `period` - (Optional) Period of instance. NOTES: Only supported prepay instance.
6464
* `project_id` - (Optional) Project ID, default value is 0.
6565
* `second_slave_zone` - (Optional, ForceNew) Zone information about second slave instance.
6666
* `security_groups` - (Optional) Security groups to use.

0 commit comments

Comments
 (0)