Skip to content

Commit

Permalink
v0.2.0: Refactor cluster resources (#38)
Browse files Browse the repository at this point in the history
* v0.2.0: Refactor cluster resources

- Consolidated create specs and update specs into configs
- Added some basic validation to Create and Update
- Updated and pruned examples
- Reran `go generate` to format examples and update docs
- Bumped version to 0.2.0
- Removed problematic wait_for_cluster_ready flag
- Simplified the schema for the cluster data source

* fixed cluster region sort

Regions in the cluster response are now sorted according to the
order they show up in the plan. If a cluster doesn't show up in
the plan, its ordinal defaults to 0 and it shows up first in the
output, where Terraform will rightfully complain.

* Fixed namespace for local provider resolution

* test cluster name updates

* bug fixes

* updated doc generator and reran
  • Loading branch information
erademacher authored Oct 26, 2022
1 parent 3f75d67 commit 167d18e
Show file tree
Hide file tree
Showing 26 changed files with 610 additions and 821 deletions.
4 changes: 0 additions & 4 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
_Add a description of the problem this PR addresses and an overview of how this PR works_.

**Checklist**

* [ ] I have added these changes to the changelog (or it's not applicable).
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
TEST?=$$(go list ./... | grep -v 'vendor')
HOSTNAME=registry.terraform.io
NAMESPACE=hashicorp
NAMESPACE=cockroachdb
NAME=cockroach
BINARY=terraform-provider-${NAME}
VERSION=0.1.1
VERSION=0.2.0
OS_ARCH=darwin_amd64

default: install
Expand Down
46 changes: 16 additions & 30 deletions docs/data-sources/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,25 @@ clusterSourceType Data Source
<!-- schema generated by tfplugindocs -->
## Schema

### Required

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

### Optional

- `config` (Attributes) (see [below for nested schema](#nestedatt--config))

### Read-Only

- `account_id` (String)
- `cloud_provider` (String)
- `cockroach_version` (String)
- `creator_id` (String)
- `dedicated` (Attributes) (see [below for nested schema](#nestedatt--dedicated))
- `id` (String) The ID of this resource.
- `name` (String) Name of cluster
- `operation_status` (String)
- `plan` (String)
- `regions` (Attributes List) (see [below for nested schema](#nestedatt--regions))
- `serverless` (Attributes) (see [below for nested schema](#nestedatt--serverless))
- `state` (String)

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

Optional:

- `dedicated` (Attributes) (see [below for nested schema](#nestedatt--config--dedicated))
- `serverless` (Attributes) (see [below for nested schema](#nestedatt--config--serverless))
<a id="nestedatt--dedicated"></a>
### Nested Schema for `dedicated`

<a id="nestedatt--config--dedicated"></a>
### Nested Schema for `config.dedicated`

Optional:
Read-Only:

- `disk_iops` (Number)
- `machine_type` (String)
Expand All @@ -55,16 +42,6 @@ Optional:
- `storage_gib` (Number)


<a id="nestedatt--config--serverless"></a>
### Nested Schema for `config.serverless`

Optional:

- `routing_id` (String)
- `spend_limit` (Number)



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

Expand All @@ -76,3 +53,12 @@ Read-Only:
- `ui_dns` (String)


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

Read-Only:

- `routing_id` (String)
- `spend_limit` (Number)


16 changes: 8 additions & 8 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ description: |-

```terraform
provider "cockroach" {
# Instructions for using the CockroachDB Cloud API
# https://www.cockroachlabs.com/docs/cockroachcloud/cloud-api.html
#
# Instructions for getting an API Key
# https://www.cockroachlabs.com/docs/cockroachcloud/console-access-management#api-access
#
# The Terraform provider requires an environment variable COCKROACH_API_KEY
# export COCKROACH_API_KEY="the API Key value here"
# Instructions for using the CockroachDB Cloud API
# https://www.cockroachlabs.com/docs/cockroachcloud/cloud-api.html
#
# Instructions for getting an API Key
# https://www.cockroachlabs.com/docs/cockroachcloud/console-access-management#api-access
#
# The Terraform provider requires an environment variable COCKROACH_API_KEY
# export COCKROACH_API_KEY="the API Key value here"
}
```

Expand Down
5 changes: 4 additions & 1 deletion docs/resources/allow_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ Allow list of IP range

- `cidr_ip` (String)
- `cidr_mask` (Number)
- `id` (String) The ID of this resource.
- `sql` (Boolean)
- `ui` (Boolean)

### Optional

- `name` (String)

### Read-Only

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


127 changes: 18 additions & 109 deletions docs/resources/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,155 +19,64 @@ Cluster Resource

- `cloud_provider` (String)
- `name` (String) Name of cluster
- `regions` (Attributes List) (see [below for nested schema](#nestedatt--regions))

### Optional

- `cockroach_version` (String)
- `create_spec` (Attributes) (see [below for nested schema](#nestedatt--create_spec))
- `update_spec` (Attributes) (see [below for nested schema](#nestedatt--update_spec))
- `wait_for_cluster_ready` (Boolean)
- `dedicated` (Attributes) (see [below for nested schema](#nestedatt--dedicated))
- `serverless` (Attributes) (see [below for nested schema](#nestedatt--serverless))

### Read-Only

- `account_id` (String)
- `config` (Attributes) (see [below for nested schema](#nestedatt--config))
- `creator_id` (String)
- `id` (String) The ID of this resource.
- `operation_status` (String)
- `plan` (String)
- `regions` (Attributes List) (see [below for nested schema](#nestedatt--regions))
- `state` (String)

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

Optional:

- `dedicated` (Attributes) (see [below for nested schema](#nestedatt--create_spec--dedicated))
- `serverless` (Attributes) (see [below for nested schema](#nestedatt--create_spec--serverless))

<a id="nestedatt--create_spec--dedicated"></a>
### Nested Schema for `create_spec.dedicated`

Optional:

- `cockroach_version` (String)
- `hardware` (Attributes) (see [below for nested schema](#nestedatt--create_spec--dedicated--hardware))
- `region_nodes` (Map of Number)

<a id="nestedatt--create_spec--dedicated--hardware"></a>
### Nested Schema for `create_spec.dedicated.hardware`

Optional:

- `disk_iops` (Number)
- `machine_spec` (Attributes) (see [below for nested schema](#nestedatt--create_spec--dedicated--hardware--machine_spec))
- `storage_gib` (Number)

<a id="nestedatt--create_spec--dedicated--hardware--machine_spec"></a>
### Nested Schema for `create_spec.dedicated.hardware.storage_gib`

Optional:

- `machine_type` (String)
- `num_virtual_cpus` (Number)




<a id="nestedatt--create_spec--serverless"></a>
### Nested Schema for `create_spec.serverless`

Optional:

- `regions` (List of String)
- `spend_limit` (Number)

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

Required:

<a id="nestedatt--update_spec"></a>
### Nested Schema for `update_spec`
- `name` (String)

Optional:

- `dedicated` (Attributes) (see [below for nested schema](#nestedatt--update_spec--dedicated))
- `serverless` (Attributes) (see [below for nested schema](#nestedatt--update_spec--serverless))
- `node_count` (Number)

<a id="nestedatt--update_spec--dedicated"></a>
### Nested Schema for `update_spec.dedicated`
Read-Only:

Optional:
- `sql_dns` (String)
- `ui_dns` (String)

- `hardware` (Attributes) (see [below for nested schema](#nestedatt--update_spec--dedicated--hardware))
- `region_nodes` (Map of Number)

<a id="nestedatt--update_spec--dedicated--hardware"></a>
### Nested Schema for `update_spec.dedicated.hardware`
<a id="nestedatt--dedicated"></a>
### Nested Schema for `dedicated`

Optional:

- `disk_iops` (Number)
- `machine_spec` (Attributes) (see [below for nested schema](#nestedatt--update_spec--dedicated--hardware--machine_spec))
- `storage_gib` (Number)

<a id="nestedatt--update_spec--dedicated--hardware--machine_spec"></a>
### Nested Schema for `update_spec.dedicated.hardware.storage_gib`

Optional:

- `machine_type` (String)
- `num_virtual_cpus` (Number)




<a id="nestedatt--update_spec--serverless"></a>
### Nested Schema for `update_spec.serverless`

Optional:

- `spend_limit` (Number)



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

Read-Only:

- `dedicated` (Attributes) (see [below for nested schema](#nestedatt--config--dedicated))
- `serverless` (Attributes) (see [below for nested schema](#nestedatt--config--serverless))

<a id="nestedatt--config--dedicated"></a>
### Nested Schema for `config.dedicated`
- `storage_gib` (Number)

Read-Only:

- `disk_iops` (Number)
- `machine_type` (String)
- `memory_gib` (Number)
- `num_virtual_cpus` (Number)
- `storage_gib` (Number)


<a id="nestedatt--config--serverless"></a>
### Nested Schema for `config.serverless`
<a id="nestedatt--serverless"></a>
### Nested Schema for `serverless`

Read-Only:
Optional:

- `routing_id` (String)
- `spend_limit` (Number)



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

Read-Only:

- `name` (String)
- `node_count` (Number)
- `sql_dns` (String)
- `ui_dns` (String)
- `routing_id` (String)


5 changes: 4 additions & 1 deletion docs/resources/sql_user.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ SQL user and password

### Required

- `id` (String) The ID of this resource.
- `name` (String)
- `password` (String, Sensitive)

### Read-Only

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


8 changes: 1 addition & 7 deletions examples/data-sources/cockroach_cluster/cockroach_cluster.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
variable cluster_id {
type = string
}

variable cloud_provider {
variable "cluster_id" {
type = string
}

data "cockroach_cluster" "cockroach" {
id = var.cluster_id
cloud_provider = var.cloud_provider
}

16 changes: 8 additions & 8 deletions examples/provider/provider.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
provider "cockroach" {
# Instructions for using the CockroachDB Cloud API
# https://www.cockroachlabs.com/docs/cockroachcloud/cloud-api.html
#
# Instructions for getting an API Key
# https://www.cockroachlabs.com/docs/cockroachcloud/console-access-management#api-access
#
# The Terraform provider requires an environment variable COCKROACH_API_KEY
# export COCKROACH_API_KEY="the API Key value here"
# Instructions for using the CockroachDB Cloud API
# https://www.cockroachlabs.com/docs/cockroachcloud/cloud-api.html
#
# Instructions for getting an API Key
# https://www.cockroachlabs.com/docs/cockroachcloud/console-access-management#api-access
#
# The Terraform provider requires an environment variable COCKROACH_API_KEY
# export COCKROACH_API_KEY="the API Key value here"
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
resource "cockroach_cluster" "cockroach" {
name = "cockroach-dedicated"
cloud_provider = "GCP"
create_spec = {
dedicated: {
region_nodes = {
"us-central1": 1
}
hardware = {
storage_gib = 15
machine_spec = {
machine_type = "n1-standard-4"
}
}
name = "cockroach-dedicated"
cloud_provider = "GCP"
dedicated = {
storage_gib = 15
machine_type = "n1-standard-4"
}
regions = [
{
name = "us-central1"
node_count = 1
}
}
]
}
Loading

0 comments on commit 167d18e

Please sign in to comment.