Skip to content

Commit

Permalink
Add dedicated region service (#147)
Browse files Browse the repository at this point in the history
---------

Signed-off-by: FingerLeader <[email protected]>
Co-authored-by: zhangyangyu <[email protected]>
  • Loading branch information
FingerLeader and zhangyangyu authored Dec 10, 2024
1 parent 44805ad commit d398e32
Show file tree
Hide file tree
Showing 34 changed files with 959 additions and 414 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ website/.bundle
website/build
website/node_modules
.vagrant/
.vscode/
*.backup
./*.tfstate
.terraform/
Expand Down
6 changes: 0 additions & 6 deletions GNUmakefile

This file was deleted.

13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
default: testacc

# Run acceptance tests
.PHONY: testacc
testacc:
TF_ACC=1 go test ./... -v $(TESTARGS) -timeout 120m

.PHONY: generate-mocks
generate-mocks: ## Generate mock objects
@echo "==> Generating mock objects"
go install github.com/vektra/mockery/[email protected]
# mockery --name TiDBCloudClient --recursive --output=mock --outpkg mock --filename api_client.go
mockery --name TiDBCloudDedicatedClient --recursive --output=mock --outpkg mock --filename dedicated_api_client.go
39 changes: 39 additions & 0 deletions docs/data-sources/dedicated_cloud_providers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "tidbcloud_dedicated_cloud_providers Data Source - terraform-provider-tidbcloud"
subcategory: ""
description: |-
dedicated cloud providers data source
---

# tidbcloud_dedicated_cloud_providers (Data Source)

dedicated cloud providers data source

## Example Usage

```terraform
variable "project_id" {
type = string
nullable = true
}
data "tidbcloud_dedicated_cloud_providers" "example" {
project_id = var.project_id
}
output "output" {
value = data.tidbcloud_dedicated_cloud_providers.example
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Optional

- `project_id` (String) The ID of the project. If not set, it will return the cloud providers that can be selected under the default project.

### Read-Only

- `cloud_providers` (List of String) The cloud providers.
40 changes: 40 additions & 0 deletions docs/data-sources/dedicated_region.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "tidbcloud_dedicated_region Data Source - terraform-provider-tidbcloud"
subcategory: ""
description: |-
dedicated region data source
---

# tidbcloud_dedicated_region (Data Source)

dedicated region data source

## Example Usage

```terraform
variable "region_id" {
type = string
nullable = false
}
data "tidbcloud_dedicated_region" "example" {
region_id = var.region_id
}
output "output" {
value = data.tidbcloud_dedicated_region.example
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `region_id` (String) The ID of the region.

### Read-Only

- `cloud_provider` (String) The cloud provider of the region.
- `display_name` (String) The display name of the region.
55 changes: 55 additions & 0 deletions docs/data-sources/dedicated_regions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "tidbcloud_dedicated_regions Data Source - terraform-provider-tidbcloud"
subcategory: ""
description: |-
dedicated regions data source
---

# tidbcloud_dedicated_regions (Data Source)

dedicated regions data source

## Example Usage

```terraform
variable "project_id" {
type = string
nullable = true
}
variable "cloud_provider" {
type = string
nullable = true
}
data "tidbcloud_dedicated_regions" "example" {
project_id = var.project_id
cloud_provider = var.cloud_provider
}
output "output" {
value = data.tidbcloud_dedicated_regions.example
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Optional

- `cloud_provider` (String) The cloud provider of the regions. If not set, it will return the regions that can be selected from all cloud providers.
- `project_id` (String) The ID of the project. If not set, it will return the regions that can be selected under the default project.

### Read-Only

- `regions` (Attributes List) The regions. (see [below for nested schema](#nestedatt--regions))

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

Read-Only:

- `cloud_provider` (String) The cloud provider of the region.
- `display_name` (String) The display name of the region.
- `region_id` (String) The ID of the region.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
variable "project_id" {
type = string
nullable = true
}

data "tidbcloud_dedicated_cloud_providers" "example" {
project_id = var.project_id
}

output "output" {
value = data.tidbcloud_dedicated_cloud_providers.example
}
12 changes: 12 additions & 0 deletions examples/data-sources/tidbcloud_dedicated_region/data-source.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
variable "region_id" {
type = string
nullable = false
}

data "tidbcloud_dedicated_region" "example" {
region_id = var.region_id
}

output "output" {
value = data.tidbcloud_dedicated_region.example
}
18 changes: 18 additions & 0 deletions examples/data-sources/tidbcloud_dedicated_regions/data-source.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
variable "project_id" {
type = string
nullable = true
}

variable "cloud_provider" {
type = string
nullable = true
}

data "tidbcloud_dedicated_regions" "example" {
project_id = var.project_id
cloud_provider = var.cloud_provider
}

output "output" {
value = data.tidbcloud_dedicated_regions.example
}
47 changes: 27 additions & 20 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/tidbcloud/terraform-provider-tidbcloud

go 1.21
go 1.23

require (
github.com/c4pt0r/go-tidbcloud-sdk-v1 v0.0.0-20240415110020-a27efb454da5
Expand All @@ -11,11 +11,13 @@ require (
github.com/go-openapi/validate v0.24.0
github.com/golang/mock v1.6.0
github.com/hashicorp/terraform-plugin-docs v0.19.4
github.com/hashicorp/terraform-plugin-framework v1.9.0
github.com/hashicorp/terraform-plugin-go v0.23.0
github.com/hashicorp/terraform-plugin-framework v1.13.0
github.com/hashicorp/terraform-plugin-go v0.25.0
github.com/hashicorp/terraform-plugin-log v0.9.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.35.0
github.com/icholy/digest v0.1.15
github.com/stretchr/testify v1.9.0
github.com/tidbcloud/tidbcloud-cli/pkg v0.0.0-20241125120734-8e2a11bc41c5
)

require (
Expand All @@ -32,6 +34,7 @@ require (
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/bmatcuk/doublestar/v4 v4.6.1 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
Expand All @@ -48,16 +51,18 @@ require (
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
github.com/hashicorp/go-hclog v1.6.3 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-plugin v1.6.0 // indirect
github.com/hashicorp/go-plugin v1.6.2 // indirect
github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/go-version v1.7.0 // indirect
github.com/hashicorp/hc-install v0.7.0 // indirect
github.com/hashicorp/hcl/v2 v2.20.1 // indirect
github.com/hashicorp/hc-install v0.9.0 // indirect
github.com/hashicorp/hcl/v2 v2.23.0 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform-exec v0.21.0 // indirect
github.com/hashicorp/terraform-json v0.22.1 // indirect
github.com/hashicorp/terraform-json v0.23.0 // indirect
github.com/hashicorp/terraform-plugin-testing v1.11.0 // indirect
github.com/hashicorp/terraform-registry-address v0.2.3 // indirect
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
Expand All @@ -76,32 +81,34 @@ require (
github.com/oklog/run v1.0.0 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/posener/complete v1.2.3 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.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
github.com/zclconf/go-cty v1.15.0 // indirect
go.abhg.dev/goldmark/frontmatter v0.2.0 // indirect
go.mongodb.org/mongo-driver v1.14.0 // indirect
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/crypto v0.29.0 // indirect
golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
golang.org/x/tools v0.13.0 // indirect
golang.org/x/mod v0.21.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/sync v0.9.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/text v0.20.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/grpc v1.63.2 // indirect
google.golang.org/protobuf v1.34.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect
google.golang.org/grpc v1.67.1 // indirect
google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit d398e32

Please sign in to comment.