Skip to content

Commit

Permalink
refactor: setup muxing to allow migrating to plugin-framework (#531)
Browse files Browse the repository at this point in the history
This also re-implements one resource, `upcloud_network`, and one data-source, `upcloud_managed_object_storage_regions`, using the plugin framework.
  • Loading branch information
kangasta authored May 7, 2024
1 parent bdfbfe7 commit 397b01e
Show file tree
Hide file tree
Showing 99 changed files with 1,628 additions and 1,378 deletions.
52 changes: 35 additions & 17 deletions .ci/tools/go.mod
Original file line number Diff line number Diff line change
@@ -1,39 +1,57 @@
module github.com/UpCloudLtd/terraform-provider-upcloud/tools

go 1.20
go 1.21

require github.com/hashicorp/terraform-plugin-docs v0.13.0
toolchain go1.22.1

require github.com/hashicorp/terraform-plugin-docs v0.19.1

// Use patched version of terraform-plugin-docs until https://github.com/hashicorp/terraform-plugin-docs/issues/363 is resolved.
replace github.com/hashicorp/terraform-plugin-docs v0.19.1 => github.com/UpCloudLtd/terraform-plugin-docs v0.0.0-20240429132234-3a67351e4359

require (
github.com/BurntSushi/toml v1.2.1 // indirect
github.com/Kunde21/markdownfmt/v3 v3.1.0 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.1.1 // indirect
github.com/Masterminds/sprig/v3 v3.2.2 // indirect
github.com/Masterminds/semver/v3 v3.2.0 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
github.com/ProtonMail/go-crypto v1.1.0-alpha.2 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/armon/go-radix v1.0.0 // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/bmatcuk/doublestar/v4 v4.6.1 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/hashicorp/cli v1.1.6 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/hashicorp/hc-install v0.4.0 // indirect
github.com/hashicorp/terraform-exec v0.17.2 // indirect
github.com/hashicorp/terraform-json v0.14.0 // indirect
github.com/huandu/xstrings v1.3.2 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mitchellh/cli v1.1.4 // indirect
github.com/hashicorp/hc-install v0.6.4 // indirect
github.com/hashicorp/terraform-exec v0.20.0 // indirect
github.com/hashicorp/terraform-json v0.21.0 // indirect
github.com/huandu/xstrings v1.3.3 // indirect
github.com/imdario/mergo v0.3.15 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/posener/complete v1.2.3 // indirect
github.com/russross/blackfriday v1.6.0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/zclconf/go-cty v1.10.0 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/sys v0.15.0 // indirect
github.com/yuin/goldmark v1.7.1 // indirect
github.com/yuin/goldmark-meta v1.1.0 // indirect
github.com/zclconf/go-cty v1.14.4 // indirect
go.abhg.dev/goldmark/frontmatter v0.2.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df // indirect
golang.org/x/mod v0.16.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
gopkg.in/yaml.v2 v2.3.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
263 changes: 118 additions & 145 deletions .ci/tools/go.sum

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions docs/data-sources/hosts.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ page_title: "upcloud_hosts Data Source - terraform-provider-upcloud"
subcategory: Cloud
description: |-
Returns a list of available UpCloud hosts.
A host identifies the host server that virtual machines are run on.
Only hosts on private cloud to which the calling account has access to are available through this resource.
A host identifies the host server that virtual machines are run on.
Only hosts on private cloud to which the calling account has access to are available through this resource.
---

# upcloud_hosts (Data Source)
Expand Down Expand Up @@ -36,5 +36,3 @@ Read-Only:
- `description` (String)
- `host_id` (Number)
- `zone` (String)


2 changes: 0 additions & 2 deletions docs/data-sources/ip_addresses.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,3 @@ Read-Only:
- `ptr_record` (String)
- `server` (String)
- `zone` (String)


4 changes: 1 addition & 3 deletions docs/data-sources/kubernetes_cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ resource "local_file" "example" {
<!-- schema generated by tfplugindocs -->
## Schema

### Required
### Required Attributes

- `id` (String) Cluster ID.

Expand All @@ -100,5 +100,3 @@ resource "local_file" "example" {
- `host` (String) Hostname of the cluster API. Defined as URI.
- `kubeconfig` (String) Kubernetes config file contents for the cluster.
- `name` (String) Cluster name. Needs to be unique within the account.


6 changes: 2 additions & 4 deletions docs/data-sources/managed_database_mysql_sessions.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ data "upcloud_managed_database_mysql_sessions" "example" {
<!-- schema generated by tfplugindocs -->
## Schema

### Required
### Required Attributes

- `service` (String) Service's UUID for which these sessions belongs to

### Optional
### Optional Attributes

- `limit` (Number) Number of entries to receive at most.
- `offset` (Number) Offset for retrieved results based on sort order.
Expand All @@ -60,5 +60,3 @@ Read-Only:
- `query_duration` (String) The active query current duration.
- `state` (String) Current overall state of this service: active: The service is executing a query, idle: The service is waiting for a new client command.
- `usename` (String) Name of the user logged into this service.


4 changes: 1 addition & 3 deletions docs/data-sources/managed_database_opensearch_indices.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ data "upcloud_managed_database_opensearch_indices" "example" {
<!-- schema generated by tfplugindocs -->
## Schema

### Required
### Required Attributes

- `service` (String) Service's UUID for which these indices belongs to

Expand All @@ -59,5 +59,3 @@ Read-Only:
- `read_only_allow_delete` (Boolean) Indicates whether the index is in a read-only state that permits deletion of the entire index. This attribute can be automatically set to true in certain scenarios where the node disk space exceeds the flood stage.
- `size` (Number) Size of the index in bytes.
- `status` (String) Status of the index e.g. `open` or `closed`.


11 changes: 6 additions & 5 deletions docs/data-sources/managed_database_postgresql_sessions.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,18 @@ data "upcloud_managed_database_postgresql_sessions" "example" {
<!-- schema generated by tfplugindocs -->
## Schema

### Required
### Required Attributes

- `service` (String) Service's UUID for which these sessions belongs to

### Optional
### Optional Attributes

- `limit` (Number) Number of entries to receive at most.
- `offset` (Number) Offset for retrieved results based on sort order.
- `order` (String) Order by session field and sort retrieved results. Limited variables can be used for ordering.

### Blocks

- `sessions` (Block Set) Current sessions (see [below for nested schema](#nestedblock--sessions))

### Read-Only
Expand All @@ -50,7 +53,7 @@ data "upcloud_managed_database_postgresql_sessions" "example" {
<a id="nestedblock--sessions"></a>
### Nested Schema for `sessions`

Optional:
Optional Attributes:

- `backend_xid` (Number) Top-level transaction identifier of this service, if any.
- `backend_xmin` (Number) The current service's xmin horizon.
Expand All @@ -76,5 +79,3 @@ Read-Only:
- `usesysid` (Number) OID of the user logged into this service.
- `wait_event` (String) Wait event name if service is currently waiting.
- `wait_event_type` (String) The type of event for which the service is waiting, if any; otherwise NULL.


6 changes: 2 additions & 4 deletions docs/data-sources/managed_database_redis_sessions.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ data "upcloud_managed_database_redis_sessions" "example" {
<!-- schema generated by tfplugindocs -->
## Schema

### Required
### Required Attributes

- `service` (String) Service's UUID for which these sessions belongs to

### Optional
### Optional Attributes

- `limit` (Number) Number of entries to receive at most.
- `offset` (Number) Offset for retrieved results based on sort order.
Expand Down Expand Up @@ -69,5 +69,3 @@ Read-Only:
- `query` (String) The last executed command.
- `query_buffer` (Number) Query buffer length (0 means no query pending).
- `query_buffer_free` (Number) Free space of the query buffer (0 means the buffer is full).


4 changes: 1 addition & 3 deletions docs/data-sources/managed_object_storage_policies.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ data "upcloud_Managed_object_storage_policies" "this" {
<!-- schema generated by tfplugindocs -->
## Schema

### Required
### Required Attributes

- `service_uuid` (String) Service UUID.

Expand All @@ -51,5 +51,3 @@ Read-Only:
- `service_uuid` (String)
- `system` (Boolean)
- `updated_at` (String)


12 changes: 5 additions & 7 deletions docs/data-sources/managed_object_storage_regions.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@ data "upcloud_Managed_object_storage_regions" "this" {}
### Read-Only

- `id` (String) The ID of this resource.
- `regions` (Set of Object) (see [below for nested schema](#nestedatt--regions))
- `regions` (Block Set) (see [below for nested schema](#nestedblock--regions))

<a id="nestedatt--regions"></a>
<a id="nestedblock--regions"></a>
### Nested Schema for `regions`

Read-Only:

- `name` (String)
- `primary_zone` (String)
- `zones` (Set of String)


- `name` (String) Name of the region.
- `primary_zone` (String) Primary zone of the region.
- `zones` (Set of String) List of zones in the region.
4 changes: 1 addition & 3 deletions docs/data-sources/networks.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ data "upcloud_networks" "upcloud_by_zone" {
<!-- schema generated by tfplugindocs -->
## Schema

### Optional
### Optional Attributes

- `filter_name` (String) If specified, results will be filtered to match name using a regular expression
- `zone` (String) If specified, this data source will return only networks from this zone
Expand Down Expand Up @@ -73,5 +73,3 @@ Read-Only:

- `id` (String)
- `title` (String)


6 changes: 2 additions & 4 deletions docs/data-sources/storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ resource "upcloud_server" "example2" {
<!-- schema generated by tfplugindocs -->
## Schema

### Required
### Required Attributes

- `type` (String) Storage type (normal, backup, cdrom, template). Use 'favorite' as type to filter storages on the list of favorites.

### Optional
### Optional Attributes

- `access_type` (String) Storage access type (public, private)
- `most_recent` (Boolean) If more than one result is returned, use the most recent storage. This is only useful with private storages. Public storages might give unpredictable results.
Expand All @@ -84,5 +84,3 @@ resource "upcloud_server" "example2" {
- `state` (String) Current state of the storage
- `tier` (String) Storage tier in use
- `title` (String) Title of the storage


2 changes: 0 additions & 2 deletions docs/data-sources/tags.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,3 @@ Read-Only:
- `description` (String)
- `name` (String)
- `servers` (Set of String)


4 changes: 1 addition & 3 deletions docs/data-sources/zone.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Data-source is deprecated.
<!-- schema generated by tfplugindocs -->
## Schema

### Required
### Required Attributes

- `name` (String) Unique lablel for the zone

Expand All @@ -24,5 +24,3 @@ Data-source is deprecated.
- `description` (String) Meaningful text describing the zone
- `id` (String) The ID of this resource.
- `public` (Boolean) Indicates whether the zone is public


4 changes: 1 addition & 3 deletions docs/data-sources/zones.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ Data-source is deprecated.
<!-- schema generated by tfplugindocs -->
## Schema

### Optional
### Optional Attributes

- `filter_type` (String)

### Read-Only

- `id` (String) The ID of this resource.
- `zone_ids` (Set of String)


2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ provider "upcloud" {
<!-- schema generated by tfplugindocs -->
## Schema

### Optional
### Optional Attributes

- `password` (String) Password for UpCloud API user. Can also be configured using the `UPCLOUD_PASSWORD` environment variable.
- `request_timeout_sec` (Number) The duration (in seconds) that the provider waits for an HTTP request towards UpCloud API to complete. Defaults to 120 seconds
Expand Down
19 changes: 11 additions & 8 deletions docs/resources/firewall_rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ page_title: "upcloud_firewall_rules Resource - terraform-provider-upcloud"
subcategory: Servers
description: |-
This resource represents a generated list of UpCloud firewall rules.
Firewall rules are used in conjunction with UpCloud servers.
Each server has its own firewall rules.
The firewall is enabled on all network interfaces except ones attached to private virtual networks.
The maximum number of firewall rules per server is 1000.
Firewall rules are used in conjunction with UpCloud servers.
Each server has its own firewall rules.
The firewall is enabled on all network interfaces except ones attached to private virtual networks.
The maximum number of firewall rules per server is 1000.
---

# upcloud_firewall_rules (Resource)
Expand Down Expand Up @@ -61,15 +61,18 @@ resource "upcloud_firewall_rules" "example" {
<!-- schema generated by tfplugindocs -->
## Schema

### Required
### Required Attributes

- `server_id` (String) The unique id of the server to be protected the firewall rules

### Blocks

- `firewall_rule` (Block List, Min: 1, Max: 1000) A single firewall rule.
If used, IP address and port ranges must have both start and end values specified. These can be the same value if only one IP address or port number is specified.
Source and destination port numbers can only be set if the protocol is TCP or UDP.
The ICMP type may only be set if the protocol is ICMP.
Typical firewall rule should have "action", "direction", "protocol", "family" and at least one destination/source-address/port range.
The default rule can be created by providing only "action" and "direction" attributes. Default rule should be defined last. (see [below for nested schema](#nestedblock--firewall_rule))
- `server_id` (String) The unique id of the server to be protected the firewall rules

### Read-Only

Expand All @@ -78,12 +81,12 @@ resource "upcloud_firewall_rules" "example" {
<a id="nestedblock--firewall_rule"></a>
### Nested Schema for `firewall_rule`

Required:
Required Attributes:

- `action` (String) Action to take if the rule conditions are met
- `direction` (String) The direction of network traffic this rule will be applied to

Optional:
Optional Attributes:

- `comment` (String) Freeform comment string for the rule
- `destination_address_end` (String) The destination address range ends from this address
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/floating_ip_address.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ resource "upcloud_floating_ip_address" "my_new_floating_address" {
<!-- schema generated by tfplugindocs -->
## Schema

### Optional
### Optional Attributes

- `access` (String) Network access for the floating IP address. Supported value: `public`
- `family` (String) The address family of new IP address
Expand Down
Loading

0 comments on commit 397b01e

Please sign in to comment.