Skip to content

Commit 370efd0

Browse files
committed
misc: use tfplugindocs to generate docs.
Rather than constructing docs manually and running them through a linter, use tfplugindocs to generate them. We move examples into the examples/ directory, and override default templates in the templates/ directory. We also add new make targets to generate docs and check that the generated docs match the code. Resolves #490.
1 parent e872fb4 commit 370efd0

File tree

95 files changed

+2265
-1631
lines changed

Some content is hidden

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

95 files changed

+2265
-1631
lines changed

Makefile

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Build variables
2+
SHELL := /usr/bin/env bash
23
VERSION ?= $(shell cat $(CURDIR)/VERSION)
34
BINARY ?= terraform-provider-oxide_$(VERSION)
45
BINARY_LOCATION ?= bin/$(BINARY)
@@ -47,9 +48,18 @@ test:
4748
@ echo "-> Running unit tests for $(BINARY)"
4849
@ go test $(TEST_PACKAGE) $(TEST_ARGS) $(TESTUNITARGS)
4950

51+
.PHONY: docs
52+
docs:
53+
@ $(GOBIN)/tfplugindocs generate
54+
55+
.PHONY: check-docs
56+
check-docs:
57+
@ $(GOBIN)/tfplugindocs generate
58+
@ if ! git diff --exit-code docs; then echo 'Generated docs have changed. Re-generate with `make docs`.'; fi
59+
5060
## Lints all of the source files
5161
.PHONY: lint
52-
lint: golangci-lint tfproviderdocs terrafmt tfproviderlint # configfmt
62+
lint: golangci-lint tfproviderdocs terrafmt tfproviderlint check-docs # configfmt
5363

5464
.PHONY: tfproviderlint
5565
tfproviderlint: tools
@@ -117,6 +127,7 @@ VERSION_GOLANGCILINT:=v1.64.8
117127
VERSION_TFPROVIDERDOCS:=v0.12.1
118128
VERSION_TERRAFMT:=v0.5.4
119129
VERSION_TFPROVIDERLINT:=v0.31.0
130+
VERSION_TFPLUGINDOCS:=v0.22.0
120131
VERSION_WHATSIT:=053446d
121132

122133
tools: $(GOBIN)/golangci-lint $(GOBIN)/tfproviderdocs $(GOBIN)/terrafmt $(GOBIN)/tfproviderlint
@@ -170,3 +181,6 @@ $(GOBIN)/whatsit: $(VERSION_DIR)/.version-whatsit-$(VERSION_WHATSIT) | $(GOBIN)
170181
@ echo "-> Installing whatsit..."
171182
@ cargo install --git ssh://[email protected]/oxidecomputer/whatsit.git#$(VERSION_WHATSIT) --branch main --root ./
172183

184+
$(GOBIN)/tfplugindocs:
185+
@ echo "-> Installing tfplugindocs..."
186+
@ go install github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs@$(VERSION_TFPLUGINDOCS)
Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
23
page_title: "oxide_anti_affinity_group Data Source - terraform-provider-oxide"
4+
subcategory: ""
5+
description: |-
6+
37
---
48

59
# oxide_anti_affinity_group (Data Source)
610

7-
Retrieve information about a specified anti-affinity group.
11+
812

913
## Example Usage
1014

11-
```hcl
15+
```terraform
1216
data "oxide_anti_affinity_group" "example" {
1317
project_name = "my-project"
1418
name = "my-group"
@@ -18,6 +22,7 @@ data "oxide_anti_affinity_group" "example" {
1822
}
1923
```
2024

25+
<!-- schema generated by tfplugindocs -->
2126
## Schema
2227

2328
### Required
@@ -27,31 +32,21 @@ data "oxide_anti_affinity_group" "example" {
2732

2833
### Optional
2934

30-
- `timeouts` (Attribute, Optional) (see [below for nested schema](#nestedatt--timeouts))
35+
- `timeouts` (Attributes) (see [below for nested schema](#nestedatt--timeouts))
3136

3237
### Read-Only
3338

34-
- `description` (String) Description of the anti-affinity group.
39+
- `description` (String) Description for the anti-affinity group.
3540
- `failure_domain` (String) Describes the scope of affinity for the purposes of co-location.
36-
- `id` (String) Unique, immutable, system-controlled identifier for the anti-affinity group.
41+
- `id` (String) Unique, immutable, system-controlled identifier of the anti-affinity group.
3742
- `policy` (String) Affinity policy used to describe what to do when a request cannot be satisfied.
3843
- `project_id` (String) ID of the project that contains the anti-affinity group.
3944
- `time_created` (String) Timestamp of when this anti-affinity group was created.
4045
- `time_modified` (String) Timestamp of when this anti-affinity group was last modified.
4146

4247
<a id="nestedatt--timeouts"></a>
43-
4448
### Nested Schema for `timeouts`
4549

4650
Optional:
4751

48-
- `read` (String, Default `10m`)
49-
50-
<a id="nestedobject--digest"></a>
51-
52-
### Nested Schema for `digest`
53-
54-
Read-Only:
55-
56-
- `type` (String) Digest type.
57-
- `value` (String) Digest type value.
52+
- `read` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).

docs/data-sources/floating_ip.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "oxide_floating_ip Data Source - terraform-provider-oxide"
4+
subcategory: ""
5+
description: |-
6+
7+
---
8+
9+
# oxide_floating_ip (Data Source)
10+
11+
12+
13+
## Example Usage
14+
15+
```terraform
16+
data "oxide_floating_ip" "example" {
17+
project_name = "my-project"
18+
name = "app-ingress"
19+
}
20+
```
21+
22+
<!-- schema generated by tfplugindocs -->
23+
## Schema
24+
25+
### Required
26+
27+
- `name` (String) Unique, mutable, user-controlled identifier for the floating IP.
28+
- `project_name` (String) Project name where this floating IP is located.
29+
30+
### Optional
31+
32+
- `timeouts` (Attributes) (see [below for nested schema](#nestedatt--timeouts))
33+
34+
### Read-Only
35+
36+
- `description` (String) Human-readable free-form text about the floating IP.
37+
- `id` (String) Unique, immutable, system-controlled identifier for the floating IP.
38+
- `instance_id` (String) Instance ID that this floating IP is attached to, if presently attached.
39+
- `ip` (String) IP address for this floating IP. If unset an IP address will be chosen from the given ip_pool_id.
40+
- `ip_pool_id` (String) IP pool ID to allocate this floating IP from. If unset the silo's default IP pool is used.
41+
- `project_id` (String) Project ID where this floating IP is located.
42+
- `time_created` (String) Timestamp when this floating IP was created.
43+
- `time_modified` (String) Timestamp when this floating IP was last modified.
44+
45+
<a id="nestedatt--timeouts"></a>
46+
### Nested Schema for `timeouts`
47+
48+
Optional:
49+
50+
- `read` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours). Read operations occur during any refresh or planning operation when refresh is enabled.

docs/data-sources/oxide_image.md renamed to docs/data-sources/image.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
23
page_title: "oxide_image Data Source - terraform-provider-oxide"
4+
subcategory: ""
5+
description: |-
6+
37
---
48

59
# oxide_image (Data Source)
610

7-
Retrieve information about a specified image.
11+
812

913
## Example Usage
1014

11-
```hcl
15+
```terraform
1216
data "oxide_image" "example" {
1317
project_name = "my-project"
1418
name = "my-image"
@@ -18,6 +22,7 @@ data "oxide_image" "example" {
1822
}
1923
```
2024

25+
<!-- schema generated by tfplugindocs -->
2126
## Schema
2227

2328
### Required
@@ -26,32 +31,31 @@ data "oxide_image" "example" {
2631

2732
### Optional
2833

29-
- `project_name` (String) Name of the project that contains the image. Necessary if the image visibility is scoped to a single project.
30-
- `timeouts` (Attribute, Optional) (see [below for nested schema](#nestedatt--timeouts))
34+
- `project_name` (String) Name of the project which contains the images
35+
- `timeouts` (Attributes) (see [below for nested schema](#nestedatt--timeouts))
3136

3237
### Read-Only
3338

3439
- `block_size` (Number) Block size in bytes.
3540
- `description` (String) Description of the image.
36-
- `digest` (Object) Hash of the image contents, if applicable (see [below for nested schema](#nestedobject--digest)).
37-
- `id` (String) Unique, immutable, system-controlled identifier for the image.
41+
- `digest` (Attributes) Hash of the image contents, if applicable. (see [below for nested schema](#nestedatt--digest))
42+
- `id` (String) Unique, immutable, system-controlled identifier of the image.
3843
- `os` (String) OS image distribution.
39-
- `project_id` (String) ID of the project that contains the image.
44+
- `project_id` (String) ID of the project which contains the images
4045
- `size` (Number) Size of the image in bytes.
4146
- `time_created` (String) Timestamp of when this image was created.
4247
- `time_modified` (String) Timestamp of when this image was last modified.
4348
- `version` (String) Version of the OS.
4449

4550
<a id="nestedatt--timeouts"></a>
46-
4751
### Nested Schema for `timeouts`
4852

4953
Optional:
5054

51-
- `read` (String, Default `10m`)
55+
- `read` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
5256

53-
<a id="nestedobject--digest"></a>
5457

58+
<a id="nestedatt--digest"></a>
5559
### Nested Schema for `digest`
5660

5761
Read-Only:

docs/data-sources/oxide_images.md renamed to docs/data-sources/images.md

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,60 @@
11
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
23
page_title: "oxide_images Data Source - terraform-provider-oxide"
4+
subcategory: ""
5+
description: |-
6+
37
---
48

59
# oxide_images (Data Source)
610

7-
Retrieve a list of all images belonging to a silo or project.
11+
812

913
## Example Usage
1014

11-
```hcl
15+
```terraform
1216
data "oxide_images" "example" {}
1317
```
1418

19+
<!-- schema generated by tfplugindocs -->
1520
## Schema
1621

1722
### Optional
1823

19-
- `timeouts` (Attribute, Optional) (see [below for nested schema](#nestedatt--timeouts))
20-
- `project_id` (String) ID of the project that contains the images.
24+
- `project_id` (String) ID of the project which contains the images
25+
- `timeouts` (Attributes) (see [below for nested schema](#nestedatt--timeouts))
2126

2227
### Read-Only
2328

24-
- `images` (List of Object) A list of all global images (see [below for nested schema](#nestedatt--images))
2529
- `id` (String) The ID of this resource.
30+
- `images` (Attributes List) (see [below for nested schema](#nestedatt--images))
2631

2732
<a id="nestedatt--timeouts"></a>
28-
2933
### Nested Schema for `timeouts`
3034

3135
Optional:
3236

33-
- `read` (String, Default `10m`)
37+
- `read` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
3438

35-
<a id="nestedatt--images"></a>
3639

40+
<a id="nestedatt--images"></a>
3741
### Nested Schema for `images`
3842

3943
Read-Only:
4044

4145
- `block_size` (Number) Block size in bytes.
4246
- `description` (String) Description of the image.
43-
- `digest` (Object) Hash of the image contents, if applicable (see [below for nested schema](#nestedobject--digest)).
44-
- `os` (String) OS image distribution.
45-
- `id` (String) Unique, immutable, system-controlled identifier for the image.
47+
- `digest` (Attributes) Hash of the image contents, if applicable. (see [below for nested schema](#nestedatt--images--digest))
48+
- `id` (String) Unique, immutable, system-controlled identifier of the image.
4649
- `name` (String) Name of the image.
50+
- `os` (String) OS image distribution.
4751
- `size` (Number) Size of the image in bytes.
4852
- `time_created` (String) Timestamp of when this image was created.
4953
- `time_modified` (String) Timestamp of when this image was last modified.
5054
- `version` (String) Version of the OS.
5155

52-
### Nested Schema for `digest`
56+
<a id="nestedatt--images--digest"></a>
57+
### Nested Schema for `images.digest`
5358

5459
Read-Only:
5560

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "oxide_instance_external_ips Data Source - terraform-provider-oxide"
4+
subcategory: ""
5+
description: |-
6+
7+
---
8+
9+
# oxide_instance_external_ips (Data Source)
10+
11+
12+
13+
## Example Usage
14+
15+
```terraform
16+
data "oxide_instance_external_ips" "example" {
17+
instance_id = "c1dee930-a8e4-11ed-afa1-0242ac120002"
18+
}
19+
```
20+
21+
<!-- schema generated by tfplugindocs -->
22+
## Schema
23+
24+
### Required
25+
26+
- `instance_id` (String) ID of the instance to which the external IPs belong to.
27+
28+
### Optional
29+
30+
- `timeouts` (Attributes) (see [below for nested schema](#nestedatt--timeouts))
31+
32+
### Read-Only
33+
34+
- `external_ips` (Attributes List) (see [below for nested schema](#nestedatt--external_ips))
35+
- `id` (String) The ID of this resource.
36+
37+
<a id="nestedatt--timeouts"></a>
38+
### Nested Schema for `timeouts`
39+
40+
Optional:
41+
42+
- `read` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
43+
44+
45+
<a id="nestedatt--external_ips"></a>
46+
### Nested Schema for `external_ips`
47+
48+
Read-Only:
49+
50+
- `ip` (String) External IP address.
51+
- `kind` (String) Kind of external IP address.

docs/data-sources/ip_pool.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "oxide_ip_pool Data Source - terraform-provider-oxide"
4+
subcategory: ""
5+
description: |-
6+
7+
---
8+
9+
# oxide_ip_pool (Data Source)
10+
11+
12+
13+
## Example Usage
14+
15+
```terraform
16+
data "oxide_ip_pool" "example" {
17+
name = "default"
18+
timeouts = {
19+
read = "1m"
20+
}
21+
}
22+
```
23+
24+
<!-- schema generated by tfplugindocs -->
25+
## Schema
26+
27+
### Required
28+
29+
- `name` (String) Name of the IP pool.
30+
31+
### Optional
32+
33+
- `timeouts` (Attributes) (see [below for nested schema](#nestedatt--timeouts))
34+
35+
### Read-Only
36+
37+
- `description` (String) Description for the IP pool.
38+
- `id` (String) Unique, immutable, system-controlled identifier of the IP pool.
39+
- `is_default` (Boolean) If a pool is the default for a silo, floating IPs and instance ephemeral IPs will come from that pool when no other pool is specified. There can be at most one default for a given silo.
40+
- `time_created` (String) Timestamp of when this IP pool was created.
41+
- `time_modified` (String) Timestamp of when this IP pool was last modified.
42+
43+
<a id="nestedatt--timeouts"></a>
44+
### Nested Schema for `timeouts`
45+
46+
Optional:
47+
48+
- `read` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).

0 commit comments

Comments
 (0)