Skip to content

Commit

Permalink
Change developer tier to serverless tier (#22)
Browse files Browse the repository at this point in the history
Change developer tier to serverless tier
  • Loading branch information
zhangyangyu authored Oct 27, 2022
1 parent f4a295f commit a8cb869
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
6 changes: 3 additions & 3 deletions docs/resources/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ resource "tidbcloud_cluster" "dedicated_tier_cluster" {
}
}
resource "tidbcloud_cluster" "developer_tier_cluster" {
resource "tidbcloud_cluster" "serverless_tier_cluster" {
project_id = "fake_id"
name = "example2"
cluster_type = "DEVELOPER"
Expand Down Expand Up @@ -93,12 +93,12 @@ resource "tidbcloud_cluster" "developer_tier_cluster" {
Optional:

- `components` (Attributes) The components of the cluster.
- For a Developer Tier cluster, the components value can not be set. - For a Dedicated Tier cluster, the components value must be set. (see [below for nested schema](#nestedatt--config--components))
- For a Serverless Tier cluster, the components value can not be set. - For a Dedicated Tier cluster, the components value must be set. (see [below for nested schema](#nestedatt--config--components))
- `ip_access_list` (Attributes List) A list of IP addresses and Classless Inter-Domain Routing (CIDR) addresses that are allowed to access the TiDB Cloud cluster via [standard connection](https://docs.pingcap.com/tidbcloud/connect-to-tidb-cluster#connect-via-standard-connection). (see [below for nested schema](#nestedatt--config--ip_access_list))
- `paused` (Boolean) lag that indicates whether the cluster is paused. true means to pause the cluster, and false means to resume the cluster.
- The cluster can be paused only when the cluster_status is "AVAILABLE". - The cluster can be resumed only when the cluster_status is "PAUSED".
- `port` (Number) The TiDB port for connection. The port must be in the range of 1024-65535 except 10080, 4000 in default.
- For a Developer Tier cluster, only port 4000 is available.
- For a Serverless Tier cluster, only port 4000 is available.
- `root_password` (String) The root password to access the cluster. It must be 8-64 characters.

<a id="nestedatt--config--components"></a>
Expand Down
4 changes: 2 additions & 2 deletions docs/resources/restore.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ The status of the restore task.
Required:

- `components` (Attributes) The components of the cluster.
- For a Developer Tier cluster, the components value can not be set. - For a Dedicated Tier cluster, the components value must be set. (see [below for nested schema](#nestedatt--config--components))
- For a Serverless Tier cluster, the components value can not be set. - For a Dedicated Tier cluster, the components value must be set. (see [below for nested schema](#nestedatt--config--components))
- `root_password` (String) The root password to access the cluster. It must be 8-64 characters.

Optional:

- `ip_access_list` (Attributes List) A list of IP addresses and Classless Inter-Domain Routing (CIDR) addresses that are allowed to access the TiDB Cloud cluster via [standard connection](https://docs.pingcap.com/tidbcloud/connect-to-tidb-cluster#connect-via-standard-connection). (see [below for nested schema](#nestedatt--config--ip_access_list))
- `port` (Number) The TiDB port for connection. The port must be in the range of 1024-65535 except 10080, 4000 in default.
- For a Developer Tier cluster, only port 4000 is available.
- For a Serverless Tier cluster, only port 4000 is available.

<a id="nestedatt--config--components"></a>
### Nested Schema for `config.components`
Expand Down
2 changes: 1 addition & 1 deletion examples/resources/tidbcloud_cluster/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ resource "tidbcloud_cluster" "dedicated_tier_cluster" {
}
}

resource "tidbcloud_cluster" "developer_tier_cluster" {
resource "tidbcloud_cluster" "serverless_tier_cluster" {
project_id = "fake_id"
name = "example2"
cluster_type = "DEVELOPER"
Expand Down
10 changes: 5 additions & 5 deletions internal/provider/cluster_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (t clusterResourceType) GetSchema(ctx context.Context) (tfsdk.Schema, diag.
},
"port": {
MarkdownDescription: "The TiDB port for connection. The port must be in the range of 1024-65535 except 10080, 4000 in default.\n" +
" - For a Developer Tier cluster, only port 4000 is available.",
" - For a Serverless Tier cluster, only port 4000 is available.",
Optional: true,
Computed: true,
Type: types.Int64Type,
Expand All @@ -138,7 +138,7 @@ func (t clusterResourceType) GetSchema(ctx context.Context) (tfsdk.Schema, diag.
},
"components": {
MarkdownDescription: "The components of the cluster.\n" +
" - For a Developer Tier cluster, the components value can not be set." +
" - For a Serverless Tier cluster, the components value can not be set." +
" - For a Dedicated Tier cluster, the components value must be set.",
Optional: true,
Computed: true,
Expand Down Expand Up @@ -268,7 +268,7 @@ func (r clusterResource) Create(ctx context.Context, req resource.CreateRequest,
return
}

// for DEVELOPER cluster, components is not allowed. or plan and state may be inconsistent
// for Serverless cluster, components is not allowed. or plan and state may be inconsistent
if data.ClusterType == dev {
if data.Config.Components != nil {
resp.Diagnostics.AddError("Create Error", fmt.Sprintf("components is not allowed in %s cluster_type", dev))
Expand Down Expand Up @@ -460,11 +460,11 @@ func (r clusterResource) Update(ctx context.Context, req resource.UpdateRequest,
return
}

// DEVELOPER can not be changed now
// Severless can not be changed now
if data.ClusterType == dev {
resp.Diagnostics.AddError(
"Update error",
"Unable to update DEVELOPER cluster",
"Unable to update Serverless cluster",
)
return
}
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/restore_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (t restoreResourceType) GetSchema(ctx context.Context) (tfsdk.Schema, diag.
},
"port": {
MarkdownDescription: "The TiDB port for connection. The port must be in the range of 1024-65535 except 10080, 4000 in default.\n" +
" - For a Developer Tier cluster, only port 4000 is available.",
" - For a Serverless Tier cluster, only port 4000 is available.",
Optional: true,
Computed: true,
Type: types.Int64Type,
Expand All @@ -96,7 +96,7 @@ func (t restoreResourceType) GetSchema(ctx context.Context) (tfsdk.Schema, diag.
},
"components": {
MarkdownDescription: "The components of the cluster.\n" +
" - For a Developer Tier cluster, the components value can not be set." +
" - For a Serverless Tier cluster, the components value can not be set." +
" - For a Dedicated Tier cluster, the components value must be set.",
Required: true,
Attributes: tfsdk.SingleNestedAttributes(map[string]tfsdk.Attribute{
Expand Down
10 changes: 5 additions & 5 deletions internal/provider/testwithproject/cluster_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import (
// create dedicated cluster may cause cost, make sure you have enough balance
// update node_quantity is not tested for create dedicated tier needs too much time!
func TestAccClusterResource(t *testing.T) {
reg, _ := regexp.Compile(".*Unable to update DEVELOPER cluster.*")
reg, _ := regexp.Compile(".*Unable to update Serverless cluster.*")
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
// Create and Read dev-tier
// Create and Read serverless tier
{
Config: testAccDevClusterResourceConfig("developer-test"),
Config: testAccServerlessClusterResourceConfig("serverless-test"),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttrSet("tidbcloud_cluster.test", "id"),
resource.TestCheckResourceAttrSet("tidbcloud_cluster.test", "config.components.tidb.node_quantity"),
Expand All @@ -32,7 +32,7 @@ func TestAccClusterResource(t *testing.T) {
},
// Update is not supported
{
Config: testAccDevClusterResourceConfig("developer-test2"),
Config: testAccServerlessClusterResourceConfig("serverless-test2"),
ExpectError: reg,
},
// Delete testing automatically occurs in TestCase
Expand Down Expand Up @@ -67,7 +67,7 @@ func TestAccClusterResource(t *testing.T) {
})
}

func testAccDevClusterResourceConfig(name string) string {
func testAccServerlessClusterResourceConfig(name string) string {
return fmt.Sprintf(`
resource "tidbcloud_cluster" "test" {
project_id = %s
Expand Down

0 comments on commit a8cb869

Please sign in to comment.