Skip to content

Commit

Permalink
Fix review change requests
Browse files Browse the repository at this point in the history
- Add base schemas for datastore and database resources
- Add required fields for each datastore type in corresponding schema
instead of deleting unused fields
- Use Sensitive: true for password fields
  • Loading branch information
Gogen120 committed Apr 18, 2024
1 parent 7c67880 commit f28dd56
Show file tree
Hide file tree
Showing 11 changed files with 387 additions and 246 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ func filterConfigurationParametersByName(configurationParameters []dbaas.Configu
return filteredConfigurationParameters
}

func convertListParametersTypes(parameter []interface{}) []string {
parameterList := make([]string, len(parameter))
for i, value := range parameter {
func convertListParametersTypes(parameters []interface{}) []string {
parameterList := make([]string, len(parameters))
for i, value := range parameters {
parameterList[i] = convertFieldToStringByType(value)
}

Expand Down
154 changes: 154 additions & 0 deletions selectel/dbaas_base_schemas.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
package selectel

import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

func resourceDBaaSDatastoreV1BaseSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
},
"project_id": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"region": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"subnet_id": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"type_id": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"flavor_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: false,
ConflictsWith: []string{"flavor"},
},
"node_count": {
Type: schema.TypeInt,
Required: true,
},
"enabled": {
Type: schema.TypeBool,
Computed: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
"backup_retention_days": {
Type: schema.TypeInt,
Optional: true,
Description: "Number of days to retain backups.",
},
"connections": {
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"flavor": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
ForceNew: false,
ConflictsWith: []string{"flavor_id"},
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"vcpus": {
Type: schema.TypeInt,
Required: true,
},
"ram": {
Type: schema.TypeInt,
Required: true,
},
"disk": {
Type: schema.TypeInt,
Required: true,
},
},
},
},
"firewall": {
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"ips": {
Type: schema.TypeList,
Required: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
},
},
},
"config": {
Type: schema.TypeMap,
Optional: true,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"instances": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"role": {
Type: schema.TypeString,
Computed: true,
},
"floating_ip": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
}
}

func resourceDBaaSDatabaseV1BaseSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"project_id": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"region": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"datastore_id": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
}
}
57 changes: 0 additions & 57 deletions selectel/schema_selectel_dbaas_database_v1.go

This file was deleted.

Loading

0 comments on commit f28dd56

Please sign in to comment.