Skip to content

Commit

Permalink
feat: hide component id (#20)
Browse files Browse the repository at this point in the history
* update

* feat: hide component id

* rm component type data sources
  • Loading branch information
cloudcarver authored Mar 18, 2024
1 parent b4cfbba commit c7646a9
Show file tree
Hide file tree
Showing 10 changed files with 284 additions and 452 deletions.
28 changes: 0 additions & 28 deletions docs/data-sources/component_type.md

This file was deleted.

43 changes: 24 additions & 19 deletions docs/resources/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,15 @@ Optional:

Required:

- `resource` (Attributes) The resource specification of the component (see [below for nested schema](#nestedatt--spec--compactor--resource))
- `default_node_group` (Attributes) The resource specification of the component (see [below for nested schema](#nestedatt--spec--compactor--default_node_group))

<a id="nestedatt--spec--compactor--resource"></a>
### Nested Schema for `spec.compactor.resource`
<a id="nestedatt--spec--compactor--default_node_group"></a>
### Nested Schema for `spec.compactor.default_node_group`

Required:

- `id` (String) The component type ID of the node
- `cpu` (String) The CPU of the node
- `memory` (String) The memory size in of the node

Optional:

Expand All @@ -68,14 +69,15 @@ Optional:

Required:

- `resource` (Attributes) The resource specification of the component (see [below for nested schema](#nestedatt--spec--compute--resource))
- `default_node_group` (Attributes) The resource specification of the component (see [below for nested schema](#nestedatt--spec--compute--default_node_group))

<a id="nestedatt--spec--compute--resource"></a>
### Nested Schema for `spec.compute.resource`
<a id="nestedatt--spec--compute--default_node_group"></a>
### Nested Schema for `spec.compute.default_node_group`

Required:

- `id` (String) The component type ID of the node
- `cpu` (String) The CPU of the node
- `memory` (String) The memory size in of the node

Optional:

Expand All @@ -88,14 +90,15 @@ Optional:

Required:

- `resource` (Attributes) The resource specification of the component (see [below for nested schema](#nestedatt--spec--frontend--resource))
- `default_node_group` (Attributes) The resource specification of the component (see [below for nested schema](#nestedatt--spec--frontend--default_node_group))

<a id="nestedatt--spec--frontend--resource"></a>
### Nested Schema for `spec.frontend.resource`
<a id="nestedatt--spec--frontend--default_node_group"></a>
### Nested Schema for `spec.frontend.default_node_group`

Required:

- `id` (String) The component type ID of the node
- `cpu` (String) The CPU of the node
- `memory` (String) The memory size in of the node

Optional:

Expand All @@ -108,18 +111,19 @@ Optional:

Required:

- `resource` (Attributes) The resource specification of the component (see [below for nested schema](#nestedatt--spec--meta--resource))
- `default_node_group` (Attributes) The resource specification of the component (see [below for nested schema](#nestedatt--spec--meta--default_node_group))

Optional:

- `etcd_meta_store` (Attributes) (see [below for nested schema](#nestedatt--spec--meta--etcd_meta_store))

<a id="nestedatt--spec--meta--resource"></a>
### Nested Schema for `spec.meta.resource`
<a id="nestedatt--spec--meta--default_node_group"></a>
### Nested Schema for `spec.meta.default_node_group`

Required:

- `id` (String) The component type ID of the node
- `cpu` (String) The CPU of the node
- `memory` (String) The memory size in of the node

Optional:

Expand All @@ -131,18 +135,19 @@ Optional:

Required:

- `resource` (Attributes) The resource specification of the component (see [below for nested schema](#nestedatt--spec--meta--etcd_meta_store--resource))
- `default_node_group` (Attributes) The resource specification of the component (see [below for nested schema](#nestedatt--spec--meta--etcd_meta_store--default_node_group))

Optional:

- `etcd_config` (String) The environment variable list of the etcd configuration

<a id="nestedatt--spec--meta--etcd_meta_store--resource"></a>
<a id="nestedatt--spec--meta--etcd_meta_store--default_node_group"></a>
### Nested Schema for `spec.meta.etcd_meta_store.etcd_config`

Required:

- `id` (String) The component type ID of the node
- `cpu` (String) The CPU of the node
- `memory` (String) The memory size in of the node

Optional:

Expand Down
4 changes: 0 additions & 4 deletions examples/data-sources/component_type/component_type.tf

This file was deleted.

53 changes: 34 additions & 19 deletions examples/resources/cluster/resource.tf
Original file line number Diff line number Diff line change
@@ -1,27 +1,42 @@
resource "risingwavecloud_cluster" "example" {
name = "dev"
version = "v1.3.0"
region = "us-east-2"
resourcev1 = {
resource "risingwavecloud_cluster" "my_cluster" {
region = "us-east-1"
name = "my_cluster"
version = "v1.8.0"
spec = {
compute = {
type = "p-1c2g"
replica = 1
default_node_group = {
cpu = "2"
memory = "8 GB"
replica = 1
}
}
compactor = {
type = "p-2c4g"
replica = 3
},
default_node_group = {
cpu = "1"
memory = "4 GB"
replica = 1
}
}
frontend = {
type = "p-1c1g"
replica = 1
},
default_node_group = {
cpu = "1"
memory = "4 GB"
replica = 1
}
}
meta = {
type = "p-1c1g"
replica = 1
},
etcd = {
type = "p-1c1g"
replica = 3
default_node_group = {
cpu = "1"
memory = "4 GB"
replica = 1
}
etcd_meta_store = {
default_node_group = {
cpu = "1"
memory = "4 GB"
replica = 1
}
}
}
}
}
81 changes: 35 additions & 46 deletions internal/cloudsdk/fake/fake.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,40 +185,37 @@ func (acc *FakeCloudClient) CreateClusterAwait(ctx context.Context, region strin
return &cluster, nil
}

func (acc *FakeCloudClient) GetTiers(ctx context.Context, _ string) ([]apigen_mgmt.Tier, error) {
debugFuncCaller()
var availableComponentTypes = []apigen_mgmt.AvailableComponentType{
{
Id: "p-1c4g",
Cpu: "1",
Memory: "4 GB",
Maximum: 3,
},
{
Id: "p-2c8g",
Cpu: "2",
Memory: "8 GB",
Maximum: 3,
},
}

nodes := []apigen_mgmt.AvailableComponentType{
{
Id: "p-1c4g",
Cpu: "1",
Memory: "4 GB",
Maximum: 3,
},
{
Id: "p-2c8g",
Cpu: "2",
Memory: "8 GB",
Maximum: 3,
},
}
func (acc *FakeCloudClient) GetTiers(ctx context.Context, _ string) ([]apigen_mgmt.Tier, error) {
return []apigen_mgmt.Tier{
{
Id: ptr.Ptr(apigen_mgmt.Standard),
AvailableMetaNodes: nodes,
AvailableComputeNodes: nodes,
AvailableCompactorNodes: nodes,
AvailableEtcdNodes: nodes,
AvailableFrontendNodes: nodes,
AvailableMetaNodes: availableComponentTypes,
AvailableComputeNodes: availableComponentTypes,
AvailableCompactorNodes: availableComponentTypes,
AvailableEtcdNodes: availableComponentTypes,
AvailableFrontendNodes: availableComponentTypes,
AllowEnableComputeNodeFileCache: true,
MaximumEtcdSizeGiB: 20,
},
}, nil
}

func (acc *FakeCloudClient) GetAvailableComponentTypes(ctx context.Context, region string, targetTier apigen_mgmt.TierId, component string) ([]apigen_mgmt.AvailableComponentType, error) {
debugFuncCaller()

tiers, err := acc.GetTiers(ctx, region)
if err != nil {
return nil, err
Expand Down Expand Up @@ -315,26 +312,11 @@ func (acc *FakeCloudClient) UpdateEtcdConfigByNsIDAwait(ctx context.Context, nsI
func reqResouceToClusterResource(reqResource *apigen_mgmt.TenantResourceRequest) apigen_mgmt.TenantResource {
return apigen_mgmt.TenantResource{
Components: apigen_mgmt.TenantResourceComponents{
Compute: &apigen_mgmt.ComponentResource{
ComponentTypeId: reqResource.Components.Compute.ComponentTypeId,
Replica: reqResource.Components.Compute.Replica,
},
Compactor: &apigen_mgmt.ComponentResource{
ComponentTypeId: reqResource.Components.Compactor.ComponentTypeId,
Replica: reqResource.Components.Compactor.Replica,
},
Frontend: &apigen_mgmt.ComponentResource{
ComponentTypeId: reqResource.Components.Frontend.ComponentTypeId,
Replica: reqResource.Components.Frontend.Replica,
},
Meta: &apigen_mgmt.ComponentResource{
ComponentTypeId: reqResource.Components.Meta.ComponentTypeId,
Replica: reqResource.Components.Meta.Replica,
},
Etcd: apigen_mgmt.ComponentResource{
ComponentTypeId: reqResource.Components.Etcd.ComponentTypeId,
Replica: reqResource.Components.Etcd.Replica,
},
Compute: componentReqToComponent(reqResource.Components.Compute),
Compactor: componentReqToComponent(reqResource.Components.Compactor),
Frontend: componentReqToComponent(reqResource.Components.Frontend),
Meta: componentReqToComponent(reqResource.Components.Meta),
Etcd: *componentReqToComponent(&reqResource.Components.Etcd),
},
EnableComputeFileCache: reqResource.EnableComputeFileCache,
EtcdVolumeSizeGiB: reqResource.EtcdVolumeSizeGiB,
Expand All @@ -344,8 +326,15 @@ func reqResouceToClusterResource(reqResource *apigen_mgmt.TenantResourceRequest)
}

func componentReqToComponent(req *apigen_mgmt.ComponentResourceRequest) *apigen_mgmt.ComponentResource {
return &apigen_mgmt.ComponentResource{
ComponentTypeId: req.ComponentTypeId,
Replica: req.Replica,
for _, c := range availableComponentTypes {
if c.Id == req.ComponentTypeId {
return &apigen_mgmt.ComponentResource{
ComponentTypeId: req.ComponentTypeId,
Replica: req.Replica,
Cpu: c.Cpu,
Memory: c.Memory,
}
}
}
return nil
}
34 changes: 0 additions & 34 deletions internal/provider/acc/data_source_component_type_test.go

This file was deleted.

Loading

0 comments on commit c7646a9

Please sign in to comment.