From ac032194ddaa3f1da23e26e29b3c723158141771 Mon Sep 17 00:00:00 2001 From: Bobby Iliev Date: Wed, 6 Dec 2023 20:16:04 +0200 Subject: [PATCH 01/10] ID migration changes --- .../resources/materialize_cluster/import.sh | 3 ++- .../materialize_cluster_replica/import.sh | 3 ++- .../import.sh | 3 ++- .../import.sh | 3 ++- .../materialize_connection_kafka/import.sh | 5 ++-- .../materialize_connection_postgres/import.sh | 5 +++- .../import.sh | 3 ++- .../resources/materialize_index/import.sh | 3 ++- .../materialize_materialized_view/import.sh | 3 ++- examples/resources/materialize_role/import.sh | 3 ++- .../resources/materialize_schema/import.sh | 3 ++- .../resources/materialize_secret/import.sh | 3 ++- .../materialize_sink_kafka/import.sh | 3 ++- .../materialize_source_kafka/import.sh | 3 ++- .../import.sh | 3 ++- .../materialize_source_postgres/import.sh | 3 ++- .../materialize_source_webhook/import.sh | 3 ++- .../resources/materialize_table/import.sh | 3 ++- examples/resources/materialize_type/import.sh | 4 +++- examples/resources/materialize_view/import.sh | 3 ++- pkg/datasources/datasource_cluster.go | 3 ++- pkg/datasources/datasource_cluster_replica.go | 3 ++- pkg/datasources/datasource_schema.go | 5 ++-- pkg/datasources/utils.go | 3 ++- .../acceptance_cluster_replica_test.go | 7 +++--- pkg/provider/acceptance_cluster_test.go | 7 +++--- ...nnection_confluent_schema_registry_test.go | 7 +++--- .../acceptance_connection_kafka_test.go | 7 +++--- .../acceptance_connection_postgres_test.go | 7 +++--- .../acceptance_connection_ssh_tunnel_test.go | 7 +++--- pkg/provider/acceptance_index_test.go | 7 +++--- .../acceptance_materialized_view_test.go | 7 +++--- pkg/provider/acceptance_role_test.go | 7 +++--- pkg/provider/acceptance_schema_test.go | 7 +++--- pkg/provider/acceptance_secret_test.go | 7 +++--- pkg/provider/acceptance_sink_kafka_test.go | 7 +++--- pkg/provider/acceptance_source_kafka_test.go | 7 +++--- .../acceptance_source_load_generator_test.go | 7 +++--- .../acceptance_source_postgres_test.go | 7 +++--- .../acceptance_source_webhook_test.go | 7 +++--- pkg/provider/acceptance_table_test.go | 7 +++--- pkg/provider/acceptance_type_test.go | 7 +++--- pkg/provider/acceptance_view_test.go | 7 +++--- pkg/resources/resource_cluster.go | 24 +++++++++++++++---- pkg/resources/resource_cluster_replica.go | 24 +++++++++++++++---- pkg/resources/resource_connection.go | 5 ++-- .../resource_connection_aws_privatelink.go | 24 +++++++++++++++---- ...ce_connection_confluent_schema_registry.go | 20 ++++++++++++++-- pkg/resources/resource_connection_kafka.go | 20 ++++++++++++++-- pkg/resources/resource_connection_postgres.go | 20 ++++++++++++++-- .../resource_connection_ssh_tunnel.go | 24 +++++++++++++++---- pkg/resources/resource_database.go | 1 - pkg/resources/resource_index.go | 24 +++++++++++++++---- pkg/resources/resource_materialized_view.go | 24 +++++++++++++++---- pkg/resources/resource_role.go | 24 +++++++++++++++---- pkg/resources/resource_schema.go | 7 +++--- pkg/resources/resource_secret.go | 24 +++++++++++++++---- pkg/resources/resource_sink.go | 5 ++-- pkg/resources/resource_sink_kafka.go | 20 ++++++++++++++-- pkg/resources/resource_source.go | 5 ++-- pkg/resources/resource_source_kafka.go | 20 ++++++++++++++-- .../resource_source_load_generator.go | 20 ++++++++++++++-- pkg/resources/resource_source_postgres.go | 20 ++++++++++++++-- pkg/resources/resource_source_webhook.go | 20 ++++++++++++++-- pkg/resources/resource_table.go | 24 +++++++++++++++---- pkg/resources/resource_type.go | 24 +++++++++++++++---- pkg/resources/resource_view.go | 24 +++++++++++++++---- 67 files changed, 506 insertions(+), 153 deletions(-) diff --git a/examples/resources/materialize_cluster/import.sh b/examples/resources/materialize_cluster/import.sh index aad30b6e..8e297930 100644 --- a/examples/resources/materialize_cluster/import.sh +++ b/examples/resources/materialize_cluster/import.sh @@ -1,4 +1,5 @@ # Clusters can be imported using the cluster id: -terraform import materialize_cluster.example_cluster +terraform import materialize_cluster.example_cluster : # Cluster id and information be found in the `mz_catalog.mz_clusters` table +# The region is the region where the database is located (e.g. aws/us-east-1) diff --git a/examples/resources/materialize_cluster_replica/import.sh b/examples/resources/materialize_cluster_replica/import.sh index ca898e20..1811901d 100644 --- a/examples/resources/materialize_cluster_replica/import.sh +++ b/examples/resources/materialize_cluster_replica/import.sh @@ -1,4 +1,5 @@ # Cluster replicas can be imported using the cluster replica id: -terraform import materialize_cluster_replica.example_1_cluster_replica +terraform import materialize_cluster_replica.example_1_cluster_replica : # Cluster replica id and information be found in the `mz_catalog.mz_cluster_replicas` table +# The region is the region where the database is located (e.g. aws/us-east-1) diff --git a/examples/resources/materialize_connection_aws_privatelink/import.sh b/examples/resources/materialize_connection_aws_privatelink/import.sh index 6a650f27..2832a886 100644 --- a/examples/resources/materialize_connection_aws_privatelink/import.sh +++ b/examples/resources/materialize_connection_aws_privatelink/import.sh @@ -1,4 +1,5 @@ #Connections can be imported using the connection id: -terraform import materialize_connection_aws_privatelink.example +terraform import materialize_connection_aws_privatelink.example : # Connection id and information be found in the `mz_catalog.mz_connections` table +# The region is the region where the database is located (e.g. aws/us-east-1) diff --git a/examples/resources/materialize_connection_confluent_schema_registry/import.sh b/examples/resources/materialize_connection_confluent_schema_registry/import.sh index 36ff7772..04ea89b3 100644 --- a/examples/resources/materialize_connection_confluent_schema_registry/import.sh +++ b/examples/resources/materialize_connection_confluent_schema_registry/import.sh @@ -1,4 +1,5 @@ #Connections can be imported using the connection id: -terraform import materialize_connection_confluent_schema_registry.example +terraform import materialize_connection_confluent_schema_registry.example : # Connection id and information be found in the `mz_catalog.mz_connections` table +# The region is the region where the database is located (e.g. aws/us-east-1) diff --git a/examples/resources/materialize_connection_kafka/import.sh b/examples/resources/materialize_connection_kafka/import.sh index 2fb7bba0..a28477ca 100644 --- a/examples/resources/materialize_connection_kafka/import.sh +++ b/examples/resources/materialize_connection_kafka/import.sh @@ -1,4 +1,5 @@ -#Connections can be imported using the connection id: -terraform import materialize_connection_kafka.example +# Connections can be imported using the connection id: +terraform import materialize_connection_kafka.example : # Connection id and information be found in the `mz_catalog.mz_connections` table +# The region is the region where the database is located (e.g. aws/us-east-1) diff --git a/examples/resources/materialize_connection_postgres/import.sh b/examples/resources/materialize_connection_postgres/import.sh index 42835bde..3712d86b 100644 --- a/examples/resources/materialize_connection_postgres/import.sh +++ b/examples/resources/materialize_connection_postgres/import.sh @@ -1,2 +1,5 @@ # Connections can be imported using the connection id: -terraform import materialize_connection_postgres.example \ No newline at end of file +terraform import materialize_connection_postgres.example : + +# Connection id and information be found in the `mz_catalog.mz_connections` table +# The region is the region where the database is located (e.g. aws/us-east-1) diff --git a/examples/resources/materialize_connection_ssh_tunnel/import.sh b/examples/resources/materialize_connection_ssh_tunnel/import.sh index 70e56fd9..5252847b 100644 --- a/examples/resources/materialize_connection_ssh_tunnel/import.sh +++ b/examples/resources/materialize_connection_ssh_tunnel/import.sh @@ -1,4 +1,5 @@ #Connections can be imported using the connection id: -terraform import materialize_connection_ssh_tunnel.example +terraform import materialize_connection_ssh_tunnel.example : # Connection id and information be found in the `mz_catalog.mz_connections` table +# The region is the region where the database is located (e.g. aws/us-east-1) diff --git a/examples/resources/materialize_index/import.sh b/examples/resources/materialize_index/import.sh index c504c2ef..5f25a14e 100644 --- a/examples/resources/materialize_index/import.sh +++ b/examples/resources/materialize_index/import.sh @@ -1,4 +1,5 @@ # Indexes can be imported using the index id: -terraform import materialize_index.example_index +terraform import materialize_index.example_index : # Index id and information be found in the `mz_catalog.mz_indexes` table +# The region is the region where the database is located (e.g. aws/us-east-1) diff --git a/examples/resources/materialize_materialized_view/import.sh b/examples/resources/materialize_materialized_view/import.sh index 41c69803..e4e43dba 100644 --- a/examples/resources/materialize_materialized_view/import.sh +++ b/examples/resources/materialize_materialized_view/import.sh @@ -1,4 +1,5 @@ # Materialized views can be imported using the materialized view id: -terraform import materialize_materialized_view.example_materialize_view +terraform import materialize_materialized_view.example_materialize_view : # Materialized view id and information be found in the `mz_catalog.mz_materialized_views` table +# The region is the region where the database is located (e.g. aws/us-east-1) diff --git a/examples/resources/materialize_role/import.sh b/examples/resources/materialize_role/import.sh index 9e6dd18d..a9904507 100644 --- a/examples/resources/materialize_role/import.sh +++ b/examples/resources/materialize_role/import.sh @@ -1,4 +1,5 @@ # Roles can be imported using the role id: -terraform import materialize_role.example_role +terraform import materialize_role.example_role : # Role id and information be found in the `mz_catalog.mz_roles` table +# The region is the region where the database is located (e.g. aws/us-east-1) diff --git a/examples/resources/materialize_schema/import.sh b/examples/resources/materialize_schema/import.sh index 22f97f5f..088fa598 100644 --- a/examples/resources/materialize_schema/import.sh +++ b/examples/resources/materialize_schema/import.sh @@ -1,4 +1,5 @@ # Schemas can be imported using the schema id: -terraform import materialize_schema.example_schema +terraform import materialize_schema.example_schema : # Schema id and information be found in the `mz_catalog.mz_schemas` table +# The role is the role where the database is located (e.g. aws/us-east-1) diff --git a/examples/resources/materialize_secret/import.sh b/examples/resources/materialize_secret/import.sh index 515574c2..743e6104 100644 --- a/examples/resources/materialize_secret/import.sh +++ b/examples/resources/materialize_secret/import.sh @@ -1,4 +1,5 @@ # Secrets can be imported using the secret id: -terraform import materialize_secret.example_secret +terraform import materialize_secret.example_secret : # Secret id and information be found in the `mz_catalog.mz_secrets` table +# The region is the region where the database is located (e.g. aws/us-east-1) diff --git a/examples/resources/materialize_sink_kafka/import.sh b/examples/resources/materialize_sink_kafka/import.sh index 673901e8..c2de2231 100644 --- a/examples/resources/materialize_sink_kafka/import.sh +++ b/examples/resources/materialize_sink_kafka/import.sh @@ -1,4 +1,5 @@ # Sinks can be imported using the sink id: -terraform import materialize_sink_kafka.example_sink_kafka +terraform import materialize_sink_kafka.example_sink_kafka : # Sink id and information be found in the `mz_catalog.mz_sinks` table +# The region is the region where the database is located (e.g. aws/us-east-1) diff --git a/examples/resources/materialize_source_kafka/import.sh b/examples/resources/materialize_source_kafka/import.sh index 090ae504..50e66884 100644 --- a/examples/resources/materialize_source_kafka/import.sh +++ b/examples/resources/materialize_source_kafka/import.sh @@ -1,4 +1,5 @@ # Sources can be imported using the source id: -terraform import materialize_source_kafka.example_source_kafka +terraform import materialize_source_kafka.example_source_kafka : # Source id and information be found in the `mz_catalog.mz_sources` table +# The region is the region where the database is located (e.g. aws/us-east-1) diff --git a/examples/resources/materialize_source_load_generator/import.sh b/examples/resources/materialize_source_load_generator/import.sh index b1a61b17..e6606ee9 100644 --- a/examples/resources/materialize_source_load_generator/import.sh +++ b/examples/resources/materialize_source_load_generator/import.sh @@ -1,4 +1,5 @@ # Sources can be imported using the source id: -terraform import materialize_source_load_generator.example_source_load_generator +terraform import materialize_source_load_generator.example_source_load_generator : # Source id and information be found in the `mz_catalog.mz_sources` table +# The region is the region where the database is located (e.g. aws/us-east-1) diff --git a/examples/resources/materialize_source_postgres/import.sh b/examples/resources/materialize_source_postgres/import.sh index 9e82cc2c..b288d9ee 100644 --- a/examples/resources/materialize_source_postgres/import.sh +++ b/examples/resources/materialize_source_postgres/import.sh @@ -1,4 +1,5 @@ # Sources can be imported using the source id: -terraform import materialize_source_postgres.example_source_postgres +terraform import materialize_source_postgres.example_source_postgres : # Source id and information be found in the `mz_catalog.mz_sources` table +# The region is the region where the database is located (e.g. aws/us-east-1) diff --git a/examples/resources/materialize_source_webhook/import.sh b/examples/resources/materialize_source_webhook/import.sh index e475c347..33e1ff81 100644 --- a/examples/resources/materialize_source_webhook/import.sh +++ b/examples/resources/materialize_source_webhook/import.sh @@ -1,4 +1,5 @@ # Sources can be imported using the source id: -terraform import materialize_source_webhook.example_source_webhook +terraform import materialize_source_webhook.example_source_webhook : # Source id and information be found in the `mz_catalog.mz_sources` table +# The region is the region where the database is located (e.g. aws/us-east-1) diff --git a/examples/resources/materialize_table/import.sh b/examples/resources/materialize_table/import.sh index 3475c477..a22c4e16 100644 --- a/examples/resources/materialize_table/import.sh +++ b/examples/resources/materialize_table/import.sh @@ -1,4 +1,5 @@ # Tables can be imported using the table id: -terraform import materialize_table.example_table +terraform import materialize_table.example_table : # Table id and information be found in the `mz_catalog.mz_tables` table +# The region is the region where the database is located (e.g. aws/us-east-1) diff --git a/examples/resources/materialize_type/import.sh b/examples/resources/materialize_type/import.sh index f20d98d0..41d649b1 100644 --- a/examples/resources/materialize_type/import.sh +++ b/examples/resources/materialize_type/import.sh @@ -1,4 +1,6 @@ # Types can be imported using the type id: -terraform import materialize_type.example_type +terraform import materialize_type.example_type : # Type id and information be found in the `mz_catalog.mz_types` table +# The region is the region where the database is located (e.g. aws/us-east-1) +``` diff --git a/examples/resources/materialize_view/import.sh b/examples/resources/materialize_view/import.sh index 9aef80ee..cce5a990 100644 --- a/examples/resources/materialize_view/import.sh +++ b/examples/resources/materialize_view/import.sh @@ -1,4 +1,5 @@ # Views can be imported using the view id: -terraform import materialize_view.example_view +terraform import materialize_view.example_view : # View id and information be found in the `mz_catalog.mz_views` +# The region is the region where the database is located (e.g. aws/us-east-1) diff --git a/pkg/datasources/datasource_cluster.go b/pkg/datasources/datasource_cluster.go index bbb367b8..5a610c4c 100644 --- a/pkg/datasources/datasource_cluster.go +++ b/pkg/datasources/datasource_cluster.go @@ -4,6 +4,7 @@ import ( "context" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -77,6 +78,6 @@ func clusterRead(ctx context.Context, d *schema.ResourceData, meta interface{}) return diag.FromErr(err) } - d.SetId("clusters") + d.SetId(utils.TransformIdWithRegion("clusters")) return diags } diff --git a/pkg/datasources/datasource_cluster_replica.go b/pkg/datasources/datasource_cluster_replica.go index 2241e6d9..35384cbb 100644 --- a/pkg/datasources/datasource_cluster_replica.go +++ b/pkg/datasources/datasource_cluster_replica.go @@ -4,6 +4,7 @@ import ( "context" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -77,6 +78,6 @@ func clusterReplicaRead(ctx context.Context, d *schema.ResourceData, meta interf return diag.FromErr(err) } - d.SetId("cluster_replicas") + d.SetId(utils.TransformIdWithRegion("cluster_replicas")) return diags } diff --git a/pkg/datasources/datasource_schema.go b/pkg/datasources/datasource_schema.go index 33d38837..e80ccdad 100644 --- a/pkg/datasources/datasource_schema.go +++ b/pkg/datasources/datasource_schema.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -72,9 +73,9 @@ func schemaRead(ctx context.Context, d *schema.ResourceData, meta interface{}) d if databaseName != "" { id := fmt.Sprintf("%s|schemas", databaseName) - d.SetId(id) + d.SetId(utils.TransformIdWithRegion(id)) } else { - d.SetId("schemas") + d.SetId(utils.TransformIdWithRegion("schemas")) } return diags diff --git a/pkg/datasources/utils.go b/pkg/datasources/utils.go index 7b2f2a74..7c2b391a 100644 --- a/pkg/datasources/utils.go +++ b/pkg/datasources/utils.go @@ -3,6 +3,7 @@ package datasources import ( "fmt" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -16,5 +17,5 @@ func SetId(resource, databaseName, schemaName string, d *schema.ResourceData) { id = resource } - d.SetId(id) + d.SetId(utils.TransformIdWithRegion(id)) } diff --git a/pkg/provider/acceptance_cluster_replica_test.go b/pkg/provider/acceptance_cluster_replica_test.go index 63f8d49e..ae03fadf 100644 --- a/pkg/provider/acceptance_cluster_replica_test.go +++ b/pkg/provider/acceptance_cluster_replica_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -136,7 +137,7 @@ func testAccCheckClusterReplicaExists(name string) resource.TestCheckFunc { if !ok { return fmt.Errorf("cluster replica not found: %s", name) } - _, err := materialize.ScanClusterReplica(db, r.Primary.ID) + _, err := materialize.ScanClusterReplica(db, utils.ExtractId(r.Primary.ID)) return err } } @@ -149,9 +150,9 @@ func testAccCheckAllClusterReplicaDestroyed(s *terraform.State) error { continue } - _, err := materialize.ScanClusterReplica(db, r.Primary.ID) + _, err := materialize.ScanClusterReplica(db, utils.ExtractId(r.Primary.ID)) if err == nil { - return fmt.Errorf("Cluster replica %v still exists", r.Primary.ID) + return fmt.Errorf("Cluster replica %v still exists", utils.ExtractId(r.Primary.ID)) } else if err != sql.ErrNoRows { return err } diff --git a/pkg/provider/acceptance_cluster_test.go b/pkg/provider/acceptance_cluster_test.go index d33b3625..9849cd80 100644 --- a/pkg/provider/acceptance_cluster_test.go +++ b/pkg/provider/acceptance_cluster_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -375,7 +376,7 @@ func testAccCheckClusterExists(name string) resource.TestCheckFunc { if !ok { return fmt.Errorf("cluster not found: %s", name) } - _, err := materialize.ScanCluster(db, r.Primary.ID) + _, err := materialize.ScanCluster(db, utils.ExtractId(r.Primary.ID)) return err } } @@ -388,9 +389,9 @@ func testAccCheckAllClusterDestroyed(s *terraform.State) error { continue } - _, err := materialize.ScanCluster(db, r.Primary.ID) + _, err := materialize.ScanCluster(db, utils.ExtractId(r.Primary.ID)) if err == nil { - return fmt.Errorf("Cluster %v still exists", r.Primary.ID) + return fmt.Errorf("Cluster %v still exists", utils.ExtractId(r.Primary.ID)) } else if err != sql.ErrNoRows { return err } diff --git a/pkg/provider/acceptance_connection_confluent_schema_registry_test.go b/pkg/provider/acceptance_connection_confluent_schema_registry_test.go index 15d8f731..6bc96f38 100644 --- a/pkg/provider/acceptance_connection_confluent_schema_registry_test.go +++ b/pkg/provider/acceptance_connection_confluent_schema_registry_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -129,7 +130,7 @@ func testAccCheckConnConfluentSchemaRegistryExists(name string) resource.TestChe if !ok { return fmt.Errorf("connection confluent schema registry not found: %s", name) } - _, err := materialize.ScanConnection(db, r.Primary.ID) + _, err := materialize.ScanConnection(db, utils.ExtractId(r.Primary.ID)) return err } } @@ -142,9 +143,9 @@ func testAccCheckAllConnConfluentSchemaRegistryDestroyed(s *terraform.State) err continue } - _, err := materialize.ScanConnection(db, r.Primary.ID) + _, err := materialize.ScanConnection(db, utils.ExtractId(r.Primary.ID)) if err == nil { - return fmt.Errorf("connection %v still exists", r.Primary.ID) + return fmt.Errorf("connection %v still exists", utils.ExtractId(r.Primary.ID)) } else if err != sql.ErrNoRows { return err } diff --git a/pkg/provider/acceptance_connection_kafka_test.go b/pkg/provider/acceptance_connection_kafka_test.go index 8e958607..b406b276 100644 --- a/pkg/provider/acceptance_connection_kafka_test.go +++ b/pkg/provider/acceptance_connection_kafka_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -267,7 +268,7 @@ func testAccCheckConnKafkaExists(name string) resource.TestCheckFunc { if !ok { return fmt.Errorf("connection kafka not found: %s", name) } - _, err := materialize.ScanConnection(db, r.Primary.ID) + _, err := materialize.ScanConnection(db, utils.ExtractId(r.Primary.ID)) return err } } @@ -280,9 +281,9 @@ func testAccCheckAllConnKafkaDestroyed(s *terraform.State) error { continue } - _, err := materialize.ScanConnection(db, r.Primary.ID) + _, err := materialize.ScanConnection(db, utils.ExtractId(r.Primary.ID)) if err == nil { - return fmt.Errorf("connection %v still exists", r.Primary.ID) + return fmt.Errorf("connection %v still exists", utils.ExtractId(r.Primary.ID)) } else if err != sql.ErrNoRows { return err } diff --git a/pkg/provider/acceptance_connection_postgres_test.go b/pkg/provider/acceptance_connection_postgres_test.go index c82944d6..3ffcb692 100644 --- a/pkg/provider/acceptance_connection_postgres_test.go +++ b/pkg/provider/acceptance_connection_postgres_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -165,7 +166,7 @@ func testAccCheckConnPostgresExists(name string) resource.TestCheckFunc { if !ok { return fmt.Errorf("connection postgres not found: %s", name) } - _, err := materialize.ScanConnection(db, r.Primary.ID) + _, err := materialize.ScanConnection(db, utils.ExtractId(r.Primary.ID)) return err } } @@ -178,9 +179,9 @@ func testAccCheckAllConnPostgresDestroyed(s *terraform.State) error { continue } - _, err := materialize.ScanConnection(db, r.Primary.ID) + _, err := materialize.ScanConnection(db, utils.ExtractId(r.Primary.ID)) if err == nil { - return fmt.Errorf("connection %v still exists", r.Primary.ID) + return fmt.Errorf("connection %v still exists", utils.ExtractId(r.Primary.ID)) } else if err != sql.ErrNoRows { return err } diff --git a/pkg/provider/acceptance_connection_ssh_tunnel_test.go b/pkg/provider/acceptance_connection_ssh_tunnel_test.go index 6de0052c..be662ba9 100644 --- a/pkg/provider/acceptance_connection_ssh_tunnel_test.go +++ b/pkg/provider/acceptance_connection_ssh_tunnel_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -139,7 +140,7 @@ func testAccCheckConnSshTunnelExists(name string) resource.TestCheckFunc { if !ok { return fmt.Errorf("connection ssh tunnel not found: %s", name) } - _, err := materialize.ScanConnectionSshTunnel(db, r.Primary.ID) + _, err := materialize.ScanConnectionSshTunnel(db, utils.ExtractId(r.Primary.ID)) return err } } @@ -152,9 +153,9 @@ func testAccCheckAllConnSshTunnelDestroyed(s *terraform.State) error { continue } - _, err := materialize.ScanConnectionSshTunnel(db, r.Primary.ID) + _, err := materialize.ScanConnectionSshTunnel(db, utils.ExtractId(r.Primary.ID)) if err == nil { - return fmt.Errorf("connection %v still exists", r.Primary.ID) + return fmt.Errorf("connection %v still exists", utils.ExtractId(r.Primary.ID)) } else if err != sql.ErrNoRows { return err } diff --git a/pkg/provider/acceptance_index_test.go b/pkg/provider/acceptance_index_test.go index 0043f440..8d1400ff 100644 --- a/pkg/provider/acceptance_index_test.go +++ b/pkg/provider/acceptance_index_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -159,7 +160,7 @@ func testAccCheckIndexExists(name string) resource.TestCheckFunc { if !ok { return fmt.Errorf("index not found: %s", name) } - _, err := materialize.ScanIndex(db, r.Primary.ID) + _, err := materialize.ScanIndex(db, utils.ExtractId(r.Primary.ID)) return err } } @@ -180,9 +181,9 @@ func testAccCheckAllIndexDestroyed(s *terraform.State) error { continue } - _, err := materialize.ScanIndex(db, r.Primary.ID) + _, err := materialize.ScanIndex(db, utils.ExtractId(r.Primary.ID)) if err == nil { - return fmt.Errorf("index %v still exists", r.Primary.ID) + return fmt.Errorf("index %v still exists", utils.ExtractId(r.Primary.ID)) } else if err != sql.ErrNoRows { return err } diff --git a/pkg/provider/acceptance_materialized_view_test.go b/pkg/provider/acceptance_materialized_view_test.go index 51634345..5ad31b27 100644 --- a/pkg/provider/acceptance_materialized_view_test.go +++ b/pkg/provider/acceptance_materialized_view_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -143,7 +144,7 @@ func testAccCheckMaterializedViewExists(name string) resource.TestCheckFunc { if !ok { return fmt.Errorf("Materialized View not found: %s", name) } - _, err := materialize.ScanMaterializedView(db, r.Primary.ID) + _, err := materialize.ScanMaterializedView(db, utils.ExtractId(r.Primary.ID)) return err } } @@ -156,9 +157,9 @@ func testAccCheckAllMaterializedViewsDestroyed(s *terraform.State) error { continue } - _, err := materialize.ScanMaterializedView(db, r.Primary.ID) + _, err := materialize.ScanMaterializedView(db, utils.ExtractId(r.Primary.ID)) if err == nil { - return fmt.Errorf("Materialized View %v still exists", r.Primary.ID) + return fmt.Errorf("Materialized View %v still exists", utils.ExtractId(r.Primary.ID)) } else if err != sql.ErrNoRows { return err } diff --git a/pkg/provider/acceptance_role_test.go b/pkg/provider/acceptance_role_test.go index 61d6a35c..e24939b1 100644 --- a/pkg/provider/acceptance_role_test.go +++ b/pkg/provider/acceptance_role_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -110,7 +111,7 @@ func testAccCheckRoleExists(name string) resource.TestCheckFunc { if !ok { return fmt.Errorf("role not found: %s", name) } - _, err := materialize.ScanRole(db, r.Primary.ID) + _, err := materialize.ScanRole(db, utils.ExtractId(r.Primary.ID)) return err } } @@ -123,9 +124,9 @@ func testAccCheckAllRolesDestroyed(s *terraform.State) error { continue } - _, err := materialize.ScanRole(db, r.Primary.ID) + _, err := materialize.ScanRole(db, utils.ExtractId(r.Primary.ID)) if err == nil { - return fmt.Errorf("role %v still exists", r.Primary.ID) + return fmt.Errorf("role %v still exists", utils.ExtractId(r.Primary.ID)) } else if err != sql.ErrNoRows { return err } diff --git a/pkg/provider/acceptance_schema_test.go b/pkg/provider/acceptance_schema_test.go index 5d29a743..5cdd1d4a 100644 --- a/pkg/provider/acceptance_schema_test.go +++ b/pkg/provider/acceptance_schema_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -132,7 +133,7 @@ func testAccCheckSchemaExists(name string) resource.TestCheckFunc { if !ok { return fmt.Errorf("Schema not found: %s", name) } - _, err := materialize.ScanSchema(db, r.Primary.ID) + _, err := materialize.ScanSchema(db, utils.ExtractId(r.Primary.ID)) return err } } @@ -145,9 +146,9 @@ func testAccCheckAllSchemasDestroyed(s *terraform.State) error { continue } - _, err := materialize.ScanSchema(db, r.Primary.ID) + _, err := materialize.ScanSchema(db, utils.ExtractId(r.Primary.ID)) if err == nil { - return fmt.Errorf("Schema %v still exists", r.Primary.ID) + return fmt.Errorf("Schema %v still exists", utils.ExtractId(r.Primary.ID)) } else if err != sql.ErrNoRows { return err } diff --git a/pkg/provider/acceptance_secret_test.go b/pkg/provider/acceptance_secret_test.go index 0127b9b3..3e3e0dd3 100644 --- a/pkg/provider/acceptance_secret_test.go +++ b/pkg/provider/acceptance_secret_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -140,7 +141,7 @@ func testAccCheckSecretExists(name string) resource.TestCheckFunc { if !ok { return fmt.Errorf("secret not found: %s", name) } - _, err := materialize.ScanSecret(db, r.Primary.ID) + _, err := materialize.ScanSecret(db, utils.ExtractId(r.Primary.ID)) return err } } @@ -153,9 +154,9 @@ func testAccCheckAllSecretsDestroyed(s *terraform.State) error { continue } - _, err := materialize.ScanSecret(db, r.Primary.ID) + _, err := materialize.ScanSecret(db, utils.ExtractId(r.Primary.ID)) if err == nil { - return fmt.Errorf("secret %v still exists", r.Primary.ID) + return fmt.Errorf("secret %v still exists", utils.ExtractId(r.Primary.ID)) } else if err != sql.ErrNoRows { return err } diff --git a/pkg/provider/acceptance_sink_kafka_test.go b/pkg/provider/acceptance_sink_kafka_test.go index e201fd7d..1998df48 100644 --- a/pkg/provider/acceptance_sink_kafka_test.go +++ b/pkg/provider/acceptance_sink_kafka_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -200,7 +201,7 @@ func testAccCheckSinkKafkaExists(name string) resource.TestCheckFunc { if !ok { return fmt.Errorf("sink kafka not found: %s", name) } - _, err := materialize.ScanSink(db, r.Primary.ID) + _, err := materialize.ScanSink(db, utils.ExtractId(r.Primary.ID)) return err } } @@ -221,9 +222,9 @@ func testAccCheckAllSinkKafkaDestroyed(s *terraform.State) error { continue } - _, err := materialize.ScanSink(db, r.Primary.ID) + _, err := materialize.ScanSink(db, utils.ExtractId(r.Primary.ID)) if err == nil { - return fmt.Errorf("sink %v still exists", r.Primary.ID) + return fmt.Errorf("sink %v still exists", utils.ExtractId(r.Primary.ID)) } else if err != sql.ErrNoRows { return err } diff --git a/pkg/provider/acceptance_source_kafka_test.go b/pkg/provider/acceptance_source_kafka_test.go index 3743106f..8ee69c75 100644 --- a/pkg/provider/acceptance_source_kafka_test.go +++ b/pkg/provider/acceptance_source_kafka_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -319,7 +320,7 @@ func testAccCheckSourceKafkaExists(name string) resource.TestCheckFunc { if !ok { return fmt.Errorf("source kafka not found: %s", name) } - _, err := materialize.ScanSource(db, r.Primary.ID) + _, err := materialize.ScanSource(db, utils.ExtractId(r.Primary.ID)) return err } } @@ -332,9 +333,9 @@ func testAccCheckAllSourceKafkaDestroyed(s *terraform.State) error { continue } - _, err := materialize.ScanSource(db, r.Primary.ID) + _, err := materialize.ScanSource(db, utils.ExtractId(r.Primary.ID)) if err == nil { - return fmt.Errorf("source %v still exists", r.Primary.ID) + return fmt.Errorf("source %v still exists", utils.ExtractId(r.Primary.ID)) } else if err != sql.ErrNoRows { return err } diff --git a/pkg/provider/acceptance_source_load_generator_test.go b/pkg/provider/acceptance_source_load_generator_test.go index f2d09660..264c97ab 100644 --- a/pkg/provider/acceptance_source_load_generator_test.go +++ b/pkg/provider/acceptance_source_load_generator_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -305,7 +306,7 @@ func testAccCheckSourceLoadGeneratorExists(name string) resource.TestCheckFunc { if !ok { return fmt.Errorf("SourceLoadGenerator not found: %s", name) } - _, err := materialize.ScanSource(db, r.Primary.ID) + _, err := materialize.ScanSource(db, utils.ExtractId(r.Primary.ID)) return err } } @@ -326,9 +327,9 @@ func testAccCheckAllSourceLoadGeneratorsDestroyed(s *terraform.State) error { continue } - _, err := materialize.ScanSource(db, r.Primary.ID) + _, err := materialize.ScanSource(db, utils.ExtractId(r.Primary.ID)) if err == nil { - return fmt.Errorf("SourceLoadGenerator %v still exists", r.Primary.ID) + return fmt.Errorf("SourceLoadGenerator %v still exists", utils.ExtractId(r.Primary.ID)) } else if err != sql.ErrNoRows { return err } diff --git a/pkg/provider/acceptance_source_postgres_test.go b/pkg/provider/acceptance_source_postgres_test.go index 9f73854d..54bbc20f 100644 --- a/pkg/provider/acceptance_source_postgres_test.go +++ b/pkg/provider/acceptance_source_postgres_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -363,7 +364,7 @@ func testAccCheckSourcePostgresExists(name string) resource.TestCheckFunc { if !ok { return fmt.Errorf("source postgres not found: %s", name) } - _, err := materialize.ScanSource(db, r.Primary.ID) + _, err := materialize.ScanSource(db, utils.ExtractId(r.Primary.ID)) return err } } @@ -376,9 +377,9 @@ func testAccCheckAllSourcePostgresDestroyed(s *terraform.State) error { continue } - _, err := materialize.ScanSource(db, r.Primary.ID) + _, err := materialize.ScanSource(db, utils.ExtractId(r.Primary.ID)) if err == nil { - return fmt.Errorf("source %v still exists", r.Primary.ID) + return fmt.Errorf("source %v still exists", utils.ExtractId(r.Primary.ID)) } else if err != sql.ErrNoRows { return err } diff --git a/pkg/provider/acceptance_source_webhook_test.go b/pkg/provider/acceptance_source_webhook_test.go index acf5e64f..5b1b275a 100644 --- a/pkg/provider/acceptance_source_webhook_test.go +++ b/pkg/provider/acceptance_source_webhook_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -336,7 +337,7 @@ func testAccCheckSourceWebhookExists(name string) resource.TestCheckFunc { if !ok { return fmt.Errorf("source webhook not found: %s", name) } - _, err := materialize.ScanSource(db, r.Primary.ID) + _, err := materialize.ScanSource(db, utils.ExtractId(r.Primary.ID)) return err } } @@ -349,9 +350,9 @@ func testAccCheckAllSourceWebhookDestroyed(s *terraform.State) error { continue } - _, err := materialize.ScanSource(db, r.Primary.ID) + _, err := materialize.ScanSource(db, utils.ExtractId(r.Primary.ID)) if err == nil { - return fmt.Errorf("source %v still exists", r.Primary.ID) + return fmt.Errorf("source %v still exists", utils.ExtractId(r.Primary.ID)) } else if err != sql.ErrNoRows { return err } diff --git a/pkg/provider/acceptance_table_test.go b/pkg/provider/acceptance_table_test.go index 03e6abc3..cbda9629 100644 --- a/pkg/provider/acceptance_table_test.go +++ b/pkg/provider/acceptance_table_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -223,7 +224,7 @@ func testAccCheckTableExists(name string) resource.TestCheckFunc { if !ok { return fmt.Errorf("Table not found: %s", name) } - _, err := materialize.ScanTable(db, r.Primary.ID) + _, err := materialize.ScanTable(db, utils.ExtractId(r.Primary.ID)) return err } } @@ -236,9 +237,9 @@ func testAccCheckAllTablesDestroyed(s *terraform.State) error { continue } - _, err := materialize.ScanTable(db, r.Primary.ID) + _, err := materialize.ScanTable(db, utils.ExtractId(r.Primary.ID)) if err == nil { - return fmt.Errorf("Table %v still exists", r.Primary.ID) + return fmt.Errorf("Table %v still exists", utils.ExtractId(r.Primary.ID)) } else if err != sql.ErrNoRows { return err } diff --git a/pkg/provider/acceptance_type_test.go b/pkg/provider/acceptance_type_test.go index 0a29e98d..44faee7e 100644 --- a/pkg/provider/acceptance_type_test.go +++ b/pkg/provider/acceptance_type_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -228,7 +229,7 @@ func testAccCheckTypeExists(name string) resource.TestCheckFunc { if !ok { return fmt.Errorf("Type not found: %s", name) } - _, err := materialize.ScanType(db, r.Primary.ID) + _, err := materialize.ScanType(db, utils.ExtractId(r.Primary.ID)) return err } } @@ -241,9 +242,9 @@ func testAccCheckAllTypesDestroyed(s *terraform.State) error { continue } - _, err := materialize.ScanType(db, r.Primary.ID) + _, err := materialize.ScanType(db, utils.ExtractId(r.Primary.ID)) if err == nil { - return fmt.Errorf("Type %v still exists", r.Primary.ID) + return fmt.Errorf("Type %v still exists", utils.ExtractId(r.Primary.ID)) } else if err != sql.ErrNoRows { return err } diff --git a/pkg/provider/acceptance_view_test.go b/pkg/provider/acceptance_view_test.go index 30970a6a..fc504bb5 100644 --- a/pkg/provider/acceptance_view_test.go +++ b/pkg/provider/acceptance_view_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -142,7 +143,7 @@ func testAccCheckViewExists(name string) resource.TestCheckFunc { if !ok { return fmt.Errorf("View not found: %s", name) } - _, err := materialize.ScanView(db, r.Primary.ID) + _, err := materialize.ScanView(db, utils.ExtractId(r.Primary.ID)) return err } } @@ -155,9 +156,9 @@ func testAccCheckAllViewsDestroyed(s *terraform.State) error { continue } - _, err := materialize.ScanView(db, r.Primary.ID) + _, err := materialize.ScanView(db, utils.ExtractId(r.Primary.ID)) if err == nil { - return fmt.Errorf("View %v still exists", r.Primary.ID) + return fmt.Errorf("View %v still exists", utils.ExtractId(r.Primary.ID)) } else if err != sql.ErrNoRows { return err } diff --git a/pkg/resources/resource_cluster.go b/pkg/resources/resource_cluster.go index b586ee92..3f9dc4d7 100644 --- a/pkg/resources/resource_cluster.go +++ b/pkg/resources/resource_cluster.go @@ -6,6 +6,7 @@ import ( "log" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -37,6 +38,13 @@ var clusterSchema = map[string]*schema.Schema{ "idle_arrangement_merge_effort": IdleArrangementMergeEffortSchema(false, []string{"size"}), } +// Define the V0 schema function +func clusterSchemaV0() *schema.Resource { + return &schema.Resource{ + Schema: clusterSchema, + } +} + func Cluster() *schema.Resource { return &schema.Resource{ Description: "Clusters describe logical compute resources that can be used by sources, sinks, indexes, and materialized views. Managed clusters are created by setting the `size` attribute", @@ -50,13 +58,21 @@ func Cluster() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: clusterSchema, + Schema: clusterSchema, + SchemaVersion: 1, + StateUpgraders: []schema.StateUpgrader{ + { + Type: clusterSchemaV0().CoreConfigSchema().ImpliedType(), + Upgrade: utils.IdStateUpgradeV0, + Version: 0, + }, + }, } } func clusterRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { i := d.Id() - s, err := materialize.ScanCluster(meta.(*sqlx.DB), i) + s, err := materialize.ScanCluster(meta.(*sqlx.DB), utils.ExtractId(i)) if err == sql.ErrNoRows { d.SetId("") return nil @@ -64,7 +80,7 @@ func clusterRead(ctx context.Context, d *schema.ResourceData, meta interface{}) return diag.FromErr(err) } - d.SetId(i) + d.SetId(utils.TransformIdWithRegion(i)) if err := d.Set("name", s.ClusterName.String); err != nil { return diag.FromErr(err) @@ -163,7 +179,7 @@ func clusterCreate(ctx context.Context, d *schema.ResourceData, meta interface{} if err != nil { return diag.FromErr(err) } - d.SetId(i) + d.SetId(utils.TransformIdWithRegion(i)) return clusterRead(ctx, d, meta) } diff --git a/pkg/resources/resource_cluster_replica.go b/pkg/resources/resource_cluster_replica.go index 76a4f53e..a74d11a2 100644 --- a/pkg/resources/resource_cluster_replica.go +++ b/pkg/resources/resource_cluster_replica.go @@ -6,6 +6,7 @@ import ( "log" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -30,6 +31,13 @@ var clusterReplicaSchema = map[string]*schema.Schema{ "idle_arrangement_merge_effort": IdleArrangementMergeEffortSchema(true, []string{}), } +// Define the V0 schema function +func clusterReplicaSchemaV0() *schema.Resource { + return &schema.Resource{ + Schema: clusterReplicaSchema, + } +} + func ClusterReplica() *schema.Resource { return &schema.Resource{ Description: "Cluster replicas allocate physical compute resources for a cluster.", @@ -45,14 +53,22 @@ func ClusterReplica() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: clusterReplicaSchema, + Schema: clusterReplicaSchema, + SchemaVersion: 1, + StateUpgraders: []schema.StateUpgrader{ + { + Type: clusterReplicaSchemaV0().CoreConfigSchema().ImpliedType(), + Upgrade: utils.IdStateUpgradeV0, + Version: 0, + }, + }, } } func clusterReplicaRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { i := d.Id() - s, err := materialize.ScanClusterReplica(meta.(*sqlx.DB), i) + s, err := materialize.ScanClusterReplica(meta.(*sqlx.DB), utils.ExtractId(i)) if err == sql.ErrNoRows { d.SetId("") return nil @@ -60,7 +76,7 @@ func clusterReplicaRead(ctx context.Context, d *schema.ResourceData, meta interf return diag.FromErr(err) } - d.SetId(i) + d.SetId(utils.TransformIdWithRegion(i)) if err := d.Set("name", s.ReplicaName.String); err != nil { return diag.FromErr(err) @@ -145,7 +161,7 @@ func clusterReplicaCreate(ctx context.Context, d *schema.ResourceData, meta inte if err != nil { return diag.FromErr(err) } - d.SetId(i) + d.SetId(utils.TransformIdWithRegion(i)) return clusterReplicaRead(ctx, d, meta) } diff --git a/pkg/resources/resource_connection.go b/pkg/resources/resource_connection.go index fa69a62b..99e631ed 100644 --- a/pkg/resources/resource_connection.go +++ b/pkg/resources/resource_connection.go @@ -5,6 +5,7 @@ import ( "database/sql" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -14,7 +15,7 @@ import ( func connectionRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { i := d.Id() - s, err := materialize.ScanConnection(meta.(*sqlx.DB), i) + s, err := materialize.ScanConnection(meta.(*sqlx.DB), utils.ExtractId(i)) if err == sql.ErrNoRows { d.SetId("") return nil @@ -22,7 +23,7 @@ func connectionRead(ctx context.Context, d *schema.ResourceData, meta interface{ return diag.FromErr(err) } - d.SetId(i) + d.SetId(utils.TransformIdWithRegion(i)) if err := d.Set("name", s.ConnectionName.String); err != nil { return diag.FromErr(err) diff --git a/pkg/resources/resource_connection_aws_privatelink.go b/pkg/resources/resource_connection_aws_privatelink.go index bf4bd8fe..c23c0cd0 100644 --- a/pkg/resources/resource_connection_aws_privatelink.go +++ b/pkg/resources/resource_connection_aws_privatelink.go @@ -6,6 +6,7 @@ import ( "log" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -40,6 +41,13 @@ var connectionAwsPrivatelinkSchema = map[string]*schema.Schema{ "ownership_role": OwnershipRoleSchema(), } +// Define the V0 schema function +func connectionAwsPrivatelinkSchemaV0() *schema.Resource { + return &schema.Resource{ + Schema: connectionAwsPrivatelinkSchema, + } +} + func ConnectionAwsPrivatelink() *schema.Resource { return &schema.Resource{ Description: "An AWS PrivateLink connection establishes a link to an AWS PrivateLink service.", @@ -53,7 +61,15 @@ func ConnectionAwsPrivatelink() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: connectionAwsPrivatelinkSchema, + Schema: connectionAwsPrivatelinkSchema, + SchemaVersion: 1, + StateUpgraders: []schema.StateUpgrader{ + { + Type: connectionAwsPrivatelinkSchemaV0().CoreConfigSchema().ImpliedType(), + Upgrade: utils.IdStateUpgradeV0, + Version: 0, + }, + }, } } @@ -67,7 +83,7 @@ type ConnectionAwsPrivatelinkParams struct { func connectionAwsPrivatelinkRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { i := d.Id() - s, err := materialize.ScanConnectionAwsPrivatelink(meta.(*sqlx.DB), i) + s, err := materialize.ScanConnectionAwsPrivatelink(meta.(*sqlx.DB), utils.ExtractId(i)) if err == sql.ErrNoRows { d.SetId("") return nil @@ -75,7 +91,7 @@ func connectionAwsPrivatelinkRead(ctx context.Context, d *schema.ResourceData, m return diag.FromErr(err) } - d.SetId(i) + d.SetId(utils.TransformIdWithRegion(i)) if err := d.Set("name", s.ConnectionName.String); err != nil { return diag.FromErr(err) @@ -158,7 +174,7 @@ func connectionAwsPrivatelinkCreate(ctx context.Context, d *schema.ResourceData, if err != nil { return diag.FromErr(err) } - d.SetId(i) + d.SetId(utils.TransformIdWithRegion(i)) return connectionAwsPrivatelinkRead(ctx, d, meta) } diff --git a/pkg/resources/resource_connection_confluent_schema_registry.go b/pkg/resources/resource_connection_confluent_schema_registry.go index f2cace1c..1a7a52cd 100644 --- a/pkg/resources/resource_connection_confluent_schema_registry.go +++ b/pkg/resources/resource_connection_confluent_schema_registry.go @@ -5,6 +5,7 @@ import ( "log" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -33,6 +34,13 @@ var connectionConfluentSchemaRegistrySchema = map[string]*schema.Schema{ "ownership_role": OwnershipRoleSchema(), } +// Define the V0 schema function +func connectionConfluentSchemaRegistrySchemaV0() *schema.Resource { + return &schema.Resource{ + Schema: connectionConfluentSchemaRegistrySchema, + } +} + func ConnectionConfluentSchemaRegistry() *schema.Resource { return &schema.Resource{ Description: "A Confluent Schema Registry connection establishes a link to a Confluent Schema Registry server.", @@ -46,7 +54,15 @@ func ConnectionConfluentSchemaRegistry() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: connectionConfluentSchemaRegistrySchema, + Schema: connectionConfluentSchemaRegistrySchema, + SchemaVersion: 1, + StateUpgraders: []schema.StateUpgrader{ + { + Type: connectionConfluentSchemaRegistrySchemaV0().CoreConfigSchema().ImpliedType(), + Upgrade: utils.IdStateUpgradeV0, + Version: 0, + }, + }, } } @@ -133,7 +149,7 @@ func connectionConfluentSchemaRegistryCreate(ctx context.Context, d *schema.Reso if err != nil { return diag.FromErr(err) } - d.SetId(i) + d.SetId(utils.TransformIdWithRegion(i)) return connectionRead(ctx, d, meta) } diff --git a/pkg/resources/resource_connection_kafka.go b/pkg/resources/resource_connection_kafka.go index c4e163fe..99211d62 100644 --- a/pkg/resources/resource_connection_kafka.go +++ b/pkg/resources/resource_connection_kafka.go @@ -6,6 +6,7 @@ import ( "strings" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -84,6 +85,13 @@ var connectionKafkaSchema = map[string]*schema.Schema{ "ownership_role": OwnershipRoleSchema(), } +// Define the V0 schema function +func connectionKafkaSchemaV0() *schema.Resource { + return &schema.Resource{ + Schema: connectionKafkaSchema, + } +} + func ConnectionKafka() *schema.Resource { return &schema.Resource{ Description: "A Kafka connection establishes a link to a Kafka cluster.", @@ -97,7 +105,15 @@ func ConnectionKafka() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: connectionKafkaSchema, + Schema: connectionKafkaSchema, + SchemaVersion: 1, + StateUpgraders: []schema.StateUpgrader{ + { + Type: connectionKafkaSchemaV0().CoreConfigSchema().ImpliedType(), + Upgrade: utils.IdStateUpgradeV0, + Version: 0, + }, + }, } } @@ -192,7 +208,7 @@ func connectionKafkaCreate(ctx context.Context, d *schema.ResourceData, meta int if err != nil { return diag.FromErr(err) } - d.SetId(i) + d.SetId(utils.TransformIdWithRegion(i)) return connectionRead(ctx, d, meta) } diff --git a/pkg/resources/resource_connection_postgres.go b/pkg/resources/resource_connection_postgres.go index eb1923aa..822979c0 100644 --- a/pkg/resources/resource_connection_postgres.go +++ b/pkg/resources/resource_connection_postgres.go @@ -5,6 +5,7 @@ import ( "log" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -53,6 +54,13 @@ var connectionPostgresSchema = map[string]*schema.Schema{ "ownership_role": OwnershipRoleSchema(), } +// Define the V0 schema function +func connectionPostgresSchemaV0() *schema.Resource { + return &schema.Resource{ + Schema: connectionPostgresSchema, + } +} + func ConnectionPostgres() *schema.Resource { return &schema.Resource{ Description: "A Postgres connection establishes a link to a single database of a PostgreSQL server.", @@ -66,7 +74,15 @@ func ConnectionPostgres() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: connectionPostgresSchema, + Schema: connectionPostgresSchema, + SchemaVersion: 1, + StateUpgraders: []schema.StateUpgrader{ + { + Type: connectionPostgresSchemaV0().CoreConfigSchema().ImpliedType(), + Upgrade: utils.IdStateUpgradeV0, + Version: 0, + }, + }, } } @@ -169,7 +185,7 @@ func connectionPostgresCreate(ctx context.Context, d *schema.ResourceData, meta if err != nil { return diag.FromErr(err) } - d.SetId(i) + d.SetId(utils.TransformIdWithRegion(i)) return connectionRead(ctx, d, meta) } diff --git a/pkg/resources/resource_connection_ssh_tunnel.go b/pkg/resources/resource_connection_ssh_tunnel.go index a9551818..6e8deea7 100644 --- a/pkg/resources/resource_connection_ssh_tunnel.go +++ b/pkg/resources/resource_connection_ssh_tunnel.go @@ -6,6 +6,7 @@ import ( "log" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -49,6 +50,13 @@ var connectionSshTunnelSchema = map[string]*schema.Schema{ "ownership_role": OwnershipRoleSchema(), } +// Define the V0 schema function +func connectionSshTunnelSchemaV0() *schema.Resource { + return &schema.Resource{ + Schema: connectionSshTunnelSchema, + } +} + func ConnectionSshTunnel() *schema.Resource { return &schema.Resource{ Description: "An SSH tunnel connection establishes a link to an SSH bastion server.", @@ -62,14 +70,22 @@ func ConnectionSshTunnel() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: connectionSshTunnelSchema, + Schema: connectionSshTunnelSchema, + SchemaVersion: 1, + StateUpgraders: []schema.StateUpgrader{ + { + Type: connectionSshTunnelSchemaV0().CoreConfigSchema().ImpliedType(), + Upgrade: utils.IdStateUpgradeV0, + Version: 0, + }, + }, } } func connectionSshTunnelRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { i := d.Id() - s, err := materialize.ScanConnectionSshTunnel(meta.(*sqlx.DB), i) + s, err := materialize.ScanConnectionSshTunnel(meta.(*sqlx.DB), utils.ExtractId(i)) if err == sql.ErrNoRows { d.SetId("") return nil @@ -77,7 +93,7 @@ func connectionSshTunnelRead(ctx context.Context, d *schema.ResourceData, meta i return diag.FromErr(err) } - d.SetId(i) + d.SetId(utils.TransformIdWithRegion(i)) if err := d.Set("name", s.ConnectionName.String); err != nil { return diag.FromErr(err) @@ -159,7 +175,7 @@ func connectionSshTunnelCreate(ctx context.Context, d *schema.ResourceData, meta if err != nil { return diag.FromErr(err) } - d.SetId(i) + d.SetId(utils.TransformIdWithRegion(i)) return connectionSshTunnelRead(ctx, d, meta) } diff --git a/pkg/resources/resource_database.go b/pkg/resources/resource_database.go index 3bcfb980..911d6da9 100644 --- a/pkg/resources/resource_database.go +++ b/pkg/resources/resource_database.go @@ -117,7 +117,6 @@ func databaseCreate(ctx context.Context, d *schema.ResourceData, meta interface{ if err != nil { return diag.FromErr(err) } - d.SetId(utils.TransformIdWithRegion(i)) return databaseRead(ctx, d, meta) diff --git a/pkg/resources/resource_index.go b/pkg/resources/resource_index.go index 73478097..b3ee35e6 100644 --- a/pkg/resources/resource_index.go +++ b/pkg/resources/resource_index.go @@ -6,6 +6,7 @@ import ( "log" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -72,6 +73,13 @@ var indexSchema = map[string]*schema.Schema{ }, } +// Define the V0 schema function +func indexSchemaV0() *schema.Resource { + return &schema.Resource{ + Schema: indexSchema, + } +} + func Index() *schema.Resource { return &schema.Resource{ Description: "Indexes represent query results stored in memory.", @@ -85,13 +93,21 @@ func Index() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: indexSchema, + Schema: indexSchema, + SchemaVersion: 1, + StateUpgraders: []schema.StateUpgrader{ + { + Type: indexSchemaV0().CoreConfigSchema().ImpliedType(), + Upgrade: utils.IdStateUpgradeV0, + Version: 0, + }, + }, } } func indexRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { i := d.Id() - s, err := materialize.ScanIndex(meta.(*sqlx.DB), i) + s, err := materialize.ScanIndex(meta.(*sqlx.DB), utils.ExtractId(i)) if err == sql.ErrNoRows { d.SetId("") return nil @@ -99,7 +115,7 @@ func indexRead(ctx context.Context, d *schema.ResourceData, meta interface{}) di return diag.FromErr(err) } - d.SetId(i) + d.SetId(utils.TransformIdWithRegion(i)) if err := d.Set("name", s.IndexName.String); err != nil { return diag.FromErr(err) @@ -192,7 +208,7 @@ func indexCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) if err != nil { return diag.FromErr(err) } - d.SetId(i) + d.SetId(utils.TransformIdWithRegion(i)) return indexRead(ctx, d, meta) } diff --git a/pkg/resources/resource_materialized_view.go b/pkg/resources/resource_materialized_view.go index 19a7204e..ad65b3fc 100644 --- a/pkg/resources/resource_materialized_view.go +++ b/pkg/resources/resource_materialized_view.go @@ -6,6 +6,7 @@ import ( "log" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -43,6 +44,13 @@ var materializedViewSchema = map[string]*schema.Schema{ "ownership_role": OwnershipRoleSchema(), } +// Define the V0 schema function +func materializedViewSchemaV0() *schema.Resource { + return &schema.Resource{ + Schema: materializedViewSchema, + } +} + func MaterializedView() *schema.Resource { return &schema.Resource{ Description: "Materialized views represent query results stored durably.", @@ -56,14 +64,22 @@ func MaterializedView() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: materializedViewSchema, + Schema: materializedViewSchema, + SchemaVersion: 1, + StateUpgraders: []schema.StateUpgrader{ + { + Type: materializedViewSchemaV0().CoreConfigSchema().ImpliedType(), + Upgrade: utils.IdStateUpgradeV0, + Version: 0, + }, + }, } } func materializedViewRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { i := d.Id() - s, err := materialize.ScanMaterializedView(meta.(*sqlx.DB), i) + s, err := materialize.ScanMaterializedView(meta.(*sqlx.DB), utils.ExtractId(i)) if err == sql.ErrNoRows { d.SetId("") return nil @@ -71,7 +87,7 @@ func materializedViewRead(ctx context.Context, d *schema.ResourceData, meta inte return diag.FromErr(err) } - d.SetId(i) + d.SetId(utils.TransformIdWithRegion(i)) if err := d.Set("name", s.MaterializedViewName.String); err != nil { return diag.FromErr(err) @@ -158,7 +174,7 @@ func materializedViewCreate(ctx context.Context, d *schema.ResourceData, meta in if err != nil { return diag.FromErr(err) } - d.SetId(i) + d.SetId(utils.TransformIdWithRegion(i)) return materializedViewRead(ctx, d, meta) } diff --git a/pkg/resources/resource_role.go b/pkg/resources/resource_role.go index 7118cd68..0b341288 100644 --- a/pkg/resources/resource_role.go +++ b/pkg/resources/resource_role.go @@ -6,6 +6,7 @@ import ( "log" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -23,6 +24,13 @@ var roleSchema = map[string]*schema.Schema{ }, } +// Define the V0 schema function +func roleSchemaV0() *schema.Resource { + return &schema.Resource{ + Schema: roleSchema, + } +} + func Role() *schema.Resource { return &schema.Resource{ Description: "A role is a collection of privileges you can apply to users.", @@ -36,13 +44,21 @@ func Role() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: roleSchema, + Schema: roleSchema, + SchemaVersion: 1, + StateUpgraders: []schema.StateUpgrader{ + { + Type: roleSchemaV0().CoreConfigSchema().ImpliedType(), + Upgrade: utils.IdStateUpgradeV0, + Version: 0, + }, + }, } } func roleRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { i := d.Id() - s, err := materialize.ScanRole(meta.(*sqlx.DB), i) + s, err := materialize.ScanRole(meta.(*sqlx.DB), utils.ExtractId(i)) if err == sql.ErrNoRows { d.SetId("") return nil @@ -50,7 +66,7 @@ func roleRead(ctx context.Context, d *schema.ResourceData, meta interface{}) dia return diag.FromErr(err) } - d.SetId(i) + d.SetId(utils.TransformIdWithRegion(i)) if err := d.Set("name", s.RoleName.String); err != nil { return diag.FromErr(err) @@ -103,7 +119,7 @@ func roleCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) d if err != nil { return diag.FromErr(err) } - d.SetId(i) + d.SetId(utils.TransformIdWithRegion(i)) return roleRead(ctx, d, meta) } diff --git a/pkg/resources/resource_schema.go b/pkg/resources/resource_schema.go index 7fdf74f7..46bd936a 100644 --- a/pkg/resources/resource_schema.go +++ b/pkg/resources/resource_schema.go @@ -6,6 +6,7 @@ import ( "log" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -39,7 +40,7 @@ func Schema() *schema.Resource { func schemaRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { i := d.Id() - s, err := materialize.ScanSchema(meta.(*sqlx.DB), i) + s, err := materialize.ScanSchema(meta.(*sqlx.DB), utils.ExtractId(i)) if err == sql.ErrNoRows { d.SetId("") return nil @@ -47,7 +48,7 @@ func schemaRead(ctx context.Context, d *schema.ResourceData, meta interface{}) d return diag.FromErr(err) } - d.SetId(i) + d.SetId(utils.TransformIdWithRegion(i)) if err := d.Set("name", s.SchemaName.String); err != nil { return diag.FromErr(err) @@ -112,7 +113,7 @@ func schemaCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) if err != nil { return diag.FromErr(err) } - d.SetId(i) + d.SetId(utils.TransformIdWithRegion(i)) return schemaRead(ctx, d, meta) } diff --git a/pkg/resources/resource_secret.go b/pkg/resources/resource_secret.go index f199e6de..32d4fcee 100644 --- a/pkg/resources/resource_secret.go +++ b/pkg/resources/resource_secret.go @@ -6,6 +6,7 @@ import ( "log" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -27,6 +28,13 @@ var secretSchema = map[string]*schema.Schema{ "ownership_role": OwnershipRoleSchema(), } +// Define the V0 schema function +func secretSchemaV0() *schema.Resource { + return &schema.Resource{ + Schema: secretSchema, + } +} + func Secret() *schema.Resource { return &schema.Resource{ Description: "A secret securely stores sensitive credentials (like passwords and SSL keys) in Materialize’s secret management system.", @@ -40,14 +48,22 @@ func Secret() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: secretSchema, + Schema: secretSchema, + SchemaVersion: 1, + StateUpgraders: []schema.StateUpgrader{ + { + Type: secretSchemaV0().CoreConfigSchema().ImpliedType(), + Upgrade: utils.IdStateUpgradeV0, + Version: 0, + }, + }, } } func secretRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { i := d.Id() - s, err := materialize.ScanSecret(meta.(*sqlx.DB), i) + s, err := materialize.ScanSecret(meta.(*sqlx.DB), utils.ExtractId(i)) if err == sql.ErrNoRows { d.SetId("") return nil @@ -55,7 +71,7 @@ func secretRead(ctx context.Context, d *schema.ResourceData, meta interface{}) d return diag.FromErr(err) } - d.SetId(i) + d.SetId(utils.TransformIdWithRegion(i)) if err := d.Set("name", s.SecretName.String); err != nil { return diag.FromErr(err) @@ -129,7 +145,7 @@ func secretCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) if err != nil { return diag.FromErr(err) } - d.SetId(i) + d.SetId(utils.TransformIdWithRegion(i)) return secretRead(ctx, d, meta) } diff --git a/pkg/resources/resource_sink.go b/pkg/resources/resource_sink.go index f3a797cd..29716992 100644 --- a/pkg/resources/resource_sink.go +++ b/pkg/resources/resource_sink.go @@ -5,6 +5,7 @@ import ( "database/sql" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -14,7 +15,7 @@ import ( func sinkRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { i := d.Id() - s, err := materialize.ScanSink(meta.(*sqlx.DB), i) + s, err := materialize.ScanSink(meta.(*sqlx.DB), utils.ExtractId(i)) if err == sql.ErrNoRows { d.SetId("") return nil @@ -22,7 +23,7 @@ func sinkRead(ctx context.Context, d *schema.ResourceData, meta interface{}) dia return diag.FromErr(err) } - d.SetId(i) + d.SetId(utils.TransformIdWithRegion(i)) if err := d.Set("name", s.SinkName.String); err != nil { return diag.FromErr(err) diff --git a/pkg/resources/resource_sink_kafka.go b/pkg/resources/resource_sink_kafka.go index 4d4a458a..a16ff696 100644 --- a/pkg/resources/resource_sink_kafka.go +++ b/pkg/resources/resource_sink_kafka.go @@ -5,6 +5,7 @@ import ( "log" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -77,6 +78,13 @@ var sinkKafkaSchema = map[string]*schema.Schema{ }, } +// Define the V0 schema function +func sinkKafkaSchemaV0() *schema.Resource { + return &schema.Resource{ + Schema: sinkKafkaSchema, + } +} + func SinkKafka() *schema.Resource { return &schema.Resource{ Description: "A Kafka sink establishes a link to a Kafka cluster that you want Materialize to write data to.", @@ -90,7 +98,15 @@ func SinkKafka() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: sinkKafkaSchema, + Schema: sinkKafkaSchema, + SchemaVersion: 1, + StateUpgraders: []schema.StateUpgrader{ + { + Type: sinkKafkaSchemaV0().CoreConfigSchema().ImpliedType(), + Upgrade: utils.IdStateUpgradeV0, + Version: 0, + }, + }, } } @@ -179,7 +195,7 @@ func sinkKafkaCreate(ctx context.Context, d *schema.ResourceData, meta any) diag if err != nil { return diag.FromErr(err) } - d.SetId(i) + d.SetId(utils.TransformIdWithRegion(i)) return sinkRead(ctx, d, meta) } diff --git a/pkg/resources/resource_source.go b/pkg/resources/resource_source.go index c42a7c01..36db1086 100644 --- a/pkg/resources/resource_source.go +++ b/pkg/resources/resource_source.go @@ -5,6 +5,7 @@ import ( "database/sql" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -14,7 +15,7 @@ import ( func sourceRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { i := d.Id() - s, err := materialize.ScanSource(meta.(*sqlx.DB), i) + s, err := materialize.ScanSource(meta.(*sqlx.DB), utils.ExtractId(i)) if err == sql.ErrNoRows { d.SetId("") return nil @@ -22,7 +23,7 @@ func sourceRead(ctx context.Context, d *schema.ResourceData, meta interface{}) d return diag.FromErr(err) } - d.SetId(i) + d.SetId(utils.TransformIdWithRegion(i)) if err := d.Set("name", s.SourceName.String); err != nil { return diag.FromErr(err) diff --git a/pkg/resources/resource_source_kafka.go b/pkg/resources/resource_source_kafka.go index 3c954e59..a96f568a 100644 --- a/pkg/resources/resource_source_kafka.go +++ b/pkg/resources/resource_source_kafka.go @@ -5,6 +5,7 @@ import ( "log" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -142,6 +143,13 @@ var sourceKafkaSchema = map[string]*schema.Schema{ "ownership_role": OwnershipRoleSchema(), } +// Define the V0 schema function +func sourceKafkaSchemaV0() *schema.Resource { + return &schema.Resource{ + Schema: sourceKafkaSchema, + } +} + func SourceKafka() *schema.Resource { return &schema.Resource{ Description: "A Kafka source describes a Kafka cluster you want Materialize to read data from.", @@ -155,7 +163,15 @@ func SourceKafka() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: sourceKafkaSchema, + Schema: sourceKafkaSchema, + SchemaVersion: 1, + StateUpgraders: []schema.StateUpgrader{ + { + Type: sourceKafkaSchemaV0().CoreConfigSchema().ImpliedType(), + Upgrade: utils.IdStateUpgradeV0, + Version: 0, + }, + }, } } @@ -290,7 +306,7 @@ func sourceKafkaCreate(ctx context.Context, d *schema.ResourceData, meta any) di if err != nil { return diag.FromErr(err) } - d.SetId(i) + d.SetId(utils.TransformIdWithRegion(i)) return sourceRead(ctx, d, meta) } diff --git a/pkg/resources/resource_source_load_generator.go b/pkg/resources/resource_source_load_generator.go index 34589543..1fa0783b 100644 --- a/pkg/resources/resource_source_load_generator.go +++ b/pkg/resources/resource_source_load_generator.go @@ -6,6 +6,7 @@ import ( "log" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -114,6 +115,13 @@ var sourceLoadgenSchema = map[string]*schema.Schema{ "ownership_role": OwnershipRoleSchema(), } +// Define the V0 schema function +func sourceLoadgenSchemaV0() *schema.Resource { + return &schema.Resource{ + Schema: sourceLoadgenSchema, + } +} + func SourceLoadgen() *schema.Resource { return &schema.Resource{ Description: "A load generator source produces synthetic data for use in demos and performance tests.", @@ -127,7 +135,15 @@ func SourceLoadgen() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: sourceLoadgenSchema, + Schema: sourceLoadgenSchema, + SchemaVersion: 1, + StateUpgraders: []schema.StateUpgrader{ + { + Type: sourceLoadgenSchemaV0().CoreConfigSchema().ImpliedType(), + Upgrade: utils.IdStateUpgradeV0, + Version: 0, + }, + }, } } @@ -208,7 +224,7 @@ func sourceLoadgenCreate(ctx context.Context, d *schema.ResourceData, meta any) if err != nil { return diag.FromErr(err) } - d.SetId(i) + d.SetId(utils.TransformIdWithRegion(i)) return sourceRead(ctx, d, meta) } diff --git a/pkg/resources/resource_source_postgres.go b/pkg/resources/resource_source_postgres.go index 435bc629..d41c26b8 100644 --- a/pkg/resources/resource_source_postgres.go +++ b/pkg/resources/resource_source_postgres.go @@ -5,6 +5,7 @@ import ( "log" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -67,6 +68,13 @@ var sourcePostgresSchema = map[string]*schema.Schema{ "ownership_role": OwnershipRoleSchema(), } +// Define the V0 schema function +func sourcePostgresSchemaV0() *schema.Resource { + return &schema.Resource{ + Schema: databaseSchema, + } +} + func SourcePostgres() *schema.Resource { return &schema.Resource{ Description: "A Postgres source describes a PostgreSQL instance you want Materialize to read data from.", @@ -80,7 +88,15 @@ func SourcePostgres() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: sourcePostgresSchema, + Schema: sourcePostgresSchema, + SchemaVersion: 1, + StateUpgraders: []schema.StateUpgrader{ + { + Type: sourcePostgresSchemaV0().CoreConfigSchema().ImpliedType(), + Upgrade: utils.IdStateUpgradeV0, + Version: 0, + }, + }, } } @@ -161,7 +177,7 @@ func sourcePostgresCreate(ctx context.Context, d *schema.ResourceData, meta any) if err != nil { return diag.FromErr(err) } - d.SetId(i) + d.SetId(utils.TransformIdWithRegion(i)) return sourceRead(ctx, d, meta) } diff --git a/pkg/resources/resource_source_webhook.go b/pkg/resources/resource_source_webhook.go index 9d153625..07d43ced 100644 --- a/pkg/resources/resource_source_webhook.go +++ b/pkg/resources/resource_source_webhook.go @@ -5,6 +5,7 @@ import ( "log" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" @@ -151,6 +152,13 @@ var sourceWebhookSchema = map[string]*schema.Schema{ "ownership_role": OwnershipRoleSchema(), } +// Define the V0 schema function +func sourceWebhookSchemaV0() *schema.Resource { + return &schema.Resource{ + Schema: sourceWebhookSchema, + } +} + func SourceWebhook() *schema.Resource { return &schema.Resource{ Description: "**Private Preview** A webhook source describes a webhook you want Materialize to read data from.", @@ -164,7 +172,15 @@ func SourceWebhook() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: sourceWebhookSchema, + Schema: sourceWebhookSchema, + SchemaVersion: 1, + StateUpgraders: []schema.StateUpgrader{ + { + Type: sourceWebhookSchemaV0().CoreConfigSchema().ImpliedType(), + Upgrade: utils.IdStateUpgradeV0, + Version: 0, + }, + }, } } @@ -272,7 +288,7 @@ func sourceWebhookCreate(ctx context.Context, d *schema.ResourceData, meta inter if err != nil { return diag.FromErr(err) } - d.SetId(i) + d.SetId(utils.TransformIdWithRegion(i)) return sourceRead(ctx, d, meta) } diff --git a/pkg/resources/resource_table.go b/pkg/resources/resource_table.go index 0beafc71..c1c34dc0 100644 --- a/pkg/resources/resource_table.go +++ b/pkg/resources/resource_table.go @@ -6,6 +6,7 @@ import ( "log" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -66,6 +67,13 @@ var tableSchema = map[string]*schema.Schema{ "ownership_role": OwnershipRoleSchema(), } +// Define the V0 schema function +func tableSchemaV0() *schema.Resource { + return &schema.Resource{ + Schema: tableSchema, + } +} + func Table() *schema.Resource { return &schema.Resource{ Description: "A table persists durable storage that can be written to, updated and seamlessly joined with other tables, views or sources", @@ -79,14 +87,22 @@ func Table() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: tableSchema, + Schema: tableSchema, + SchemaVersion: 1, + StateUpgraders: []schema.StateUpgrader{ + { + Type: tableSchemaV0().CoreConfigSchema().ImpliedType(), + Upgrade: utils.IdStateUpgradeV0, + Version: 0, + }, + }, } } func tableRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { i := d.Id() - s, err := materialize.ScanTable(meta.(*sqlx.DB), i) + s, err := materialize.ScanTable(meta.(*sqlx.DB), utils.ExtractId(i)) if err == sql.ErrNoRows { d.SetId("") return nil @@ -94,7 +110,7 @@ func tableRead(ctx context.Context, d *schema.ResourceData, meta interface{}) di return diag.FromErr(err) } - d.SetId(i) + d.SetId(utils.TransformIdWithRegion(i)) if err := d.Set("name", s.TableName.String); err != nil { return diag.FromErr(err) @@ -208,7 +224,7 @@ func tableCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) return diag.FromErr(err) } - d.SetId(i) + d.SetId(utils.TransformIdWithRegion(i)) return tableRead(ctx, d, meta) } diff --git a/pkg/resources/resource_type.go b/pkg/resources/resource_type.go index 257d674c..d50bcb37 100644 --- a/pkg/resources/resource_type.go +++ b/pkg/resources/resource_type.go @@ -6,6 +6,7 @@ import ( "log" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -89,6 +90,13 @@ var typeSchema = map[string]*schema.Schema{ "ownership_role": OwnershipRoleSchema(), } +// Define the V0 schema function +func typeSchemaV0() *schema.Resource { + return &schema.Resource{ + Schema: typeSchema, + } +} + func Type() *schema.Resource { return &schema.Resource{ Description: "A custom types, which let you create named versions of anonymous types.", @@ -102,14 +110,22 @@ func Type() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: typeSchema, + Schema: typeSchema, + SchemaVersion: 1, + StateUpgraders: []schema.StateUpgrader{ + { + Type: typeSchemaV0().CoreConfigSchema().ImpliedType(), + Upgrade: utils.IdStateUpgradeV0, + Version: 0, + }, + }, } } func typeRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { i := d.Id() - s, err := materialize.ScanType(meta.(*sqlx.DB), i) + s, err := materialize.ScanType(meta.(*sqlx.DB), utils.ExtractId(i)) if err == sql.ErrNoRows { d.SetId("") return nil @@ -117,7 +133,7 @@ func typeRead(ctx context.Context, d *schema.ResourceData, meta interface{}) dia return diag.FromErr(err) } - d.SetId(i) + d.SetId(utils.TransformIdWithRegion(i)) if err := d.Set("name", s.TypeName.String); err != nil { return diag.FromErr(err) @@ -206,7 +222,7 @@ func typeCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) d if err != nil { return diag.FromErr(err) } - d.SetId(i) + d.SetId(utils.TransformIdWithRegion(i)) return typeRead(ctx, d, meta) } diff --git a/pkg/resources/resource_view.go b/pkg/resources/resource_view.go index d25730ed..cbb15f90 100644 --- a/pkg/resources/resource_view.go +++ b/pkg/resources/resource_view.go @@ -6,6 +6,7 @@ import ( "log" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -27,6 +28,13 @@ var viewSchema = map[string]*schema.Schema{ "ownership_role": OwnershipRoleSchema(), } +// Define the V0 schema function +func viewSchemaV0() *schema.Resource { + return &schema.Resource{ + Schema: viewSchema, + } +} + func View() *schema.Resource { return &schema.Resource{ Description: "Views represent queries of sources and other views that you want to save for repeated execution.", @@ -40,14 +48,22 @@ func View() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: viewSchema, + Schema: viewSchema, + SchemaVersion: 1, + StateUpgraders: []schema.StateUpgrader{ + { + Type: viewSchemaV0().CoreConfigSchema().ImpliedType(), + Upgrade: utils.IdStateUpgradeV0, + Version: 0, + }, + }, } } func viewRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { i := d.Id() - s, err := materialize.ScanView(meta.(*sqlx.DB), i) + s, err := materialize.ScanView(meta.(*sqlx.DB), utils.ExtractId(i)) if err == sql.ErrNoRows { d.SetId("") return nil @@ -55,7 +71,7 @@ func viewRead(ctx context.Context, d *schema.ResourceData, meta interface{}) dia return diag.FromErr(err) } - d.SetId(i) + d.SetId(utils.TransformIdWithRegion(i)) if err := d.Set("name", s.ViewName.String); err != nil { return diag.FromErr(err) @@ -129,7 +145,7 @@ func viewCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) d if err != nil { return diag.FromErr(err) } - d.SetId(i) + d.SetId(utils.TransformIdWithRegion(i)) return viewRead(ctx, d, meta) } From 708cdd9f2f49f4fb58865fa7951c92f74481fa17 Mon Sep 17 00:00:00 2001 From: bobbyiliev Date: Wed, 6 Dec 2023 18:17:24 +0000 Subject: [PATCH 02/10] Terraform Docs --- docs/resources/cluster.md | 3 ++- docs/resources/cluster_replica | 3 ++- docs/resources/cluster_replica.md | 3 ++- docs/resources/connection_aws_privatelink.md | 3 ++- docs/resources/connection_confluent_schema_registry.md | 3 ++- docs/resources/connection_kafka.md | 5 +++-- docs/resources/connection_postgres.md | 5 ++++- docs/resources/connection_ssh_tunnel.md | 3 ++- docs/resources/index.md | 3 ++- docs/resources/materialized_view.md | 3 ++- docs/resources/role.md | 3 ++- docs/resources/schema.md | 3 ++- docs/resources/secret.md | 3 ++- docs/resources/sink_kafka.md | 3 ++- docs/resources/source_kafka.md | 3 ++- docs/resources/source_load_generator.md | 3 ++- docs/resources/source_postgres.md | 3 ++- docs/resources/source_webhook.md | 3 ++- docs/resources/table.md | 3 ++- docs/resources/type.md | 4 +++- docs/resources/view.md | 3 ++- 21 files changed, 46 insertions(+), 22 deletions(-) diff --git a/docs/resources/cluster.md b/docs/resources/cluster.md index 3479eba6..c19662a2 100644 --- a/docs/resources/cluster.md +++ b/docs/resources/cluster.md @@ -46,7 +46,8 @@ Import is supported using the following syntax: ```shell # Clusters can be imported using the cluster id: -terraform import materialize_cluster.example_cluster +terraform import materialize_cluster.example_cluster : # Cluster id and information be found in the `mz_catalog.mz_clusters` table +# The region is the region where the database is located (e.g. aws/us-east-1) ``` diff --git a/docs/resources/cluster_replica b/docs/resources/cluster_replica index 45c9114c..23b759ef 100644 --- a/docs/resources/cluster_replica +++ b/docs/resources/cluster_replica @@ -46,7 +46,8 @@ Import is supported using the following syntax: ```shell # Cluster replicas can be imported using the cluster replica id: -terraform import materialize_cluster_replica.example_1_cluster_replica +terraform import materialize_cluster_replica.example_1_cluster_replica : # Cluster replica id and information be found in the `mz_catalog.mz_cluster_replicas` table +# The region is the region where the database is located (e.g. aws/us-east-1) ``` \ No newline at end of file diff --git a/docs/resources/cluster_replica.md b/docs/resources/cluster_replica.md index db6cf23f..d0d35da8 100644 --- a/docs/resources/cluster_replica.md +++ b/docs/resources/cluster_replica.md @@ -48,7 +48,8 @@ Import is supported using the following syntax: ```shell # Cluster replicas can be imported using the cluster replica id: -terraform import materialize_cluster_replica.example_1_cluster_replica +terraform import materialize_cluster_replica.example_1_cluster_replica : # Cluster replica id and information be found in the `mz_catalog.mz_cluster_replicas` table +# The region is the region where the database is located (e.g. aws/us-east-1) ``` diff --git a/docs/resources/connection_aws_privatelink.md b/docs/resources/connection_aws_privatelink.md index 95369632..9cc8d165 100644 --- a/docs/resources/connection_aws_privatelink.md +++ b/docs/resources/connection_aws_privatelink.md @@ -57,7 +57,8 @@ Import is supported using the following syntax: ```shell #Connections can be imported using the connection id: -terraform import materialize_connection_aws_privatelink.example +terraform import materialize_connection_aws_privatelink.example : # Connection id and information be found in the `mz_catalog.mz_connections` table +# The region is the region where the database is located (e.g. aws/us-east-1) ``` diff --git a/docs/resources/connection_confluent_schema_registry.md b/docs/resources/connection_confluent_schema_registry.md index 409bc060..b33949e4 100644 --- a/docs/resources/connection_confluent_schema_registry.md +++ b/docs/resources/connection_confluent_schema_registry.md @@ -184,7 +184,8 @@ Import is supported using the following syntax: ```shell #Connections can be imported using the connection id: -terraform import materialize_connection_confluent_schema_registry.example +terraform import materialize_connection_confluent_schema_registry.example : # Connection id and information be found in the `mz_catalog.mz_connections` table +# The region is the region where the database is located (e.g. aws/us-east-1) ``` diff --git a/docs/resources/connection_kafka.md b/docs/resources/connection_kafka.md index 02c7f010..3443642d 100644 --- a/docs/resources/connection_kafka.md +++ b/docs/resources/connection_kafka.md @@ -251,8 +251,9 @@ Optional: Import is supported using the following syntax: ```shell -#Connections can be imported using the connection id: -terraform import materialize_connection_kafka.example +# Connections can be imported using the connection id: +terraform import materialize_connection_kafka.example : # Connection id and information be found in the `mz_catalog.mz_connections` table +# The region is the region where the database is located (e.g. aws/us-east-1) ``` diff --git a/docs/resources/connection_postgres.md b/docs/resources/connection_postgres.md index 1b95ead0..ad8f0ed3 100644 --- a/docs/resources/connection_postgres.md +++ b/docs/resources/connection_postgres.md @@ -226,5 +226,8 @@ Import is supported using the following syntax: ```shell # Connections can be imported using the connection id: -terraform import materialize_connection_postgres.example +terraform import materialize_connection_postgres.example : + +# Connection id and information be found in the `mz_catalog.mz_connections` table +# The region is the region where the database is located (e.g. aws/us-east-1) ``` diff --git a/docs/resources/connection_ssh_tunnel.md b/docs/resources/connection_ssh_tunnel.md index 0bf18356..959e81b9 100644 --- a/docs/resources/connection_ssh_tunnel.md +++ b/docs/resources/connection_ssh_tunnel.md @@ -59,7 +59,8 @@ Import is supported using the following syntax: ```shell #Connections can be imported using the connection id: -terraform import materialize_connection_ssh_tunnel.example +terraform import materialize_connection_ssh_tunnel.example : # Connection id and information be found in the `mz_catalog.mz_connections` table +# The region is the region where the database is located (e.g. aws/us-east-1) ``` diff --git a/docs/resources/index.md b/docs/resources/index.md index bc644646..a2819a58 100644 --- a/docs/resources/index.md +++ b/docs/resources/index.md @@ -80,7 +80,8 @@ Import is supported using the following syntax: ```shell # Indexes can be imported using the index id: -terraform import materialize_index.example_index +terraform import materialize_index.example_index : # Index id and information be found in the `mz_catalog.mz_indexes` table +# The region is the region where the database is located (e.g. aws/us-east-1) ``` diff --git a/docs/resources/materialized_view.md b/docs/resources/materialized_view.md index 308e3f6c..db6d4b48 100644 --- a/docs/resources/materialized_view.md +++ b/docs/resources/materialized_view.md @@ -65,7 +65,8 @@ Import is supported using the following syntax: ```shell # Materialized views can be imported using the materialized view id: -terraform import materialize_materialized_view.example_materialize_view +terraform import materialize_materialized_view.example_materialize_view : # Materialized view id and information be found in the `mz_catalog.mz_materialized_views` table +# The region is the region where the database is located (e.g. aws/us-east-1) ``` diff --git a/docs/resources/role.md b/docs/resources/role.md index e0578ddb..b46d62dc 100644 --- a/docs/resources/role.md +++ b/docs/resources/role.md @@ -41,7 +41,8 @@ Import is supported using the following syntax: ```shell # Roles can be imported using the role id: -terraform import materialize_role.example_role +terraform import materialize_role.example_role : # Role id and information be found in the `mz_catalog.mz_roles` table +# The region is the region where the database is located (e.g. aws/us-east-1) ``` diff --git a/docs/resources/schema.md b/docs/resources/schema.md index 2dac0d8b..fdcdecee 100644 --- a/docs/resources/schema.md +++ b/docs/resources/schema.md @@ -43,7 +43,8 @@ Import is supported using the following syntax: ```shell # Schemas can be imported using the schema id: -terraform import materialize_schema.example_schema +terraform import materialize_schema.example_schema : # Schema id and information be found in the `mz_catalog.mz_schemas` table +# The role is the role where the database is located (e.g. aws/us-east-1) ``` diff --git a/docs/resources/secret.md b/docs/resources/secret.md index 52bbd1e2..37584fb2 100644 --- a/docs/resources/secret.md +++ b/docs/resources/secret.md @@ -45,7 +45,8 @@ Import is supported using the following syntax: ```shell # Secrets can be imported using the secret id: -terraform import materialize_secret.example_secret +terraform import materialize_secret.example_secret : # Secret id and information be found in the `mz_catalog.mz_secrets` table +# The region is the region where the database is located (e.g. aws/us-east-1) ``` diff --git a/docs/resources/sink_kafka.md b/docs/resources/sink_kafka.md index b015b94c..a35c0a89 100644 --- a/docs/resources/sink_kafka.md +++ b/docs/resources/sink_kafka.md @@ -148,7 +148,8 @@ Import is supported using the following syntax: ```shell # Sinks can be imported using the sink id: -terraform import materialize_sink_kafka.example_sink_kafka +terraform import materialize_sink_kafka.example_sink_kafka : # Sink id and information be found in the `mz_catalog.mz_sinks` table +# The region is the region where the database is located (e.g. aws/us-east-1) ``` diff --git a/docs/resources/source_kafka.md b/docs/resources/source_kafka.md index 47226747..04e821f3 100644 --- a/docs/resources/source_kafka.md +++ b/docs/resources/source_kafka.md @@ -348,7 +348,8 @@ Import is supported using the following syntax: ```shell # Sources can be imported using the source id: -terraform import materialize_source_kafka.example_source_kafka +terraform import materialize_source_kafka.example_source_kafka : # Source id and information be found in the `mz_catalog.mz_sources` table +# The region is the region where the database is located (e.g. aws/us-east-1) ``` diff --git a/docs/resources/source_load_generator.md b/docs/resources/source_load_generator.md index 3a3c9722..68063895 100644 --- a/docs/resources/source_load_generator.md +++ b/docs/resources/source_load_generator.md @@ -125,7 +125,8 @@ Import is supported using the following syntax: ```shell # Sources can be imported using the source id: -terraform import materialize_source_load_generator.example_source_load_generator +terraform import materialize_source_load_generator.example_source_load_generator : # Source id and information be found in the `mz_catalog.mz_sources` table +# The region is the region where the database is located (e.g. aws/us-east-1) ``` diff --git a/docs/resources/source_postgres.md b/docs/resources/source_postgres.md index 7efc3dc1..e9a4c75f 100644 --- a/docs/resources/source_postgres.md +++ b/docs/resources/source_postgres.md @@ -124,7 +124,8 @@ Import is supported using the following syntax: ```shell # Sources can be imported using the source id: -terraform import materialize_source_postgres.example_source_postgres +terraform import materialize_source_postgres.example_source_postgres : # Source id and information be found in the `mz_catalog.mz_sources` table +# The region is the region where the database is located (e.g. aws/us-east-1) ``` diff --git a/docs/resources/source_webhook.md b/docs/resources/source_webhook.md index 21d78673..45933c77 100644 --- a/docs/resources/source_webhook.md +++ b/docs/resources/source_webhook.md @@ -150,7 +150,8 @@ Import is supported using the following syntax: ```shell # Sources can be imported using the source id: -terraform import materialize_source_webhook.example_source_webhook +terraform import materialize_source_webhook.example_source_webhook : # Source id and information be found in the `mz_catalog.mz_sources` table +# The region is the region where the database is located (e.g. aws/us-east-1) ``` diff --git a/docs/resources/table.md b/docs/resources/table.md index 338247ba..8f2ab959 100644 --- a/docs/resources/table.md +++ b/docs/resources/table.md @@ -75,7 +75,8 @@ Import is supported using the following syntax: ```shell # Tables can be imported using the table id: -terraform import materialize_table.example_table +terraform import materialize_table.example_table : # Table id and information be found in the `mz_catalog.mz_tables` table +# The region is the region where the database is located (e.g. aws/us-east-1) ``` diff --git a/docs/resources/type.md b/docs/resources/type.md index 02ea3869..d82804c5 100644 --- a/docs/resources/type.md +++ b/docs/resources/type.md @@ -89,7 +89,9 @@ Import is supported using the following syntax: ```shell # Types can be imported using the type id: -terraform import materialize_type.example_type +terraform import materialize_type.example_type : # Type id and information be found in the `mz_catalog.mz_types` table +# The region is the region where the database is located (e.g. aws/us-east-1) +``` ``` diff --git a/docs/resources/view.md b/docs/resources/view.md index 58be274f..514bc322 100644 --- a/docs/resources/view.md +++ b/docs/resources/view.md @@ -63,7 +63,8 @@ Import is supported using the following syntax: ```shell # Views can be imported using the view id: -terraform import materialize_view.example_view +terraform import materialize_view.example_view : # View id and information be found in the `mz_catalog.mz_views` +# The region is the region where the database is located (e.g. aws/us-east-1) ``` From 41b7fe39fd81715295526d1da44464ad37c18094 Mon Sep 17 00:00:00 2001 From: Bobby Iliev Date: Wed, 6 Dec 2023 20:22:56 +0200 Subject: [PATCH 03/10] Add schema migration --- pkg/resources/resource_schema.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/pkg/resources/resource_schema.go b/pkg/resources/resource_schema.go index 46bd936a..11e857e3 100644 --- a/pkg/resources/resource_schema.go +++ b/pkg/resources/resource_schema.go @@ -21,6 +21,13 @@ var schemaSchema = map[string]*schema.Schema{ "ownership_role": OwnershipRoleSchema(), } +// Define the V0 schema function +func schemaSchemaV0() *schema.Resource { + return &schema.Resource{ + Schema: schemaSchema, + } +} + func Schema() *schema.Resource { return &schema.Resource{ Description: "The second highest level namespace hierarchy in Materialize.", @@ -34,7 +41,15 @@ func Schema() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: schemaSchema, + Schema: schemaSchema, + SchemaVersion: 1, + StateUpgraders: []schema.StateUpgrader{ + { + Type: schemaSchemaV0().CoreConfigSchema().ImpliedType(), + Upgrade: utils.IdStateUpgradeV0, + Version: 0, + }, + }, } } From c12c6b7f298c0047e9d1e73129f586d074aaf80f Mon Sep 17 00:00:00 2001 From: Bobby Iliev Date: Wed, 6 Dec 2023 20:45:04 +0200 Subject: [PATCH 04/10] Fix failing tests --- pkg/resources/resource_index.go | 2 +- pkg/resources/resource_source.go | 2 +- pkg/resources/resource_table.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/resources/resource_index.go b/pkg/resources/resource_index.go index b3ee35e6..eaf5880c 100644 --- a/pkg/resources/resource_index.go +++ b/pkg/resources/resource_index.go @@ -139,7 +139,7 @@ func indexRead(ctx context.Context, d *schema.ResourceData, meta interface{}) di } // Index columns - indexColumns, err := materialize.ListIndexColumns(meta.(*sqlx.DB), i) + indexColumns, err := materialize.ListIndexColumns(meta.(*sqlx.DB), utils.ExtractId(i)) if err != nil { return diag.FromErr(err) } diff --git a/pkg/resources/resource_source.go b/pkg/resources/resource_source.go index 36db1086..12a115ad 100644 --- a/pkg/resources/resource_source.go +++ b/pkg/resources/resource_source.go @@ -59,7 +59,7 @@ func sourceRead(ctx context.Context, d *schema.ResourceData, meta interface{}) d } // Subsources - deps, err := materialize.ListDependencies(meta.(*sqlx.DB), i, "source") + deps, err := materialize.ListDependencies(meta.(*sqlx.DB), utils.ExtractId(i), "source") if err != nil { return diag.FromErr(err) } diff --git a/pkg/resources/resource_table.go b/pkg/resources/resource_table.go index c1c34dc0..4c508816 100644 --- a/pkg/resources/resource_table.go +++ b/pkg/resources/resource_table.go @@ -138,7 +138,7 @@ func tableRead(ctx context.Context, d *schema.ResourceData, meta interface{}) di } // Table columns - tableColumns, err := materialize.ListTableColumns(meta.(*sqlx.DB), i) + tableColumns, err := materialize.ListTableColumns(meta.(*sqlx.DB), utils.ExtractId(i)) if err != nil { log.Print("[DEBUG] cannot query list tables") return diag.FromErr(err) From f4f015a8bedcdd4e44337e70e2380e044f34bea0 Mon Sep 17 00:00:00 2001 From: Bobby Iliev Date: Wed, 6 Dec 2023 21:05:06 +0200 Subject: [PATCH 05/10] Change id in datasources --- pkg/datasources/datasource_cluster.go | 2 +- pkg/datasources/datasource_cluster_replica.go | 2 +- pkg/datasources/datasource_connection.go | 3 ++- pkg/datasources/datasource_current_cluster.go | 3 ++- pkg/datasources/datasource_current_database.go | 3 ++- pkg/datasources/datasource_database.go | 2 +- pkg/datasources/datasource_egress_ips.go | 3 ++- pkg/datasources/datasource_index.go | 3 ++- pkg/datasources/datasource_materialized_view.go | 3 ++- pkg/datasources/datasource_role.go | 3 ++- pkg/datasources/datasource_schema.go | 2 +- pkg/datasources/datasource_secret.go | 3 ++- pkg/datasources/datasource_sink.go | 3 ++- pkg/datasources/datasource_source.go | 3 ++- pkg/datasources/datasource_table.go | 3 ++- pkg/datasources/datasource_type.go | 3 ++- pkg/datasources/datasource_view.go | 3 ++- 17 files changed, 30 insertions(+), 17 deletions(-) diff --git a/pkg/datasources/datasource_cluster.go b/pkg/datasources/datasource_cluster.go index 5a610c4c..2d52dcb6 100644 --- a/pkg/datasources/datasource_cluster.go +++ b/pkg/datasources/datasource_cluster.go @@ -64,7 +64,7 @@ func clusterRead(ctx context.Context, d *schema.ResourceData, meta interface{}) for _, p := range dataSource { clusterMap := map[string]interface{}{} - clusterMap["id"] = p.ClusterId.String + clusterMap["id"] = utils.TransformIdWithRegion(p.ClusterId.String) clusterMap["name"] = p.ClusterName.String clusterMap["managed"] = p.Managed.Bool clusterMap["size"] = p.Size.String diff --git a/pkg/datasources/datasource_cluster_replica.go b/pkg/datasources/datasource_cluster_replica.go index 35384cbb..f4909901 100644 --- a/pkg/datasources/datasource_cluster_replica.go +++ b/pkg/datasources/datasource_cluster_replica.go @@ -64,7 +64,7 @@ func clusterReplicaRead(ctx context.Context, d *schema.ResourceData, meta interf for _, p := range dataSource { clusterReplicaMap := map[string]interface{}{} - clusterReplicaMap["id"] = p.ReplicaId.String + clusterReplicaMap["id"] = utils.TransformIdWithRegion(p.ReplicaId.String) clusterReplicaMap["name"] = p.ReplicaName.String clusterReplicaMap["cluster"] = p.ClusterName.String clusterReplicaMap["size"] = p.Size.String diff --git a/pkg/datasources/datasource_connection.go b/pkg/datasources/datasource_connection.go index 41ef4df6..bd2cd25d 100644 --- a/pkg/datasources/datasource_connection.go +++ b/pkg/datasources/datasource_connection.go @@ -4,6 +4,7 @@ import ( "context" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -73,7 +74,7 @@ func connectionRead(ctx context.Context, d *schema.ResourceData, meta interface{ for _, p := range dataSource { connectionMap := map[string]interface{}{} - connectionMap["id"] = p.ConnectionId.String + connectionMap["id"] = utils.TransformIdWithRegion(p.ConnectionId.String) connectionMap["name"] = p.ConnectionName.String connectionMap["schema_name"] = p.SchemaName.String connectionMap["database_name"] = p.DatabaseName.String diff --git a/pkg/datasources/datasource_current_cluster.go b/pkg/datasources/datasource_current_cluster.go index fdfc34f3..a25c105a 100644 --- a/pkg/datasources/datasource_current_cluster.go +++ b/pkg/datasources/datasource_current_cluster.go @@ -3,6 +3,7 @@ package datasources import ( "context" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/jmoiron/sqlx" @@ -28,7 +29,7 @@ func currentClusterRead(ctx context.Context, d *schema.ResourceData, meta interf conn.QueryRow("SHOW CLUSTER;").Scan(&name) d.Set("name", name) - d.SetId("current_cluster") + d.SetId(utils.TransformIdWithRegion("current_cluster")) return diags } diff --git a/pkg/datasources/datasource_current_database.go b/pkg/datasources/datasource_current_database.go index d71e5f89..9f53d01a 100644 --- a/pkg/datasources/datasource_current_database.go +++ b/pkg/datasources/datasource_current_database.go @@ -3,6 +3,7 @@ package datasources import ( "context" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/jmoiron/sqlx" @@ -28,7 +29,7 @@ func currentDatabaseRead(ctx context.Context, d *schema.ResourceData, meta inter conn.QueryRow("SHOW DATABASE;").Scan(&name) d.Set("name", name) - d.SetId("current_database") + d.SetId(utils.TransformIdWithRegion("current_database")) return diags } diff --git a/pkg/datasources/datasource_database.go b/pkg/datasources/datasource_database.go index 343854ae..79cd875d 100644 --- a/pkg/datasources/datasource_database.go +++ b/pkg/datasources/datasource_database.go @@ -48,7 +48,7 @@ func databaseRead(ctx context.Context, d *schema.ResourceData, meta interface{}) for _, p := range dataSource { databaseMap := map[string]interface{}{} - databaseMap["id"] = p.DatabaseId.String + databaseMap["id"] = utils.TransformIdWithRegion(p.DatabaseId.String) databaseMap["name"] = p.DatabaseName.String databaseFormats = append(databaseFormats, databaseMap) diff --git a/pkg/datasources/datasource_egress_ips.go b/pkg/datasources/datasource_egress_ips.go index 600c3522..eba3db4b 100644 --- a/pkg/datasources/datasource_egress_ips.go +++ b/pkg/datasources/datasource_egress_ips.go @@ -7,6 +7,7 @@ import ( "log" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/jmoiron/sqlx" @@ -64,7 +65,7 @@ func EgressIpsRead(ctx context.Context, d *schema.ResourceData, meta interface{} return diag.FromErr(err) } - d.SetId("egress_ips") + d.SetId(utils.TransformIdWithRegion("egress_ips")) return diags } diff --git a/pkg/datasources/datasource_index.go b/pkg/datasources/datasource_index.go index 81ec8a8b..7a87da3c 100644 --- a/pkg/datasources/datasource_index.go +++ b/pkg/datasources/datasource_index.go @@ -4,6 +4,7 @@ import ( "context" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -73,7 +74,7 @@ func indexRead(ctx context.Context, d *schema.ResourceData, meta interface{}) di for _, p := range dataSource { indexMap := map[string]interface{}{} - indexMap["id"] = p.IndexId.String + indexMap["id"] = utils.TransformIdWithRegion(p.IndexId.String) indexMap["name"] = p.IndexName.String indexMap["obj_name"] = p.ObjectName.String indexMap["obj_schema"] = p.ObjectSchemaName.String diff --git a/pkg/datasources/datasource_materialized_view.go b/pkg/datasources/datasource_materialized_view.go index b6963b81..4b14d0f1 100644 --- a/pkg/datasources/datasource_materialized_view.go +++ b/pkg/datasources/datasource_materialized_view.go @@ -4,6 +4,7 @@ import ( "context" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -69,7 +70,7 @@ func materializedViewRead(ctx context.Context, d *schema.ResourceData, meta inte for _, p := range dataSource { materizliedViewMap := map[string]interface{}{} - materizliedViewMap["id"] = p.MaterializedViewId.String + materizliedViewMap["id"] = utils.TransformIdWithRegion(p.MaterializedViewId.String) materizliedViewMap["name"] = p.MaterializedViewName.String materizliedViewMap["schema_name"] = p.SchemaName.String materizliedViewMap["database_name"] = p.DatabaseName.String diff --git a/pkg/datasources/datasource_role.go b/pkg/datasources/datasource_role.go index 78b02b21..ac829671 100644 --- a/pkg/datasources/datasource_role.go +++ b/pkg/datasources/datasource_role.go @@ -4,6 +4,7 @@ import ( "context" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -57,6 +58,6 @@ func roleRead(ctx context.Context, d *schema.ResourceData, meta interface{}) dia return diag.FromErr(err) } - d.SetId("roles") + d.SetId(utils.TransformIdWithRegion("roles")) return diags } diff --git a/pkg/datasources/datasource_schema.go b/pkg/datasources/datasource_schema.go index e80ccdad..06ccd6a1 100644 --- a/pkg/datasources/datasource_schema.go +++ b/pkg/datasources/datasource_schema.go @@ -60,7 +60,7 @@ func schemaRead(ctx context.Context, d *schema.ResourceData, meta interface{}) d for _, p := range dataSource { schemaMap := map[string]interface{}{} - schemaMap["id"] = p.SchemaId.String + schemaMap["id"] = utils.TransformIdWithRegion(p.SchemaId.String) schemaMap["name"] = p.SchemaName.String schemaMap["database_name"] = p.DatabaseName.String diff --git a/pkg/datasources/datasource_secret.go b/pkg/datasources/datasource_secret.go index 298c01c6..d1b57ae0 100644 --- a/pkg/datasources/datasource_secret.go +++ b/pkg/datasources/datasource_secret.go @@ -4,6 +4,7 @@ import ( "context" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -69,7 +70,7 @@ func secretRead(ctx context.Context, d *schema.ResourceData, meta interface{}) d for _, p := range dataSource { secretMap := map[string]interface{}{} - secretMap["id"] = p.SecretId.String + secretMap["id"] = utils.TransformIdWithRegion(p.SecretId.String) secretMap["name"] = p.SecretName.String secretMap["schema_name"] = p.SchemaName.String secretMap["database_name"] = p.DatabaseName.String diff --git a/pkg/datasources/datasource_sink.go b/pkg/datasources/datasource_sink.go index fb0e5b63..725473e3 100644 --- a/pkg/datasources/datasource_sink.go +++ b/pkg/datasources/datasource_sink.go @@ -4,6 +4,7 @@ import ( "context" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -89,7 +90,7 @@ func sinkRead(ctx context.Context, d *schema.ResourceData, meta interface{}) dia for _, p := range dataSource { sinkMap := map[string]interface{}{} - sinkMap["id"] = p.SinkId.String + sinkMap["id"] = utils.TransformIdWithRegion(p.SinkId.String) sinkMap["name"] = p.SinkName.String sinkMap["schema_name"] = p.SchemaName.String sinkMap["database_name"] = p.DatabaseName.String diff --git a/pkg/datasources/datasource_source.go b/pkg/datasources/datasource_source.go index 8a2955bc..56e3cf2c 100644 --- a/pkg/datasources/datasource_source.go +++ b/pkg/datasources/datasource_source.go @@ -4,6 +4,7 @@ import ( "context" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -89,7 +90,7 @@ func sourceRead(ctx context.Context, d *schema.ResourceData, meta interface{}) d for _, p := range dataSource { sourceMap := map[string]interface{}{} - sourceMap["id"] = p.SourceId.String + sourceMap["id"] = utils.TransformIdWithRegion(p.SourceId.String) sourceMap["name"] = p.SourceName.String sourceMap["schema_name"] = p.SchemaName.String sourceMap["database_name"] = p.DatabaseName.String diff --git a/pkg/datasources/datasource_table.go b/pkg/datasources/datasource_table.go index da2b7d10..b029eb7c 100644 --- a/pkg/datasources/datasource_table.go +++ b/pkg/datasources/datasource_table.go @@ -4,6 +4,7 @@ import ( "context" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -69,7 +70,7 @@ func tableRead(ctx context.Context, d *schema.ResourceData, meta interface{}) di for _, p := range dataSource { tableMap := map[string]interface{}{} - tableMap["id"] = p.TableId.String + tableMap["id"] = utils.TransformIdWithRegion(p.TableId.String) tableMap["name"] = p.TableName.String tableMap["schema_name"] = p.SchemaName.String tableMap["database_name"] = p.DatabaseName.String diff --git a/pkg/datasources/datasource_type.go b/pkg/datasources/datasource_type.go index dc420d43..b6d24e95 100644 --- a/pkg/datasources/datasource_type.go +++ b/pkg/datasources/datasource_type.go @@ -4,6 +4,7 @@ import ( "context" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -73,7 +74,7 @@ func typeRead(ctx context.Context, d *schema.ResourceData, meta interface{}) dia for _, p := range dataSource { typeMap := map[string]interface{}{} - typeMap["id"] = p.TypeId.String + typeMap["id"] = utils.TransformIdWithRegion(p.TypeId.String) typeMap["name"] = p.TypeName.String typeMap["schema_name"] = p.SchemaName.String typeMap["database_name"] = p.DatabaseName.String diff --git a/pkg/datasources/datasource_view.go b/pkg/datasources/datasource_view.go index 722fe5a9..14ba2701 100644 --- a/pkg/datasources/datasource_view.go +++ b/pkg/datasources/datasource_view.go @@ -4,6 +4,7 @@ import ( "context" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" + "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -69,7 +70,7 @@ func viewRead(ctx context.Context, d *schema.ResourceData, meta interface{}) dia for _, p := range dataSource { viewMap := map[string]interface{}{} - viewMap["id"] = p.ViewId.String + viewMap["id"] = utils.TransformIdWithRegion(p.ViewId.String) viewMap["name"] = p.ViewName.String viewMap["schema_name"] = p.SchemaName.String viewMap["database_name"] = p.DatabaseName.String From 828b2d17dd13ffe683d605d32cf41c7864acd63e Mon Sep 17 00:00:00 2001 From: Bobby Iliev Date: Thu, 7 Dec 2023 16:40:53 +0200 Subject: [PATCH 06/10] Update examples/resources/materialize_schema/import.sh Co-authored-by: Dennis Hume --- examples/resources/materialize_schema/import.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/resources/materialize_schema/import.sh b/examples/resources/materialize_schema/import.sh index 088fa598..a1c93472 100644 --- a/examples/resources/materialize_schema/import.sh +++ b/examples/resources/materialize_schema/import.sh @@ -1,5 +1,5 @@ # Schemas can be imported using the schema id: -terraform import materialize_schema.example_schema : +terraform import materialize_schema.example_schema : # Schema id and information be found in the `mz_catalog.mz_schemas` table # The role is the role where the database is located (e.g. aws/us-east-1) From ba09f91a4c0d0db1431703a295e28ec6b970ce95 Mon Sep 17 00:00:00 2001 From: Bobby Iliev Date: Thu, 7 Dec 2023 16:41:09 +0200 Subject: [PATCH 07/10] Update examples/resources/materialize_type/import.sh Co-authored-by: Dennis Hume --- examples/resources/materialize_type/import.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/resources/materialize_type/import.sh b/examples/resources/materialize_type/import.sh index 41d649b1..311b70ba 100644 --- a/examples/resources/materialize_type/import.sh +++ b/examples/resources/materialize_type/import.sh @@ -3,4 +3,3 @@ terraform import materialize_type.example_type : # Type id and information be found in the `mz_catalog.mz_types` table # The region is the region where the database is located (e.g. aws/us-east-1) -``` From 629a7cc8e317ded2072ba1becde8f5fa6d3e1e93 Mon Sep 17 00:00:00 2001 From: bobbyiliev Date: Thu, 7 Dec 2023 14:41:41 +0000 Subject: [PATCH 08/10] Terraform Docs --- docs/resources/schema.md | 2 +- docs/resources/type.md | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/resources/schema.md b/docs/resources/schema.md index fdcdecee..7d0a8ef2 100644 --- a/docs/resources/schema.md +++ b/docs/resources/schema.md @@ -43,7 +43,7 @@ Import is supported using the following syntax: ```shell # Schemas can be imported using the schema id: -terraform import materialize_schema.example_schema : +terraform import materialize_schema.example_schema : # Schema id and information be found in the `mz_catalog.mz_schemas` table # The role is the role where the database is located (e.g. aws/us-east-1) diff --git a/docs/resources/type.md b/docs/resources/type.md index d82804c5..b12f116b 100644 --- a/docs/resources/type.md +++ b/docs/resources/type.md @@ -94,4 +94,3 @@ terraform import materialize_type.example_type : # Type id and information be found in the `mz_catalog.mz_types` table # The region is the region where the database is located (e.g. aws/us-east-1) ``` -``` From 97a22c5c9a3825390acb5dd935b0f4beff496929 Mon Sep 17 00:00:00 2001 From: Bobby Iliev Date: Thu, 7 Dec 2023 17:19:29 +0200 Subject: [PATCH 09/10] Remove transofrm ids from individual datasources --- pkg/datasources/datasource_cluster.go | 2 +- pkg/datasources/datasource_cluster_replica.go | 2 +- pkg/datasources/datasource_connection.go | 3 +- pkg/datasources/datasource_database.go | 2 +- pkg/datasources/datasource_index.go | 3 +- .../datasource_materialized_view.go | 3 +- pkg/datasources/datasource_schema.go | 2 +- pkg/datasources/datasource_secret.go | 3 +- pkg/datasources/datasource_sink.go | 3 +- pkg/datasources/datasource_source.go | 3 +- pkg/datasources/datasource_table.go | 3 +- pkg/datasources/datasource_type.go | 3 +- pkg/datasources/datasource_view.go | 3 +- pkg/resources/resource_secret.go | 28 +++++++++---------- 14 files changed, 27 insertions(+), 36 deletions(-) diff --git a/pkg/datasources/datasource_cluster.go b/pkg/datasources/datasource_cluster.go index 2d52dcb6..5a610c4c 100644 --- a/pkg/datasources/datasource_cluster.go +++ b/pkg/datasources/datasource_cluster.go @@ -64,7 +64,7 @@ func clusterRead(ctx context.Context, d *schema.ResourceData, meta interface{}) for _, p := range dataSource { clusterMap := map[string]interface{}{} - clusterMap["id"] = utils.TransformIdWithRegion(p.ClusterId.String) + clusterMap["id"] = p.ClusterId.String clusterMap["name"] = p.ClusterName.String clusterMap["managed"] = p.Managed.Bool clusterMap["size"] = p.Size.String diff --git a/pkg/datasources/datasource_cluster_replica.go b/pkg/datasources/datasource_cluster_replica.go index f4909901..35384cbb 100644 --- a/pkg/datasources/datasource_cluster_replica.go +++ b/pkg/datasources/datasource_cluster_replica.go @@ -64,7 +64,7 @@ func clusterReplicaRead(ctx context.Context, d *schema.ResourceData, meta interf for _, p := range dataSource { clusterReplicaMap := map[string]interface{}{} - clusterReplicaMap["id"] = utils.TransformIdWithRegion(p.ReplicaId.String) + clusterReplicaMap["id"] = p.ReplicaId.String clusterReplicaMap["name"] = p.ReplicaName.String clusterReplicaMap["cluster"] = p.ClusterName.String clusterReplicaMap["size"] = p.Size.String diff --git a/pkg/datasources/datasource_connection.go b/pkg/datasources/datasource_connection.go index bd2cd25d..41ef4df6 100644 --- a/pkg/datasources/datasource_connection.go +++ b/pkg/datasources/datasource_connection.go @@ -4,7 +4,6 @@ import ( "context" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" - "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -74,7 +73,7 @@ func connectionRead(ctx context.Context, d *schema.ResourceData, meta interface{ for _, p := range dataSource { connectionMap := map[string]interface{}{} - connectionMap["id"] = utils.TransformIdWithRegion(p.ConnectionId.String) + connectionMap["id"] = p.ConnectionId.String connectionMap["name"] = p.ConnectionName.String connectionMap["schema_name"] = p.SchemaName.String connectionMap["database_name"] = p.DatabaseName.String diff --git a/pkg/datasources/datasource_database.go b/pkg/datasources/datasource_database.go index 79cd875d..343854ae 100644 --- a/pkg/datasources/datasource_database.go +++ b/pkg/datasources/datasource_database.go @@ -48,7 +48,7 @@ func databaseRead(ctx context.Context, d *schema.ResourceData, meta interface{}) for _, p := range dataSource { databaseMap := map[string]interface{}{} - databaseMap["id"] = utils.TransformIdWithRegion(p.DatabaseId.String) + databaseMap["id"] = p.DatabaseId.String databaseMap["name"] = p.DatabaseName.String databaseFormats = append(databaseFormats, databaseMap) diff --git a/pkg/datasources/datasource_index.go b/pkg/datasources/datasource_index.go index 7a87da3c..81ec8a8b 100644 --- a/pkg/datasources/datasource_index.go +++ b/pkg/datasources/datasource_index.go @@ -4,7 +4,6 @@ import ( "context" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" - "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -74,7 +73,7 @@ func indexRead(ctx context.Context, d *schema.ResourceData, meta interface{}) di for _, p := range dataSource { indexMap := map[string]interface{}{} - indexMap["id"] = utils.TransformIdWithRegion(p.IndexId.String) + indexMap["id"] = p.IndexId.String indexMap["name"] = p.IndexName.String indexMap["obj_name"] = p.ObjectName.String indexMap["obj_schema"] = p.ObjectSchemaName.String diff --git a/pkg/datasources/datasource_materialized_view.go b/pkg/datasources/datasource_materialized_view.go index 4b14d0f1..b6963b81 100644 --- a/pkg/datasources/datasource_materialized_view.go +++ b/pkg/datasources/datasource_materialized_view.go @@ -4,7 +4,6 @@ import ( "context" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" - "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -70,7 +69,7 @@ func materializedViewRead(ctx context.Context, d *schema.ResourceData, meta inte for _, p := range dataSource { materizliedViewMap := map[string]interface{}{} - materizliedViewMap["id"] = utils.TransformIdWithRegion(p.MaterializedViewId.String) + materizliedViewMap["id"] = p.MaterializedViewId.String materizliedViewMap["name"] = p.MaterializedViewName.String materizliedViewMap["schema_name"] = p.SchemaName.String materizliedViewMap["database_name"] = p.DatabaseName.String diff --git a/pkg/datasources/datasource_schema.go b/pkg/datasources/datasource_schema.go index 06ccd6a1..e80ccdad 100644 --- a/pkg/datasources/datasource_schema.go +++ b/pkg/datasources/datasource_schema.go @@ -60,7 +60,7 @@ func schemaRead(ctx context.Context, d *schema.ResourceData, meta interface{}) d for _, p := range dataSource { schemaMap := map[string]interface{}{} - schemaMap["id"] = utils.TransformIdWithRegion(p.SchemaId.String) + schemaMap["id"] = p.SchemaId.String schemaMap["name"] = p.SchemaName.String schemaMap["database_name"] = p.DatabaseName.String diff --git a/pkg/datasources/datasource_secret.go b/pkg/datasources/datasource_secret.go index d1b57ae0..298c01c6 100644 --- a/pkg/datasources/datasource_secret.go +++ b/pkg/datasources/datasource_secret.go @@ -4,7 +4,6 @@ import ( "context" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" - "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -70,7 +69,7 @@ func secretRead(ctx context.Context, d *schema.ResourceData, meta interface{}) d for _, p := range dataSource { secretMap := map[string]interface{}{} - secretMap["id"] = utils.TransformIdWithRegion(p.SecretId.String) + secretMap["id"] = p.SecretId.String secretMap["name"] = p.SecretName.String secretMap["schema_name"] = p.SchemaName.String secretMap["database_name"] = p.DatabaseName.String diff --git a/pkg/datasources/datasource_sink.go b/pkg/datasources/datasource_sink.go index 725473e3..fb0e5b63 100644 --- a/pkg/datasources/datasource_sink.go +++ b/pkg/datasources/datasource_sink.go @@ -4,7 +4,6 @@ import ( "context" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" - "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -90,7 +89,7 @@ func sinkRead(ctx context.Context, d *schema.ResourceData, meta interface{}) dia for _, p := range dataSource { sinkMap := map[string]interface{}{} - sinkMap["id"] = utils.TransformIdWithRegion(p.SinkId.String) + sinkMap["id"] = p.SinkId.String sinkMap["name"] = p.SinkName.String sinkMap["schema_name"] = p.SchemaName.String sinkMap["database_name"] = p.DatabaseName.String diff --git a/pkg/datasources/datasource_source.go b/pkg/datasources/datasource_source.go index 56e3cf2c..8a2955bc 100644 --- a/pkg/datasources/datasource_source.go +++ b/pkg/datasources/datasource_source.go @@ -4,7 +4,6 @@ import ( "context" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" - "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -90,7 +89,7 @@ func sourceRead(ctx context.Context, d *schema.ResourceData, meta interface{}) d for _, p := range dataSource { sourceMap := map[string]interface{}{} - sourceMap["id"] = utils.TransformIdWithRegion(p.SourceId.String) + sourceMap["id"] = p.SourceId.String sourceMap["name"] = p.SourceName.String sourceMap["schema_name"] = p.SchemaName.String sourceMap["database_name"] = p.DatabaseName.String diff --git a/pkg/datasources/datasource_table.go b/pkg/datasources/datasource_table.go index b029eb7c..da2b7d10 100644 --- a/pkg/datasources/datasource_table.go +++ b/pkg/datasources/datasource_table.go @@ -4,7 +4,6 @@ import ( "context" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" - "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -70,7 +69,7 @@ func tableRead(ctx context.Context, d *schema.ResourceData, meta interface{}) di for _, p := range dataSource { tableMap := map[string]interface{}{} - tableMap["id"] = utils.TransformIdWithRegion(p.TableId.String) + tableMap["id"] = p.TableId.String tableMap["name"] = p.TableName.String tableMap["schema_name"] = p.SchemaName.String tableMap["database_name"] = p.DatabaseName.String diff --git a/pkg/datasources/datasource_type.go b/pkg/datasources/datasource_type.go index b6d24e95..dc420d43 100644 --- a/pkg/datasources/datasource_type.go +++ b/pkg/datasources/datasource_type.go @@ -4,7 +4,6 @@ import ( "context" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" - "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -74,7 +73,7 @@ func typeRead(ctx context.Context, d *schema.ResourceData, meta interface{}) dia for _, p := range dataSource { typeMap := map[string]interface{}{} - typeMap["id"] = utils.TransformIdWithRegion(p.TypeId.String) + typeMap["id"] = p.TypeId.String typeMap["name"] = p.TypeName.String typeMap["schema_name"] = p.SchemaName.String typeMap["database_name"] = p.DatabaseName.String diff --git a/pkg/datasources/datasource_view.go b/pkg/datasources/datasource_view.go index 14ba2701..722fe5a9 100644 --- a/pkg/datasources/datasource_view.go +++ b/pkg/datasources/datasource_view.go @@ -4,7 +4,6 @@ import ( "context" "github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize" - "github.com/MaterializeInc/terraform-provider-materialize/pkg/utils" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -70,7 +69,7 @@ func viewRead(ctx context.Context, d *schema.ResourceData, meta interface{}) dia for _, p := range dataSource { viewMap := map[string]interface{}{} - viewMap["id"] = utils.TransformIdWithRegion(p.ViewId.String) + viewMap["id"] = p.ViewId.String viewMap["name"] = p.ViewName.String viewMap["schema_name"] = p.SchemaName.String viewMap["database_name"] = p.DatabaseName.String diff --git a/pkg/resources/resource_secret.go b/pkg/resources/resource_secret.go index 32d4fcee..338641f1 100644 --- a/pkg/resources/resource_secret.go +++ b/pkg/resources/resource_secret.go @@ -29,11 +29,11 @@ var secretSchema = map[string]*schema.Schema{ } // Define the V0 schema function -func secretSchemaV0() *schema.Resource { - return &schema.Resource{ - Schema: secretSchema, - } -} +// func secretSchemaV0() *schema.Resource { +// return &schema.Resource{ +// Schema: secretSchema, +// } +// } func Secret() *schema.Resource { return &schema.Resource{ @@ -48,15 +48,15 @@ func Secret() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: secretSchema, - SchemaVersion: 1, - StateUpgraders: []schema.StateUpgrader{ - { - Type: secretSchemaV0().CoreConfigSchema().ImpliedType(), - Upgrade: utils.IdStateUpgradeV0, - Version: 0, - }, - }, + Schema: secretSchema, + // SchemaVersion: 1, + // StateUpgraders: []schema.StateUpgrader{ + // { + // Type: secretSchemaV0().CoreConfigSchema().ImpliedType(), + // Upgrade: utils.IdStateUpgradeV0, + // Version: 0, + // }, + // }, } } From 93ce03a633473026d45c649be6b3de21576aa7ee Mon Sep 17 00:00:00 2001 From: Bobby Iliev Date: Thu, 7 Dec 2023 20:49:55 +0200 Subject: [PATCH 10/10] Remove the state updaters for all objects --- pkg/resources/resource_cluster.go | 17 +---------------- pkg/resources/resource_cluster_replica.go | 17 +---------------- .../resource_connection_aws_privatelink.go | 17 +---------------- ...urce_connection_confluent_schema_registry.go | 17 +---------------- pkg/resources/resource_connection_kafka.go | 17 +---------------- pkg/resources/resource_connection_postgres.go | 17 +---------------- pkg/resources/resource_connection_ssh_tunnel.go | 17 +---------------- pkg/resources/resource_database.go | 17 +---------------- pkg/resources/resource_index.go | 17 +---------------- pkg/resources/resource_materialized_view.go | 17 +---------------- pkg/resources/resource_role.go | 17 +---------------- pkg/resources/resource_schema.go | 17 +---------------- pkg/resources/resource_secret.go | 15 --------------- pkg/resources/resource_sink_kafka.go | 17 +---------------- pkg/resources/resource_source_kafka.go | 17 +---------------- pkg/resources/resource_source_load_generator.go | 17 +---------------- pkg/resources/resource_source_postgres.go | 17 +---------------- pkg/resources/resource_source_webhook.go | 17 +---------------- pkg/resources/resource_table.go | 17 +---------------- pkg/resources/resource_type.go | 17 +---------------- pkg/resources/resource_view.go | 17 +---------------- 21 files changed, 20 insertions(+), 335 deletions(-) diff --git a/pkg/resources/resource_cluster.go b/pkg/resources/resource_cluster.go index 3f9dc4d7..7166b006 100644 --- a/pkg/resources/resource_cluster.go +++ b/pkg/resources/resource_cluster.go @@ -38,13 +38,6 @@ var clusterSchema = map[string]*schema.Schema{ "idle_arrangement_merge_effort": IdleArrangementMergeEffortSchema(false, []string{"size"}), } -// Define the V0 schema function -func clusterSchemaV0() *schema.Resource { - return &schema.Resource{ - Schema: clusterSchema, - } -} - func Cluster() *schema.Resource { return &schema.Resource{ Description: "Clusters describe logical compute resources that can be used by sources, sinks, indexes, and materialized views. Managed clusters are created by setting the `size` attribute", @@ -58,15 +51,7 @@ func Cluster() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: clusterSchema, - SchemaVersion: 1, - StateUpgraders: []schema.StateUpgrader{ - { - Type: clusterSchemaV0().CoreConfigSchema().ImpliedType(), - Upgrade: utils.IdStateUpgradeV0, - Version: 0, - }, - }, + Schema: clusterSchema, } } diff --git a/pkg/resources/resource_cluster_replica.go b/pkg/resources/resource_cluster_replica.go index a74d11a2..227e3026 100644 --- a/pkg/resources/resource_cluster_replica.go +++ b/pkg/resources/resource_cluster_replica.go @@ -31,13 +31,6 @@ var clusterReplicaSchema = map[string]*schema.Schema{ "idle_arrangement_merge_effort": IdleArrangementMergeEffortSchema(true, []string{}), } -// Define the V0 schema function -func clusterReplicaSchemaV0() *schema.Resource { - return &schema.Resource{ - Schema: clusterReplicaSchema, - } -} - func ClusterReplica() *schema.Resource { return &schema.Resource{ Description: "Cluster replicas allocate physical compute resources for a cluster.", @@ -53,15 +46,7 @@ func ClusterReplica() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: clusterReplicaSchema, - SchemaVersion: 1, - StateUpgraders: []schema.StateUpgrader{ - { - Type: clusterReplicaSchemaV0().CoreConfigSchema().ImpliedType(), - Upgrade: utils.IdStateUpgradeV0, - Version: 0, - }, - }, + Schema: clusterReplicaSchema, } } diff --git a/pkg/resources/resource_connection_aws_privatelink.go b/pkg/resources/resource_connection_aws_privatelink.go index c23c0cd0..48ce18d8 100644 --- a/pkg/resources/resource_connection_aws_privatelink.go +++ b/pkg/resources/resource_connection_aws_privatelink.go @@ -41,13 +41,6 @@ var connectionAwsPrivatelinkSchema = map[string]*schema.Schema{ "ownership_role": OwnershipRoleSchema(), } -// Define the V0 schema function -func connectionAwsPrivatelinkSchemaV0() *schema.Resource { - return &schema.Resource{ - Schema: connectionAwsPrivatelinkSchema, - } -} - func ConnectionAwsPrivatelink() *schema.Resource { return &schema.Resource{ Description: "An AWS PrivateLink connection establishes a link to an AWS PrivateLink service.", @@ -61,15 +54,7 @@ func ConnectionAwsPrivatelink() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: connectionAwsPrivatelinkSchema, - SchemaVersion: 1, - StateUpgraders: []schema.StateUpgrader{ - { - Type: connectionAwsPrivatelinkSchemaV0().CoreConfigSchema().ImpliedType(), - Upgrade: utils.IdStateUpgradeV0, - Version: 0, - }, - }, + Schema: connectionAwsPrivatelinkSchema, } } diff --git a/pkg/resources/resource_connection_confluent_schema_registry.go b/pkg/resources/resource_connection_confluent_schema_registry.go index 1a7a52cd..9c9039f0 100644 --- a/pkg/resources/resource_connection_confluent_schema_registry.go +++ b/pkg/resources/resource_connection_confluent_schema_registry.go @@ -34,13 +34,6 @@ var connectionConfluentSchemaRegistrySchema = map[string]*schema.Schema{ "ownership_role": OwnershipRoleSchema(), } -// Define the V0 schema function -func connectionConfluentSchemaRegistrySchemaV0() *schema.Resource { - return &schema.Resource{ - Schema: connectionConfluentSchemaRegistrySchema, - } -} - func ConnectionConfluentSchemaRegistry() *schema.Resource { return &schema.Resource{ Description: "A Confluent Schema Registry connection establishes a link to a Confluent Schema Registry server.", @@ -54,15 +47,7 @@ func ConnectionConfluentSchemaRegistry() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: connectionConfluentSchemaRegistrySchema, - SchemaVersion: 1, - StateUpgraders: []schema.StateUpgrader{ - { - Type: connectionConfluentSchemaRegistrySchemaV0().CoreConfigSchema().ImpliedType(), - Upgrade: utils.IdStateUpgradeV0, - Version: 0, - }, - }, + Schema: connectionConfluentSchemaRegistrySchema, } } diff --git a/pkg/resources/resource_connection_kafka.go b/pkg/resources/resource_connection_kafka.go index 99211d62..ea33e9da 100644 --- a/pkg/resources/resource_connection_kafka.go +++ b/pkg/resources/resource_connection_kafka.go @@ -85,13 +85,6 @@ var connectionKafkaSchema = map[string]*schema.Schema{ "ownership_role": OwnershipRoleSchema(), } -// Define the V0 schema function -func connectionKafkaSchemaV0() *schema.Resource { - return &schema.Resource{ - Schema: connectionKafkaSchema, - } -} - func ConnectionKafka() *schema.Resource { return &schema.Resource{ Description: "A Kafka connection establishes a link to a Kafka cluster.", @@ -105,15 +98,7 @@ func ConnectionKafka() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: connectionKafkaSchema, - SchemaVersion: 1, - StateUpgraders: []schema.StateUpgrader{ - { - Type: connectionKafkaSchemaV0().CoreConfigSchema().ImpliedType(), - Upgrade: utils.IdStateUpgradeV0, - Version: 0, - }, - }, + Schema: connectionKafkaSchema, } } diff --git a/pkg/resources/resource_connection_postgres.go b/pkg/resources/resource_connection_postgres.go index 822979c0..44acbd79 100644 --- a/pkg/resources/resource_connection_postgres.go +++ b/pkg/resources/resource_connection_postgres.go @@ -54,13 +54,6 @@ var connectionPostgresSchema = map[string]*schema.Schema{ "ownership_role": OwnershipRoleSchema(), } -// Define the V0 schema function -func connectionPostgresSchemaV0() *schema.Resource { - return &schema.Resource{ - Schema: connectionPostgresSchema, - } -} - func ConnectionPostgres() *schema.Resource { return &schema.Resource{ Description: "A Postgres connection establishes a link to a single database of a PostgreSQL server.", @@ -74,15 +67,7 @@ func ConnectionPostgres() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: connectionPostgresSchema, - SchemaVersion: 1, - StateUpgraders: []schema.StateUpgrader{ - { - Type: connectionPostgresSchemaV0().CoreConfigSchema().ImpliedType(), - Upgrade: utils.IdStateUpgradeV0, - Version: 0, - }, - }, + Schema: connectionPostgresSchema, } } diff --git a/pkg/resources/resource_connection_ssh_tunnel.go b/pkg/resources/resource_connection_ssh_tunnel.go index 6e8deea7..93ec6e54 100644 --- a/pkg/resources/resource_connection_ssh_tunnel.go +++ b/pkg/resources/resource_connection_ssh_tunnel.go @@ -50,13 +50,6 @@ var connectionSshTunnelSchema = map[string]*schema.Schema{ "ownership_role": OwnershipRoleSchema(), } -// Define the V0 schema function -func connectionSshTunnelSchemaV0() *schema.Resource { - return &schema.Resource{ - Schema: connectionSshTunnelSchema, - } -} - func ConnectionSshTunnel() *schema.Resource { return &schema.Resource{ Description: "An SSH tunnel connection establishes a link to an SSH bastion server.", @@ -70,15 +63,7 @@ func ConnectionSshTunnel() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: connectionSshTunnelSchema, - SchemaVersion: 1, - StateUpgraders: []schema.StateUpgrader{ - { - Type: connectionSshTunnelSchemaV0().CoreConfigSchema().ImpliedType(), - Upgrade: utils.IdStateUpgradeV0, - Version: 0, - }, - }, + Schema: connectionSshTunnelSchema, } } diff --git a/pkg/resources/resource_database.go b/pkg/resources/resource_database.go index 911d6da9..872d60c0 100644 --- a/pkg/resources/resource_database.go +++ b/pkg/resources/resource_database.go @@ -19,13 +19,6 @@ var databaseSchema = map[string]*schema.Schema{ "ownership_role": OwnershipRoleSchema(), } -// Define the V0 schema function -func databaseSchemaV0() *schema.Resource { - return &schema.Resource{ - Schema: databaseSchema, - } -} - func Database() *schema.Resource { return &schema.Resource{ Description: "The highest level namespace hierarchy in Materialize.", @@ -39,15 +32,7 @@ func Database() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: databaseSchema, - SchemaVersion: 1, - StateUpgraders: []schema.StateUpgrader{ - { - Type: databaseSchemaV0().CoreConfigSchema().ImpliedType(), - Upgrade: utils.IdStateUpgradeV0, - Version: 0, - }, - }, + Schema: databaseSchema, } } diff --git a/pkg/resources/resource_index.go b/pkg/resources/resource_index.go index eaf5880c..93352478 100644 --- a/pkg/resources/resource_index.go +++ b/pkg/resources/resource_index.go @@ -73,13 +73,6 @@ var indexSchema = map[string]*schema.Schema{ }, } -// Define the V0 schema function -func indexSchemaV0() *schema.Resource { - return &schema.Resource{ - Schema: indexSchema, - } -} - func Index() *schema.Resource { return &schema.Resource{ Description: "Indexes represent query results stored in memory.", @@ -93,15 +86,7 @@ func Index() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: indexSchema, - SchemaVersion: 1, - StateUpgraders: []schema.StateUpgrader{ - { - Type: indexSchemaV0().CoreConfigSchema().ImpliedType(), - Upgrade: utils.IdStateUpgradeV0, - Version: 0, - }, - }, + Schema: indexSchema, } } diff --git a/pkg/resources/resource_materialized_view.go b/pkg/resources/resource_materialized_view.go index ad65b3fc..42f5d3c7 100644 --- a/pkg/resources/resource_materialized_view.go +++ b/pkg/resources/resource_materialized_view.go @@ -44,13 +44,6 @@ var materializedViewSchema = map[string]*schema.Schema{ "ownership_role": OwnershipRoleSchema(), } -// Define the V0 schema function -func materializedViewSchemaV0() *schema.Resource { - return &schema.Resource{ - Schema: materializedViewSchema, - } -} - func MaterializedView() *schema.Resource { return &schema.Resource{ Description: "Materialized views represent query results stored durably.", @@ -64,15 +57,7 @@ func MaterializedView() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: materializedViewSchema, - SchemaVersion: 1, - StateUpgraders: []schema.StateUpgrader{ - { - Type: materializedViewSchemaV0().CoreConfigSchema().ImpliedType(), - Upgrade: utils.IdStateUpgradeV0, - Version: 0, - }, - }, + Schema: materializedViewSchema, } } diff --git a/pkg/resources/resource_role.go b/pkg/resources/resource_role.go index 0b341288..b1b0ee96 100644 --- a/pkg/resources/resource_role.go +++ b/pkg/resources/resource_role.go @@ -24,13 +24,6 @@ var roleSchema = map[string]*schema.Schema{ }, } -// Define the V0 schema function -func roleSchemaV0() *schema.Resource { - return &schema.Resource{ - Schema: roleSchema, - } -} - func Role() *schema.Resource { return &schema.Resource{ Description: "A role is a collection of privileges you can apply to users.", @@ -44,15 +37,7 @@ func Role() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: roleSchema, - SchemaVersion: 1, - StateUpgraders: []schema.StateUpgrader{ - { - Type: roleSchemaV0().CoreConfigSchema().ImpliedType(), - Upgrade: utils.IdStateUpgradeV0, - Version: 0, - }, - }, + Schema: roleSchema, } } diff --git a/pkg/resources/resource_schema.go b/pkg/resources/resource_schema.go index 11e857e3..46bd936a 100644 --- a/pkg/resources/resource_schema.go +++ b/pkg/resources/resource_schema.go @@ -21,13 +21,6 @@ var schemaSchema = map[string]*schema.Schema{ "ownership_role": OwnershipRoleSchema(), } -// Define the V0 schema function -func schemaSchemaV0() *schema.Resource { - return &schema.Resource{ - Schema: schemaSchema, - } -} - func Schema() *schema.Resource { return &schema.Resource{ Description: "The second highest level namespace hierarchy in Materialize.", @@ -41,15 +34,7 @@ func Schema() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: schemaSchema, - SchemaVersion: 1, - StateUpgraders: []schema.StateUpgrader{ - { - Type: schemaSchemaV0().CoreConfigSchema().ImpliedType(), - Upgrade: utils.IdStateUpgradeV0, - Version: 0, - }, - }, + Schema: schemaSchema, } } diff --git a/pkg/resources/resource_secret.go b/pkg/resources/resource_secret.go index 338641f1..aafa3d0c 100644 --- a/pkg/resources/resource_secret.go +++ b/pkg/resources/resource_secret.go @@ -28,13 +28,6 @@ var secretSchema = map[string]*schema.Schema{ "ownership_role": OwnershipRoleSchema(), } -// Define the V0 schema function -// func secretSchemaV0() *schema.Resource { -// return &schema.Resource{ -// Schema: secretSchema, -// } -// } - func Secret() *schema.Resource { return &schema.Resource{ Description: "A secret securely stores sensitive credentials (like passwords and SSL keys) in Materialize’s secret management system.", @@ -49,14 +42,6 @@ func Secret() *schema.Resource { }, Schema: secretSchema, - // SchemaVersion: 1, - // StateUpgraders: []schema.StateUpgrader{ - // { - // Type: secretSchemaV0().CoreConfigSchema().ImpliedType(), - // Upgrade: utils.IdStateUpgradeV0, - // Version: 0, - // }, - // }, } } diff --git a/pkg/resources/resource_sink_kafka.go b/pkg/resources/resource_sink_kafka.go index a16ff696..7b4e737f 100644 --- a/pkg/resources/resource_sink_kafka.go +++ b/pkg/resources/resource_sink_kafka.go @@ -78,13 +78,6 @@ var sinkKafkaSchema = map[string]*schema.Schema{ }, } -// Define the V0 schema function -func sinkKafkaSchemaV0() *schema.Resource { - return &schema.Resource{ - Schema: sinkKafkaSchema, - } -} - func SinkKafka() *schema.Resource { return &schema.Resource{ Description: "A Kafka sink establishes a link to a Kafka cluster that you want Materialize to write data to.", @@ -98,15 +91,7 @@ func SinkKafka() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: sinkKafkaSchema, - SchemaVersion: 1, - StateUpgraders: []schema.StateUpgrader{ - { - Type: sinkKafkaSchemaV0().CoreConfigSchema().ImpliedType(), - Upgrade: utils.IdStateUpgradeV0, - Version: 0, - }, - }, + Schema: sinkKafkaSchema, } } diff --git a/pkg/resources/resource_source_kafka.go b/pkg/resources/resource_source_kafka.go index a96f568a..ebf77526 100644 --- a/pkg/resources/resource_source_kafka.go +++ b/pkg/resources/resource_source_kafka.go @@ -143,13 +143,6 @@ var sourceKafkaSchema = map[string]*schema.Schema{ "ownership_role": OwnershipRoleSchema(), } -// Define the V0 schema function -func sourceKafkaSchemaV0() *schema.Resource { - return &schema.Resource{ - Schema: sourceKafkaSchema, - } -} - func SourceKafka() *schema.Resource { return &schema.Resource{ Description: "A Kafka source describes a Kafka cluster you want Materialize to read data from.", @@ -163,15 +156,7 @@ func SourceKafka() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: sourceKafkaSchema, - SchemaVersion: 1, - StateUpgraders: []schema.StateUpgrader{ - { - Type: sourceKafkaSchemaV0().CoreConfigSchema().ImpliedType(), - Upgrade: utils.IdStateUpgradeV0, - Version: 0, - }, - }, + Schema: sourceKafkaSchema, } } diff --git a/pkg/resources/resource_source_load_generator.go b/pkg/resources/resource_source_load_generator.go index 1fa0783b..216661bf 100644 --- a/pkg/resources/resource_source_load_generator.go +++ b/pkg/resources/resource_source_load_generator.go @@ -115,13 +115,6 @@ var sourceLoadgenSchema = map[string]*schema.Schema{ "ownership_role": OwnershipRoleSchema(), } -// Define the V0 schema function -func sourceLoadgenSchemaV0() *schema.Resource { - return &schema.Resource{ - Schema: sourceLoadgenSchema, - } -} - func SourceLoadgen() *schema.Resource { return &schema.Resource{ Description: "A load generator source produces synthetic data for use in demos and performance tests.", @@ -135,15 +128,7 @@ func SourceLoadgen() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: sourceLoadgenSchema, - SchemaVersion: 1, - StateUpgraders: []schema.StateUpgrader{ - { - Type: sourceLoadgenSchemaV0().CoreConfigSchema().ImpliedType(), - Upgrade: utils.IdStateUpgradeV0, - Version: 0, - }, - }, + Schema: sourceLoadgenSchema, } } diff --git a/pkg/resources/resource_source_postgres.go b/pkg/resources/resource_source_postgres.go index d41c26b8..6fba1493 100644 --- a/pkg/resources/resource_source_postgres.go +++ b/pkg/resources/resource_source_postgres.go @@ -68,13 +68,6 @@ var sourcePostgresSchema = map[string]*schema.Schema{ "ownership_role": OwnershipRoleSchema(), } -// Define the V0 schema function -func sourcePostgresSchemaV0() *schema.Resource { - return &schema.Resource{ - Schema: databaseSchema, - } -} - func SourcePostgres() *schema.Resource { return &schema.Resource{ Description: "A Postgres source describes a PostgreSQL instance you want Materialize to read data from.", @@ -88,15 +81,7 @@ func SourcePostgres() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: sourcePostgresSchema, - SchemaVersion: 1, - StateUpgraders: []schema.StateUpgrader{ - { - Type: sourcePostgresSchemaV0().CoreConfigSchema().ImpliedType(), - Upgrade: utils.IdStateUpgradeV0, - Version: 0, - }, - }, + Schema: sourcePostgresSchema, } } diff --git a/pkg/resources/resource_source_webhook.go b/pkg/resources/resource_source_webhook.go index 07d43ced..d3c7a0e2 100644 --- a/pkg/resources/resource_source_webhook.go +++ b/pkg/resources/resource_source_webhook.go @@ -152,13 +152,6 @@ var sourceWebhookSchema = map[string]*schema.Schema{ "ownership_role": OwnershipRoleSchema(), } -// Define the V0 schema function -func sourceWebhookSchemaV0() *schema.Resource { - return &schema.Resource{ - Schema: sourceWebhookSchema, - } -} - func SourceWebhook() *schema.Resource { return &schema.Resource{ Description: "**Private Preview** A webhook source describes a webhook you want Materialize to read data from.", @@ -172,15 +165,7 @@ func SourceWebhook() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: sourceWebhookSchema, - SchemaVersion: 1, - StateUpgraders: []schema.StateUpgrader{ - { - Type: sourceWebhookSchemaV0().CoreConfigSchema().ImpliedType(), - Upgrade: utils.IdStateUpgradeV0, - Version: 0, - }, - }, + Schema: sourceWebhookSchema, } } diff --git a/pkg/resources/resource_table.go b/pkg/resources/resource_table.go index 4c508816..4f51df72 100644 --- a/pkg/resources/resource_table.go +++ b/pkg/resources/resource_table.go @@ -67,13 +67,6 @@ var tableSchema = map[string]*schema.Schema{ "ownership_role": OwnershipRoleSchema(), } -// Define the V0 schema function -func tableSchemaV0() *schema.Resource { - return &schema.Resource{ - Schema: tableSchema, - } -} - func Table() *schema.Resource { return &schema.Resource{ Description: "A table persists durable storage that can be written to, updated and seamlessly joined with other tables, views or sources", @@ -87,15 +80,7 @@ func Table() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: tableSchema, - SchemaVersion: 1, - StateUpgraders: []schema.StateUpgrader{ - { - Type: tableSchemaV0().CoreConfigSchema().ImpliedType(), - Upgrade: utils.IdStateUpgradeV0, - Version: 0, - }, - }, + Schema: tableSchema, } } diff --git a/pkg/resources/resource_type.go b/pkg/resources/resource_type.go index d50bcb37..a7f1173d 100644 --- a/pkg/resources/resource_type.go +++ b/pkg/resources/resource_type.go @@ -90,13 +90,6 @@ var typeSchema = map[string]*schema.Schema{ "ownership_role": OwnershipRoleSchema(), } -// Define the V0 schema function -func typeSchemaV0() *schema.Resource { - return &schema.Resource{ - Schema: typeSchema, - } -} - func Type() *schema.Resource { return &schema.Resource{ Description: "A custom types, which let you create named versions of anonymous types.", @@ -110,15 +103,7 @@ func Type() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: typeSchema, - SchemaVersion: 1, - StateUpgraders: []schema.StateUpgrader{ - { - Type: typeSchemaV0().CoreConfigSchema().ImpliedType(), - Upgrade: utils.IdStateUpgradeV0, - Version: 0, - }, - }, + Schema: typeSchema, } } diff --git a/pkg/resources/resource_view.go b/pkg/resources/resource_view.go index cbb15f90..30e442fb 100644 --- a/pkg/resources/resource_view.go +++ b/pkg/resources/resource_view.go @@ -28,13 +28,6 @@ var viewSchema = map[string]*schema.Schema{ "ownership_role": OwnershipRoleSchema(), } -// Define the V0 schema function -func viewSchemaV0() *schema.Resource { - return &schema.Resource{ - Schema: viewSchema, - } -} - func View() *schema.Resource { return &schema.Resource{ Description: "Views represent queries of sources and other views that you want to save for repeated execution.", @@ -48,15 +41,7 @@ func View() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: viewSchema, - SchemaVersion: 1, - StateUpgraders: []schema.StateUpgrader{ - { - Type: viewSchemaV0().CoreConfigSchema().ImpliedType(), - Upgrade: utils.IdStateUpgradeV0, - Version: 0, - }, - }, + Schema: viewSchema, } }