Skip to content

Commit

Permalink
Moved DBaaS resource schemas to the separate files
Browse files Browse the repository at this point in the history
  • Loading branch information
Gogen120 committed Feb 27, 2024
1 parent eba0d88 commit 577d855
Show file tree
Hide file tree
Showing 32 changed files with 610 additions and 995 deletions.
11 changes: 0 additions & 11 deletions selectel/dbaas.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,14 +366,3 @@ func validateDatastoreType(ctx context.Context, expectedDatastoreTypeEngines []s

return nil
}

// Databases

func dbaasDatabaseV1LocaleDiffSuppressFunc(k, old, new string, d *schema.ResourceData) bool {
// The default locale value - C is the same as null value, so we need to suppress
if old == "C" && new == "" {
return true
}

return false
}
43 changes: 1 addition & 42 deletions selectel/resource_selectel_dbaas_database_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,48 +30,7 @@ func resourceDBaaSDatabaseV1() *schema.Resource {
Update: schema.DefaultTimeout(60 * time.Minute),
Delete: schema.DefaultTimeout(60 * time.Minute),
},
Schema: 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,
},
"owner_id": {
Type: schema.TypeString,
Optional: true,
},
"lc_collate": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
DiffSuppressFunc: dbaasDatabaseV1LocaleDiffSuppressFunc,
},
"lc_ctype": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
DiffSuppressFunc: dbaasDatabaseV1LocaleDiffSuppressFunc,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
},
Schema: resourceDBaaSPostgreSQLDatabaseV1Schema(),
}
}

Expand Down
147 changes: 1 addition & 146 deletions selectel/resource_selectel_dbaas_datastore_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/selectel/dbaas-go"
waiters "github.com/terraform-providers/terraform-provider-selectel/selectel/waiters/dbaas"
)
Expand All @@ -31,151 +30,7 @@ func resourceDBaaSDatastoreV1() *schema.Resource {
Update: schema.DefaultTimeout(60 * time.Minute),
Delete: schema.DefaultTimeout(60 * time.Minute),
},
Schema: 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,
},
},
},
},
"pooler": {
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"mode": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{
"session",
"transaction",
"statement",
}, false),
},
"size": {
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,
},
},
},
},
},
"restore": {
Type: schema.TypeSet,
Optional: true,
ForceNew: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"datastore_id": {
Type: schema.TypeString,
Optional: true,
},
"target_time": {
Type: schema.TypeString,
Optional: true,
},
},
},
},
"config": {
Type: schema.TypeMap,
Optional: true,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"redis_password": {
Type: schema.TypeString,
Optional: true,
},
},
Schema: resourceDBaaSDatastoreV1Schema(),
}
}

Expand Down
32 changes: 1 addition & 31 deletions selectel/resource_selectel_dbaas_extension_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,37 +29,7 @@ func resourceDBaaSExtensionV1() *schema.Resource {
Update: schema.DefaultTimeout(60 * time.Minute),
Delete: schema.DefaultTimeout(60 * time.Minute),
},
Schema: map[string]*schema.Schema{
"project_id": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"region": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"available_extension_id": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"datastore_id": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"database_id": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
},
Schema: resourceDBaaSPostgreSQLExtensionV1Schema(),
}
}

Expand Down
32 changes: 1 addition & 31 deletions selectel/resource_selectel_dbaas_grant_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,37 +29,7 @@ func resourceDBaaSGrantV1() *schema.Resource {
Update: schema.DefaultTimeout(60 * time.Minute),
Delete: schema.DefaultTimeout(60 * time.Minute),
},
Schema: map[string]*schema.Schema{
"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,
},
"database_id": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"user_id": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
},
Schema: resourceDBaaSGrantV1Schema(),
}
}

Expand Down
51 changes: 1 addition & 50 deletions selectel/resource_selectel_dbaas_kafka_acl_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/selectel/dbaas-go"
waiters "github.com/terraform-providers/terraform-provider-selectel/selectel/waiters/dbaas"
)
Expand All @@ -31,55 +30,7 @@ func resourceDBaaSKafkaACLV1() *schema.Resource {
Update: schema.DefaultTimeout(60 * time.Minute),
Delete: schema.DefaultTimeout(60 * time.Minute),
},
Schema: map[string]*schema.Schema{
"datastore_id": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"region": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"pattern": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"pattern_type": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
"literal",
"prefixed",
"all",
}, false),
},
"user_id": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"allow_read": {
Type: schema.TypeBool,
Required: true,
},
"allow_write": {
Type: schema.TypeBool,
Required: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
"project_id": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
},
Schema: resourceDBaaSKafkaACKV1Schema(),
}
}

Expand Down
Loading

0 comments on commit 577d855

Please sign in to comment.