Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: raise errors on data consistency errors #545

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions internal/service/cloud/data_sources.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const (

func DataSourceHosts() *schema.Resource {
return &schema.Resource{
EnableLegacyTypeSystemApplyErrors: true,
EnableLegacyTypeSystemPlanErrors: true,
Description: `Returns a list of available UpCloud hosts.
A host identifies the host server that virtual machines are run on.
Only hosts on private cloud to which the calling account has access to are available through this resource.`,
Expand All @@ -30,6 +32,8 @@ func DataSourceHosts() *schema.Resource {
Type: schema.TypeSet,
Computed: true,
Elem: &schema.Resource{
EnableLegacyTypeSystemApplyErrors: true,
EnableLegacyTypeSystemPlanErrors: true,
Schema: map[string]*schema.Schema{
"host_id": {
Type: schema.TypeInt,
Expand Down Expand Up @@ -86,8 +90,10 @@ func dataSourceHostsRead(ctx context.Context, d *schema.ResourceData, meta inter

func DataSourceZone() *schema.Resource {
return &schema.Resource{
Description: "Data-source is deprecated.",
ReadContext: resourceZoneRead,
EnableLegacyTypeSystemApplyErrors: true,
EnableLegacyTypeSystemPlanErrors: true,
Description: "Data-source is deprecated.",
ReadContext: resourceZoneRead,
Schema: map[string]*schema.Schema{
"name": {
Description: "Unique lablel for the zone",
Expand Down Expand Up @@ -148,8 +154,10 @@ func resourceZoneRead(ctx context.Context, d *schema.ResourceData, meta interfac

func DataSourceZones() *schema.Resource {
return &schema.Resource{
Description: "Data-source is deprecated.",
ReadContext: dataSourceZonesRead,
EnableLegacyTypeSystemApplyErrors: true,
EnableLegacyTypeSystemPlanErrors: true,
Description: "Data-source is deprecated.",
ReadContext: dataSourceZonesRead,
Schema: map[string]*schema.Schema{
"zone_ids": {
Type: schema.TypeSet,
Expand Down
10 changes: 7 additions & 3 deletions internal/service/database/data_source_opensearch_indices.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ import (

func DataSourceOpenSearchIndices() *schema.Resource {
return &schema.Resource{
Description: "OpenSearch indices",
ReadContext: dataSourceOpenSearchIndicesRead,
EnableLegacyTypeSystemApplyErrors: true,
EnableLegacyTypeSystemPlanErrors: true,
Description: "OpenSearch indices",
ReadContext: dataSourceOpenSearchIndicesRead,
Schema: map[string]*schema.Schema{
"indices": {
Description: "Available indices for OpenSearch",
Expand All @@ -35,7 +37,9 @@ func DataSourceOpenSearchIndices() *schema.Resource {

func schemaOpenSearchIndex() *schema.Resource {
return &schema.Resource{
Description: "OpenSearch index",
EnableLegacyTypeSystemApplyErrors: true,
EnableLegacyTypeSystemPlanErrors: true,
Description: "OpenSearch index",
Schema: map[string]*schema.Schema{
"create_time": {
Description: "Timestamp indicating the creation time of the index.",
Expand Down
30 changes: 21 additions & 9 deletions internal/service/database/data_source_sessions.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ import (

func DataSourceSessionsMySQL() *schema.Resource {
return &schema.Resource{
Description: "Current sessions of a MySQL managed database",
ReadContext: dataSourceSessionsMySQLRead,
EnableLegacyTypeSystemApplyErrors: true,
EnableLegacyTypeSystemPlanErrors: true,
Description: "Current sessions of a MySQL managed database",
ReadContext: dataSourceSessionsMySQLRead,
Schema: utils.JoinSchemas(
schemaDataSourceSessionsCommon(),
schemaDataSourceSessionsMySQL(),
Expand All @@ -26,8 +28,10 @@ func DataSourceSessionsMySQL() *schema.Resource {

func DataSourceSessionsPostgreSQL() *schema.Resource {
return &schema.Resource{
Description: "Current sessions of a PostgreSQL managed database",
ReadContext: dataSourceSessionsPostgreSQLRead,
EnableLegacyTypeSystemApplyErrors: true,
EnableLegacyTypeSystemPlanErrors: true,
Description: "Current sessions of a PostgreSQL managed database",
ReadContext: dataSourceSessionsPostgreSQLRead,
Schema: utils.JoinSchemas(
schemaDataSourceSessionsCommon(),
schemaDataSourceSessionsPostgreSQL(),
Expand All @@ -37,8 +41,10 @@ func DataSourceSessionsPostgreSQL() *schema.Resource {

func DataSourceSessionsRedis() *schema.Resource {
return &schema.Resource{
Description: "Current sessions of a Redis managed database",
ReadContext: dataSourceSessionsRedisRead,
EnableLegacyTypeSystemApplyErrors: true,
EnableLegacyTypeSystemPlanErrors: true,
Description: "Current sessions of a Redis managed database",
ReadContext: dataSourceSessionsRedisRead,
Schema: utils.JoinSchemas(
schemaDataSourceSessionsCommon(),
schemaDataSourceSessionsRedis(),
Expand Down Expand Up @@ -113,7 +119,9 @@ func schemaDataSourceSessionsRedis() map[string]*schema.Schema {

func schemaDatabaseSessionMySQL() *schema.Resource {
return &schema.Resource{
Description: "MySQL session",
EnableLegacyTypeSystemApplyErrors: true,
EnableLegacyTypeSystemPlanErrors: true,
Description: "MySQL session",
Schema: map[string]*schema.Schema{
"application_name": {
Description: "Name of the application that is connected to this service.",
Expand Down Expand Up @@ -161,7 +169,9 @@ func schemaDatabaseSessionMySQL() *schema.Resource {

func schemaDatabaseSessionPostgreSQL() *schema.Resource {
return &schema.Resource{
Description: "PostgreSQL session",
EnableLegacyTypeSystemApplyErrors: true,
EnableLegacyTypeSystemPlanErrors: true,
Description: "PostgreSQL session",
Schema: map[string]*schema.Schema{
"application_name": {
Description: "Name of the application that is connected to this service.",
Expand Down Expand Up @@ -278,7 +288,9 @@ func schemaDatabaseSessionPostgreSQL() *schema.Resource {

func schemaDatabaseSessionRedis() *schema.Resource {
return &schema.Resource{
Description: "Redis session",
EnableLegacyTypeSystemApplyErrors: true,
EnableLegacyTypeSystemPlanErrors: true,
Description: "Redis session",
Schema: map[string]*schema.Schema{
"active_channel_subscriptions": {
Description: "Number of active channel subscriptions",
Expand Down
6 changes: 6 additions & 0 deletions internal/service/database/database_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ func schemaDatabaseComponents() *schema.Schema {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
EnableLegacyTypeSystemApplyErrors: true,
EnableLegacyTypeSystemPlanErrors: true,
Schema: map[string]*schema.Schema{
"component": {
Description: "Type of the component",
Expand Down Expand Up @@ -157,6 +159,8 @@ func schemaDatabaseNetwork() *schema.Schema {
MaxItems: 8,
MinItems: 1,
Elem: &schema.Resource{
EnableLegacyTypeSystemApplyErrors: true,
EnableLegacyTypeSystemPlanErrors: true,
Schema: map[string]*schema.Schema{
"name": {
Description: "The name of the network. Must be unique within the service.",
Expand Down Expand Up @@ -223,6 +227,8 @@ func schemaDatabaseNodeStates() *schema.Schema {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
EnableLegacyTypeSystemApplyErrors: true,
EnableLegacyTypeSystemPlanErrors: true,
Schema: map[string]*schema.Schema{
"name": {
Description: "Name plus a node iteration",
Expand Down
10 changes: 6 additions & 4 deletions internal/service/database/logical_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ import (

func ResourceLogicalDatabase() *schema.Resource {
return &schema.Resource{
Description: "This resource represents a logical database in managed database",
CreateContext: resourceLogicalDatabaseCreate,
ReadContext: resourceLogicalDatabaseRead,
DeleteContext: resourceLogicalDatabaseDelete,
EnableLegacyTypeSystemApplyErrors: true,
EnableLegacyTypeSystemPlanErrors: true,
Description: "This resource represents a logical database in managed database",
CreateContext: resourceLogicalDatabaseCreate,
ReadContext: resourceLogicalDatabaseRead,
DeleteContext: resourceLogicalDatabaseDelete,
Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
},
Expand Down
16 changes: 10 additions & 6 deletions internal/service/database/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ import (

func ResourceMySQL() *schema.Resource {
return &schema.Resource{
Description: serviceDescription("MySQL"),
CreateContext: resourceMySQLCreate,
ReadContext: resourceMySQLRead,
UpdateContext: resourceMySQLUpdate,
DeleteContext: resourceDatabaseDelete,
EnableLegacyTypeSystemApplyErrors: true,
EnableLegacyTypeSystemPlanErrors: true,
Description: serviceDescription("MySQL"),
CreateContext: resourceMySQLCreate,
ReadContext: resourceMySQLRead,
UpdateContext: resourceMySQLUpdate,
DeleteContext: resourceDatabaseDelete,
Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
},
Expand Down Expand Up @@ -63,7 +65,9 @@ func schemaMySQLEngine() map[string]*schema.Schema {
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: properties.GetSchemaMap(upcloud.ManagedDatabaseServiceTypeMySQL),
EnableLegacyTypeSystemApplyErrors: true,
EnableLegacyTypeSystemPlanErrors: true,
Schema: properties.GetSchemaMap(upcloud.ManagedDatabaseServiceTypeMySQL),
},
},
}
Expand Down
16 changes: 10 additions & 6 deletions internal/service/database/opensearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ import (

func ResourceOpenSearch() *schema.Resource {
return &schema.Resource{
Description: serviceDescription("OpenSearch"),
CreateContext: resourceOpenSearchCreate,
ReadContext: resourceOpenSearchRead,
UpdateContext: resourceOpenSearchUpdate,
DeleteContext: resourceDatabaseDelete,
EnableLegacyTypeSystemApplyErrors: true,
EnableLegacyTypeSystemPlanErrors: true,
Description: serviceDescription("OpenSearch"),
CreateContext: resourceOpenSearchCreate,
ReadContext: resourceOpenSearchRead,
UpdateContext: resourceOpenSearchUpdate,
DeleteContext: resourceDatabaseDelete,
Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
},
Expand Down Expand Up @@ -110,7 +112,9 @@ func schemaOpenSearchEngine() map[string]*schema.Schema {
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: properties.GetSchemaMap(upcloud.ManagedDatabaseServiceTypeOpenSearch),
EnableLegacyTypeSystemApplyErrors: true,
EnableLegacyTypeSystemPlanErrors: true,
Schema: properties.GetSchemaMap(upcloud.ManagedDatabaseServiceTypeOpenSearch),
},
},
}
Expand Down
16 changes: 10 additions & 6 deletions internal/service/database/postgresql.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ import (

func ResourcePostgreSQL() *schema.Resource {
return &schema.Resource{
Description: serviceDescription("PostgreSQL"),
CreateContext: resourcePostgreSQLCreate,
ReadContext: resourcePostgreSQLRead,
UpdateContext: resourcePostgreSQLUpdate,
DeleteContext: resourceDatabaseDelete,
EnableLegacyTypeSystemApplyErrors: true,
EnableLegacyTypeSystemPlanErrors: true,
Description: serviceDescription("PostgreSQL"),
CreateContext: resourcePostgreSQLCreate,
ReadContext: resourcePostgreSQLRead,
UpdateContext: resourcePostgreSQLUpdate,
DeleteContext: resourceDatabaseDelete,
Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
},
Expand Down Expand Up @@ -107,7 +109,9 @@ func schemaPostgreSQLEngine() map[string]*schema.Schema {
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: properties.GetSchemaMap(upcloud.ManagedDatabaseServiceTypePostgreSQL),
EnableLegacyTypeSystemApplyErrors: true,
EnableLegacyTypeSystemPlanErrors: true,
Schema: properties.GetSchemaMap(upcloud.ManagedDatabaseServiceTypePostgreSQL),
},
},
}
Expand Down
6 changes: 5 additions & 1 deletion internal/service/database/properties/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,11 @@ func getSchema(key string, prop upcloud.ManagedDatabaseServiceProperty) (*schema

s.Type = schema.TypeList
s.MaxItems = 1
s.Elem = &schema.Resource{Schema: nested}
s.Elem = &schema.Resource{
EnableLegacyTypeSystemApplyErrors: true,
EnableLegacyTypeSystemPlanErrors: true,
Schema: nested,
}
default:
return nil, fmt.Errorf(`unknown property value type "%s"`, prop.Type)
}
Expand Down
16 changes: 10 additions & 6 deletions internal/service/database/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ import (

func ResourceRedis() *schema.Resource {
return &schema.Resource{
Description: serviceDescription("Redis"),
CreateContext: resourceRedisCreate,
ReadContext: resourceRedisRead,
UpdateContext: resourceRedisUpdate,
DeleteContext: resourceDatabaseDelete,
EnableLegacyTypeSystemApplyErrors: true,
EnableLegacyTypeSystemPlanErrors: true,
Description: serviceDescription("Redis"),
CreateContext: resourceRedisCreate,
ReadContext: resourceRedisRead,
UpdateContext: resourceRedisUpdate,
DeleteContext: resourceDatabaseDelete,
Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
},
Expand Down Expand Up @@ -63,7 +65,9 @@ func schemaRedisEngine() map[string]*schema.Schema {
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: properties.GetSchemaMap(upcloud.ManagedDatabaseServiceTypeRedis),
EnableLegacyTypeSystemApplyErrors: true,
EnableLegacyTypeSystemPlanErrors: true,
Schema: properties.GetSchemaMap(upcloud.ManagedDatabaseServiceTypeRedis),
},
},
}
Expand Down
26 changes: 18 additions & 8 deletions internal/service/database/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ import (

func ResourceUser() *schema.Resource {
return &schema.Resource{
Description: "This resource represents a user in managed database",
CreateContext: resourceUserCreate,
ReadContext: resourceUserRead,
UpdateContext: resourceUserUpdate,
DeleteContext: resourceUserDelete,
EnableLegacyTypeSystemApplyErrors: true,
EnableLegacyTypeSystemPlanErrors: true,
Description: "This resource represents a user in managed database",
CreateContext: resourceUserCreate,
ReadContext: resourceUserRead,
UpdateContext: resourceUserUpdate,
DeleteContext: resourceUserDelete,
Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
},
Expand Down Expand Up @@ -72,7 +74,9 @@ func schemaUser() map[string]*schema.Schema {
Optional: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: schemaPostgreSQLUserAccessControl(),
EnableLegacyTypeSystemApplyErrors: true,
EnableLegacyTypeSystemPlanErrors: true,
Schema: schemaPostgreSQLUserAccessControl(),
},
},
"redis_access_control": {
Expand All @@ -81,7 +85,9 @@ func schemaUser() map[string]*schema.Schema {
Optional: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: schemaRedisUserAccessControl(),
EnableLegacyTypeSystemApplyErrors: true,
EnableLegacyTypeSystemPlanErrors: true,
Schema: schemaRedisUserAccessControl(),
},
},
"opensearch_access_control": {
Expand All @@ -90,7 +96,9 @@ func schemaUser() map[string]*schema.Schema {
Optional: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: schemaOpenSearchUserAccessControl(),
EnableLegacyTypeSystemApplyErrors: true,
EnableLegacyTypeSystemPlanErrors: true,
Schema: schemaOpenSearchUserAccessControl(),
},
},
}
Expand Down Expand Up @@ -155,6 +163,8 @@ func schemaOpenSearchUserAccessControl() map[string]*schema.Schema {
Type: schema.TypeList,
Required: true,
Elem: &schema.Resource{
EnableLegacyTypeSystemApplyErrors: true,
EnableLegacyTypeSystemPlanErrors: true,
Schema: map[string]*schema.Schema{
"index": {
Description: "Set index name, pattern or top level API.",
Expand Down
4 changes: 4 additions & 0 deletions internal/service/firewall/firewall.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import (

func ResourceFirewallRules() *schema.Resource {
return &schema.Resource{
EnableLegacyTypeSystemApplyErrors: true,
EnableLegacyTypeSystemPlanErrors: true,
Description: `This resource represents a generated list of UpCloud firewall rules.
Firewall rules are used in conjunction with UpCloud servers.
Each server has its own firewall rules.
Expand Down Expand Up @@ -47,6 +49,8 @@ func ResourceFirewallRules() *schema.Resource {
MaxItems: 1000,
Required: true,
Elem: &schema.Resource{
EnableLegacyTypeSystemApplyErrors: true,
EnableLegacyTypeSystemPlanErrors: true,
Schema: map[string]*schema.Schema{
"direction": {
Type: schema.TypeString,
Expand Down
Loading
Loading