Skip to content

Commit 5347a98

Browse files
authored
feat(provider): [128090230] optmize resources doc and support to show timeouts content (#3563)
* add * add * add * add * add * add * add * add * add * add
1 parent c7af5a4 commit 5347a98

14 files changed

+133
-0
lines changed

.changelog/3563.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
provider: optmize resources doc and support to show `timeouts` content
3+
```

gendoc/main.go

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ func genDoc(product, dtype, fpath, name string, resource *schema.Resource) {
130130
"example": "",
131131
"description": "",
132132
"description_short": "",
133+
"timeouts": "",
133134
"import": "",
134135
}
135136

@@ -164,6 +165,61 @@ func genDoc(product, dtype, fpath, name string, resource *schema.Resource) {
164165
description = strings.TrimSpace(description[:importPos])
165166
}
166167

168+
if resource.Timeouts != nil {
169+
var timeoutMethods []string
170+
if resource.Timeouts.Create != nil {
171+
timeoutStr := resource.Timeouts.Create.String()
172+
if strings.Contains(timeoutStr, "m") {
173+
parts := strings.Split(timeoutStr, "m")
174+
if len(parts) > 0 {
175+
timeoutStr = parts[0] + "m"
176+
}
177+
}
178+
179+
timeoutMethods = append(timeoutMethods, fmt.Sprintf("* `create` - (Defaults to `%s`) Used when creating the resource.", timeoutStr))
180+
}
181+
182+
if resource.Timeouts.Read != nil {
183+
timeoutStr := resource.Timeouts.Read.String()
184+
if strings.Contains(timeoutStr, "m") {
185+
parts := strings.Split(timeoutStr, "m")
186+
if len(parts) > 0 {
187+
timeoutStr = parts[0] + "m"
188+
}
189+
}
190+
191+
timeoutMethods = append(timeoutMethods, fmt.Sprintf("* `read` - (Defaults to `%s`) Used when reading the resource.", timeoutStr))
192+
}
193+
194+
if resource.Timeouts.Update != nil {
195+
timeoutStr := resource.Timeouts.Update.String()
196+
if strings.Contains(timeoutStr, "m") {
197+
parts := strings.Split(timeoutStr, "m")
198+
if len(parts) > 0 {
199+
timeoutStr = parts[0] + "m"
200+
}
201+
}
202+
203+
timeoutMethods = append(timeoutMethods, fmt.Sprintf("* `update` - (Defaults to `%s`) Used when updating the resource.", timeoutStr))
204+
}
205+
206+
if resource.Timeouts.Delete != nil {
207+
timeoutStr := resource.Timeouts.Delete.String()
208+
if strings.Contains(timeoutStr, "m") {
209+
parts := strings.Split(timeoutStr, "m")
210+
if len(parts) > 0 {
211+
timeoutStr = parts[0] + "m"
212+
}
213+
}
214+
215+
timeoutMethods = append(timeoutMethods, fmt.Sprintf("* `delete` - (Defaults to `%s`) Used when deleting the resource.", timeoutStr))
216+
}
217+
218+
if len(timeoutMethods) > 0 {
219+
data["timeouts"] = strings.TrimSpace(fmt.Sprintf("The `timeouts` block allows you to specify [timeouts](https://developer.hashicorp.com/terraform/language/resources/syntax#operation-timeouts) for certain actions:\n\n%s", strings.Join(timeoutMethods, "\n")))
220+
}
221+
}
222+
167223
pos := strings.Index(description, "\nExample Usage\n")
168224
if pos != -1 {
169225
data["example"] = formatHCL(description[pos+15:])

gendoc/template.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ In addition to all arguments above, the following attributes are exported:
3030
3131
{{.attributes}}
3232
{{end}}
33+
{{- if and .timeouts (ne .timeouts "")}}
34+
## Timeouts
35+
36+
{{.timeouts}}
37+
{{- end}}
3338
{{if ne .import ""}}
3439
## Import
3540

website/docs/r/as_start_instance_refresh.html.markdown

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,9 @@ In addition to all arguments above, the following attributes are exported:
6262
* `id` - ID of the resource.
6363

6464

65+
## Timeouts
66+
67+
The `timeouts` block allows you to specify [timeouts](https://developer.hashicorp.com/terraform/language/resources/syntax#operation-timeouts) for certain actions:
68+
69+
* `create` - (Defaults to `5m`) Used when creating the resource.
6570

website/docs/r/cynosdb_cluster_slave_zone.html.markdown

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,13 @@ In addition to all arguments above, the following attributes are exported:
131131
* `id` - ID of the resource.
132132

133133

134+
## Timeouts
135+
136+
The `timeouts` block allows you to specify [timeouts](https://developer.hashicorp.com/terraform/language/resources/syntax#operation-timeouts) for certain actions:
137+
138+
* `create` - (Defaults to `5m`) Used when creating the resource.
139+
* `update` - (Defaults to `5m`) Used when updating the resource.
140+
* `delete` - (Defaults to `5m`) Used when deleting the resource.
134141

135142
## Import
136143

website/docs/r/instance.html.markdown

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,11 @@ In addition to all arguments above, the following attributes are exported:
409409
* `public_ipv6_addresses` - The public IPv6 address to which the instance is bound.
410410
* `uuid` - Globally unique ID of the instance.
411411

412+
## Timeouts
413+
414+
The `timeouts` block allows you to specify [timeouts](https://developer.hashicorp.com/terraform/language/resources/syntax#operation-timeouts) for certain actions:
415+
416+
* `create` - (Defaults to `15m`) Used when creating the resource.
412417

413418
## Import
414419

website/docs/r/instance_set.html.markdown

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,12 @@ In addition to all arguments above, the following attributes are exported:
118118
* `instance_status` - Current status of the instance.
119119
* `public_ip` - Public IP of the instance.
120120

121+
## Timeouts
122+
123+
The `timeouts` block allows you to specify [timeouts](https://developer.hashicorp.com/terraform/language/resources/syntax#operation-timeouts) for certain actions:
124+
125+
* `create` - (Defaults to `10m`) Used when creating the resource.
126+
* `read` - (Defaults to `10m`) Used when reading the resource.
127+
* `update` - (Defaults to `10m`) Used when updating the resource.
128+
* `delete` - (Defaults to `10m`) Used when deleting the resource.
121129

website/docs/r/kubernetes_addon.html.markdown

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ In addition to all arguments above, the following attributes are exported:
5454
* `phase` - Status of addon.
5555
* `reason` - Reason of addon failed.
5656

57+
## Timeouts
58+
59+
The `timeouts` block allows you to specify [timeouts](https://developer.hashicorp.com/terraform/language/resources/syntax#operation-timeouts) for certain actions:
60+
61+
* `create` - (Defaults to `3m`) Used when creating the resource.
62+
* `update` - (Defaults to `3m`) Used when updating the resource.
63+
* `delete` - (Defaults to `3m`) Used when deleting the resource.
5764

5865
## Import
5966

website/docs/r/kubernetes_node_pool.html.markdown

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,12 @@ In addition to all arguments above, the following attributes are exported:
461461
* `node_count` - The total node count.
462462
* `status` - Status of the node pool.
463463

464+
## Timeouts
465+
466+
The `timeouts` block allows you to specify [timeouts](https://developer.hashicorp.com/terraform/language/resources/syntax#operation-timeouts) for certain actions:
467+
468+
* `create` - (Defaults to `30m`) Used when creating the resource.
469+
* `update` - (Defaults to `30m`) Used when updating the resource.
464470

465471
## Import
466472

website/docs/r/mongodb_instance_backup.html.markdown

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,9 @@ In addition to all arguments above, the following attributes are exported:
3636
* `id` - ID of the resource.
3737

3838

39+
## Timeouts
40+
41+
The `timeouts` block allows you to specify [timeouts](https://developer.hashicorp.com/terraform/language/resources/syntax#operation-timeouts) for certain actions:
42+
43+
* `create` - (Defaults to `3m`) Used when creating the resource.
3944

0 commit comments

Comments
 (0)